Aaron Sherman skribis 2004-05-12 14:04 (-0400):
> Perl 5:
>         #!/usr/bin/perl
>         while(<>) {
>               s/\w+/WORD/g;
>               print;
>         }
> Perl 6:
>         #!/usr/bin/perl
>         while $stdin.getline -> $_ {

Empty <> uses ARGV, not STDIN. It only uses STDIN if not @ARGV (or if
'-' is in @ARGV).

>               s:g/\w+/WORD/;
>               $stdout.print;

A2 says $*STDIN and $*STDOUT. Has this been changed?

Also, will there no longer be the concept of a selected filehandle? I'd
hate to have to specify stdin and stdout in throw away scripts.

>         }

I think I like this better:

    for <> {
        s:g/\w+/WORD/;
        print;
    }

But I think I still want to have some non-mutating version of s/// that
returns the modified string, so that you can just write something like

    print s:gx/\w+/WORD/ for <>;


Juerd

Reply via email to