develooper Front page | perl.perl6.meta | Postings from May 2001

Re: perl5 to perl6

Thread Previous | Thread Next
From:
Chaim Frenkel
Date:
May 11, 2001 06:41
Subject:
Re: perl5 to perl6
Message ID:
m3oft09fas.fsf@csamnycln01.nyc.csam.com
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 <gnat@oreilly.com> 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.
chaimf@pobox.com				               +1-718-236-0183

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About