On 7/15/07, Rodrick Brown <[EMAIL PROTECTED]> wrote:
@list = map { $c = $_; $c =~ s/\s+/_/g; $c } @d = grep { /\d/ } <FH>;
Is there a way to shorten the following mostly concerned with why I
have to use a temporary variable.
There reason you might need $c is that $_ maps directly to $d[0],
$d[1], etc., so changing $_ changes the element in @d. If you want to
save @d you need to prevent this behavior. One way is to use $c as in
the code above, another is to local'ize $_ to the map:
@list = map { local $_ = $_; s/\s+/_/g; $_ } @d = grep { /\d/ } <FH>;
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/