Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Perl Beginners > Re: Array eleme...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 3 of 7 Topic 11009 of 11509
Post > Topic >>

Re: Array element split, with grep

by Uri Guttman <uri@[EMAIL PROTECTED] > Apr 30, 2008 at 08:39 PM

>>>>> "SB" == Steve Bertrand <iaccounts@[EMAIL PROTECTED]
> writes:

  SB> Steve Bertrand wrote:
  >> Hi all,
  >> Can someone explain to me how I can fix this up to achieve my desired
  >> results?
  >> my $time = (split (/:/, (grep (/^info/, @[EMAIL PROTECTED]
))))[0];

  SB> I figured it out :)

  SB> my $time = (split (/:/, (grep (/^info/, @[EMAIL PROTECTED]
))[0]))[0];

  SB> I neglected to realize that the result from grep was in scalar
context
  SB> until I specified it as an array.

overkill.

my ($time) = map { /^(info\d+):/ ? $1 : () } @[EMAIL PROTECTED]
 ;

uri

-- 
Uri Guttman  ------  uri@[EMAIL PROTECTED]
  --------  http://www.sysarch.com
--
-----  Perl Code Review , Architecture, Development, Training, Sup****t
------
--------- Free Perl Training --- http://perlhunter.com/college.html
---------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com
---------
 




 7 Posts in Topic:
Array element split, with grep
iaccounts@[EMAIL PROTECTE  2008-04-30 15:37:10 
Re: Array element split, with grep
iaccounts@[EMAIL PROTECTE  2008-04-30 15:43:54 
Re: Array element split, with grep
Uri Guttman <uri@[EMAI  2008-04-30 20:39:39 
Re: Array element split, with grep
rob.dixon@[EMAIL PROTECTE  2008-04-30 22:12:12 
Re: Array element split, with grep
krahnj@[EMAIL PROTECTED]   2008-04-30 14:47:36 
Re: Array element split, with grep
krahnj@[EMAIL PROTECTED]   2008-04-30 14:42:25 
Re: Array element split, with grep
noreply@[EMAIL PROTECTED]  2008-05-01 00:20:37 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Jul 23 21:15:51 CDT 2008.