my %vars = split /=?"/, $line;
This splits on any " optionally preceded by the = sign.
use strict; use warnings; use Data::Dumper; my @store; # put the results in here while (<DATA>) { chomp; next unless /\S+/; # Ignore empty lines my %vars = split /=?"/; # Do the splits push @store, \%vars; # record these samples } print Dumper \@store; # Look what we got __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"
I just saw the variable name 'w' appears twice in the lines. In this case my code only keeps the last value. You may need to do something a little more complicated
Cheers,
R.
In reply to Re^3: I need to insert spaces and get the values for all the variables
by Random_Walk
in thread I need to insert spaces and get the values for all the variables
by rahulruns
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |