[Omaha.pm] map {} instead of $i
trey-b at cox.net
trey-b at cox.net
Thu Feb 11 18:04:40 PST 2010
1. oh I get it.
2. perdoc -f map...damn you Jay!
----- Original Message -----
From: "Jay Hannah" <jay at jays.net>
To: "Nebraska USA Perl Mongers of Omaha" <omaha-pm at pm.org>
Sent: Thursday, February 11, 2010 1:56 PM
Subject: [Omaha.pm] map {} instead of $i
> BEFORE:
>
> foreach (my $i=0; $i < scalar(@a); $i++) {
> $a[$i] = -1 unless (defined $a[$i]);
> }
>
>
> AFTER:
>
> @a = map { defined $_ ? $_ : -1 } @a;
>
>
> Your thoughts?
>
> j
>
>
> _______________________________________________
> 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