On Thu, 17 Mar 2005 12:55:02 -0800 "John W. Krahn" <[EMAIL PROTECTED]> wrote:
> Chris Knipe wrote: > > Lo all, > > Hello, > > > 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? > print Dumper \%hash; > ' > $VAR1 = { > 'bytes' => '10829240,2009327', > 'mac-address' => '00:02:6F:36:2D:31', > 'packets' => '12623,18377', > 'frames' => '12623,18377', > 'wds' => 'no', > 'interface' => 'something very long with spaces and all', > 'rx-rate' => '11Mbps', > 'ap' => 'no', > 'tx-rate' => '11Mbps' > }; > > > > 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> > > > -- Whatever you do will be insignificant,but the important is you do it! -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>