[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Omaha.pm] for loop quickie
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@pm.org
[mailto:omaha-pm-bounces+kiranbina=gmail.com@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@petdance.com => www.petdance.com => AIM:petdance
_______________________________________________
Omaha-pm mailing list
Omaha-pm@pm.org
http://mail.pm.org/mailman/listinfo/omaha-pm