On Apr 5, 2005 5:53 PM, Michael Gale wrote:
> 
> So two questions,
> 
> 1. I can simplify the above regexp by using groups correct ?
>  /output:.*DISK.*-.free.space:(.(\S+).*MB.\((\d+)%\):){1,}/
> 

Yes, you can simplify by using groups, but there's something wrong
with both your REs, IMHO. What exactly are you trying to capture from
the data? Your RE looks too complex to me. I think you are trying to
get the path name and percentage number, right? Well, here's one way:
   /(\/\S*).+?\((\d+)/sg
Note the "s" modifier - your data is multiline, so I need the "s"
modifier to make "." match a newline.

> 2. It breaks it up into parts, $1,$2,$3,$4, .... etc. Can I save the
> parts into an array ?

Simply assign the result of the match to an array:
my @arr = /(\/\S*).+?\((\d+)/sg;

-- 
Offer Kaye

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


Reply via email to