Skip to content

Commit 7381d5d

Browse files
committed
[tutorial] allow filename def on command line
1 parent 96af943 commit 7381d5d

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

categories/tutorial/01-word-wrap.pl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@
1212

1313
my $line_length = 50;
1414

15-
my $tempfile = open('lorem.txt', :r);
16-
my $count = 0;
17-
for $tempfile.lines {
18-
$count++;
19-
lines(words($_));
15+
sub MAIN($input-file = $*SPEC.catdir($*PROGRAM-NAME.IO.dirname, "lorem.txt")) {
16+
my $tempfile = open($input-file, :r);
17+
my $count = 0;
18+
for $tempfile.lines {
19+
$count++;
20+
lines(words($_));
21+
}
2022
}
2123

22-
exit 0;
23-
2424
# Split a line into words (array)
2525
sub words ($in) {
2626
return $in.split(/\s/);

0 commit comments

Comments
 (0)