On Jul 16, 12:12 am, [EMAIL PROTECTED] (Rodrick Brown) 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.

Yes it bugged me too. That's why I contributed List::MoreUtils::apply.

use List::MoreUtils 'apply';
@list = apply { s/\s+/_/g } @d = grep { /\d/ } <FH>;

Note: This is basically just syntactic sugar for what you did in the
first place. There are, as others have pointed out, perfectly adequate
ways to to this without List::MoreUtils::apply() but sometimes the
apply() idiom seems more natural.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to