Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^4: I need to insert spaces and get the values for all the variables

by hdb (Prior)
on Sep 04, 2013 at 08:52 UTC ( #1052258=note: print w/ replies, xml ) Need Help??


in reply to Re^3: I need to insert spaces and get the values for all the variables
in thread I need to insert spaces and get the values for all the variables

Your suggestion to split on " inspired me to use it as the record separator like this:

use strict; use warnings; use Data::Dumper; my %variables; my ($var,$val); local $/='"'; # thanks to Random_Walk while(<DATA>){ chomp; if( /=/ ) { s/[\n=]//g; # cleanup $var = $_; } else { push @{ $variables{$var} }, $_; } } print Dumper \%variables; __DATA__ dvgqu="0"vgrq="0"w="0"devce="db"elped_me="0"r="0"rmb="0"rrqm="0"vcm="0 +"ul="0"w="0"wmb="0"wrqm="0" dvgqu="0"vgrq="0"w="0"devce="d"elped_me="0"r="0"rmb="0"rrqm="0"vcm="0" +ul="0"w="0"wmb="0"wrqm="0" dvgqu="0.00"vgrq="0.00"w="0.00"devce="db"elped_me="1"r="0.00"rmb="0.00 +"rrqm="0.00"vcm="0.00"ul="0.00"w="0.00"wmb="0.00"wrqm="0.00" dvgqu="0.00"vgrq="58.91"w="0.09"devce="d"elped_me="1"r="0.00"rmb="0.00 +"rrqm="0.00"vcm="0.09"ul="0.05"w="5.50"wmb="324.00"wrqm="35.00"


Comment on Re^4: I need to insert spaces and get the values for all the variables
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1052258]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (8)
As of 2014-10-25 11:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (143 votes), past polls