[Omaha.pm] for loop quickie
Dr. Dhundy R. Bastola
kiranbina at gmail.com
Mon May 22 19:22:52 PDT 2006
I really appreciate when Andy breaks it up and makes people like us feel
welcome. I wanted to let you know that you are helping people like me learn
well by doing so. Thanks
Kiran
-----Original Message-----
From: omaha-pm-bounces+kiranbina=gmail.com at pm.org
[mailto:omaha-pm-bounces+kiranbina=gmail.com at pm.org] On Behalf Of Andy
Lester
Sent: Monday, May 22, 2006 4:14 PM
To: Perl Mongers of Omaha, Nebraska USA
Subject: Re: [Omaha.pm] for loop quickie
>
> after:
>
> for (@row) {
> s/[^ -~]//g;
> s/\|/:/g;
> }
Beautiful. Getting out of the C mindset of keeping a loop index is
one of the big steps into Perl mastery.
Note that in this example, there's an implicit $_ being used as the
loop variable. You can also make it explicit:
for my $entry (@row) {
$entry =~ s/...../;
}
In this case, although it looks like $entry is a temporary variable,
and that changes to $entry will get thrown away, that's not the
case. $entry is an alias to the iterated variable.
xoa
--
Andy Lester => andy at petdance.com => www.petdance.com => AIM:petdance
_______________________________________________
Omaha-pm mailing list
Omaha-pm at pm.org
http://mail.pm.org/mailman/listinfo/omaha-pm
More information about the Omaha-pm
mailing list