Re: perl5 to perl6
[email protected] (Chaim Frenkel) 11 May 2001 09:38:19 -0400
| Newsgroups | perl.perl6.meta |
|---|---|
| Message-ID | <[email protected]> |
Those are all major typo inducing changes. You'll need alternative micro-code loads for your fingers, when switching between clients and when editing scripts that pre-date Perl 6. <chaim> >>>>> "NT" == Nathan Torkington <[email protected]> writes: NT> Here's a program I use to count messages in my mailfile: NT> #!/usr/bin/perl -w NT> while (<>) { NT> if (($who) = /^From\s+\S+\s+\S+\s+(\S+\s+\S+)/) { NT> @r = reverse split ' ', $who; NT> $r[0] = sprintf("%02d", $r[0]); NT> $count{"@r"}++; NT> } NT> } NT> foreach (sort keys %count) { NT> printf("%s: %3d\n", $_, $count{$_}); NT> } NT> Here's the corresponding perl6 program: NT> #!/usr/bin/perl -w NT> while (<$ARGS>) { NT> if (($who) = /^From\s+\S+\s+\S+\s+(\S+\s+\S+)/) { NT> @r = reverse split ' ', $who; NT> @r[0] = sprintf("%02d", @r[0]); NT> %count{"@r"}++; NT> } NT> } NT> foreach (sort %count) { NT> printf("%s: %3d\n", $_, %count{$_}); NT> } NT> Notice the variable changes: %count{...} because I'm talking about the NT> hash %count. @r[0] because I'm talking about the array @r. NT> Nat -- Chaim Frenkel Nonlinear Knowledge, Inc. [email protected] +1-718-236-0183