Renqilong wrote:
On Thu, 17 Mar 2005 12:55:02 -0800
"John W. Krahn" <[EMAIL PROTECTED]> wrote:
Chris Knipe wrote:
I tried to do this with split(), but it's not working good at all....
The string:
interface=something very long with spaces and all
mac-address=00:02:6F:36:2D:31 ap=no wds=no rx-rate=11Mbps tx-rate=11Mbps
packets=12623,18377 bytes=10829240,2009327 frames=12623,18377
(the above is one line, wrapped for email).
I need to grab the values for all the options....
$ perl -le'
use Data::Dumper;
my $string = q/interface=something very long with spaces and all
mac-address=00:02:6F:36:2D:31 ap=no wds=no rx-rate=11Mbps tx-rate=11Mbps
packets=12623,18377 bytes=10829240,2009327 frames=12623,18377/;
my %hash = $string =~ /(\S+)=([^=]+)(?:\s+|$)/g;
=====> would you kindly explain how this (?:\s+|$) works?
Sure. (?:) are non-capturing parentheses so the pattern inside will not be
returned in list context like normal capturing parentheses. The pattern says
to match EITHER \s+ (one or more whitespace characters) OR $ (the end of the
line.)
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>