Skip to content

Commit d93a61e

Browse files
committed
Finishes section on CLI refs #114
1 parent 4ae64b8 commit d93a61e

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

doc/Language/system.pod6

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ This will fail if the environment variable C<API_KEY> has not been defined previ
2121
2222
Perl 6 has a better way to deal with command line arguments if they represent file names: the L<C<$*ARGFILES>/language/variables#index-entry-%24%2AARGFILES> dynamic variable.
2323
24+
=begin code
25+
for $*ARGFILES.lines -> $l {
26+
say "Long lines in {$*ARGFILES.path}"
27+
if $l.chars > 72 ;
28+
}
29+
=end code
30+
31+
You can run this program this way C<argfiles.p6 *.p6>, for instance, and it will print a file name every time it finds a line longer than 72 characters. C<$*ARGFILES> contains filehandles of all files described in the command lines- C<.lines> will read in turn one line from every one of them, changing the value of C<$*ARGFILES.path> every time a new handle is being processed. In general, it provides a very convenient API for scripts that deal with sets of files.
2432
2533
=head1 Running programs synchronous and asynchronously
2634

0 commit comments

Comments
 (0)