On Wed, Apr 27, 2011 at 04:32:57PM +0100, jet speed wrote:
> Hi all,
> 
> Thanks for all our inputs,
> 
> The regular expression below works fine if do it for single line, i am
> trying to caputre the match $1, and $2 into array. only the first line
> is pushed to the array. what am i doing wrong ?
> how to get all the $1 and $2 match values for each line into arrary ?
> Kindly advice.
> 
> 
> # more wwnlist
> 0079 Not Visible             6000097000029260057253303030373
> 007A Not Visible             6000097000029260057253303030374
> 007B Not Visible             6000097000029260057253303030374
> 007C Not Visible             6000097000029260057253303030374
> 007D Not Visible             6000097000029260057253303030374
> 007E Not Visible             6000097000029260057253303030374

> if ($_=~/\b(\d{4})\s[a-z]{1,3}\s[a-z]{1,7}\s*(\d{1,32})\b/i) {

\d doesn't match hex digits or, at least not all of them.

Instead of your first \d you could use [0-9A-F] which actually matches exactly
the characters you want.  \d will also match many characters you probably
don't want to match, unfortunately.

However, I might be tempted to go with Rob's second solution, unless you are
sure each line matches that regexp exactly.  And if you are, is it always "Not
Visible" in there, or can it really be any three and seven letter words?  If
not, why not use "Not Visible" in your regexp?

-- 
Paul Johnson - p...@pjcj.net
http://www.pjcj.net

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to