Hello,
Hello,
I have the following input as an example:
$_ = <<DATA; servicedescr:Disk Usage output:DISK OK - free space: / 21994 MB (76%): /boot 80 MB (81%): /dev/shm 1732 MB (100%): /var/lib/mysql 200680 MB (43%): perfdata: /=7071MB;23251;26157;0;29064 /boot=18MB;78;88;0;98 /dev/shm=0MB;1384;1557;0;1731 /var/lib/mysql=268606MB;375428;422357;0;469286 DATA
Now, if I run this following regular expression against it: /output:.*DISK.*-.free.space:.(\S+).*MB.\((\d+)%\):.(\S+).*MB.\((\d+)% \):.(\S+).*MB.\((\d+)%\):.(\S+).*MB.\((\d+)%\):.(\S+).*MB.\((\d+)%\):/
So two questions,
1. I can simplify the above regexp by using groups correct ? /output:.*DISK.*-.free.space:(.(\S+).*MB.\((\d+)%\):){1,}/
2. It breaks it up into parts, $1,$2,$3,$4, .... etc. Can I save the parts into an array ?
To answer your second question first, yes:
$ perl -le' $_ = q/ 123 abc 4567 defgh /; my @x = /(\w+)\s+(\w+)\s+(\w+)\s+(\w+)/; print map ">$_< ", @x; ' >123< >abc< >4567< >defgh<
As to your first question, it will MATCH the same string but it will not CAPTURE the same strings, it will only capture the contents of existing parentheses:
$ perl -le' $_ = q/ 123 abc 4567 defgh /; my @x = /^\s*((\w+)\s+){1,}\s*$/; print map ">$_< ", @x; ' >defgh< >defgh<
John -- use Perl; program fulfillment
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>