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"
In reply to Re^4: I need to insert spaces and get the values for all the variables
by hdb
in thread I need to insert spaces and get the values for all the variables
by rahulruns
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |