[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Omaha.pm] map {} instead of $i



1. oh I get it.
2. perdoc -f map...damn you Jay!
----- Original Message ----- From: "Jay Hannah" <jay@jays.net>
To: "Nebraska USA Perl Mongers of Omaha" <omaha-pm@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@pm.org
http://mail.pm.org/mailman/listinfo/omaha-pm