SPUG: Where is grep's return value?

Parr, Ryan Ryan.Parr at wwireless.com
Tue Sep 10 19:22:17 CDT 2002


Except you no longer have the construct of "@r = grep {} @" which is what's
intended.

-- Ryan

-----Original Message-----
From: Asim Jalis [mailto:asimjalis at acm.org]
Sent: Tuesday, September 10, 2002 4:49 PM
To: Jeremy Mates
Cc: 'spug-list at pm.org'
Subject: Re: SPUG: Where is grep's return value?


On Tue, Sep 10, 2002 at 04:27:08PM -0700, Jeremy Mates wrote:
> * Orr, Chuck  (NOC) <chuck.orr at attws.com> [2002-09-10T16:08-0700]:
> > if (grep("$KEY",EXISTING)){
> 
> perl -le '@a=qw(a b c); if (@r = grep { $_ eq "b" } @a) { print "@r" }'

The "if" and "@r" temporary variable can be removed:

perl -le '@a=qw(a b c); print grep { $_ eq "b" } @a'


Asim

 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
      Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
  Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
 For daily traffic, use spug-list for LIST ;  for weekly, spug-list-digest
     Seattle Perl Users Group (SPUG) Home Page: http://seattleperl.org

 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
      Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
  Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
 For daily traffic, use spug-list for LIST ;  for weekly, spug-list-digest
     Seattle Perl Users Group (SPUG) Home Page: http://seattleperl.org




More information about the spug-list mailing list