the strings that I need to regex from is as below:
colour -name red -value 8,0,2 -code 0
colour -name blue -value 9 -code 1
colour -name yellow -value 7,3,2.5 -code 1
The required output is hash of colour name and value
red 8,0,2 blue 9 yellow 7,3,2.5
Piece of code:
#/usr/perl;
my %result = {};
my @word = split ' ', $line ; #$line has each of the line of data that is read from text
$result{$word[2]} = $word[4];
But this is not giving the required output for the values where there are commas. TIA.
required output
ITEMS
red 8,0,2 blue 9 yellow 7,3,2.5
obtained output
ITEMS
red 8 0 2 blue 9 yellow 7 3 2.5
%resultto see the content of result hash.use Data::Dumper; #your code; print Dumper(\%result);red 8,0,2 blue 9 yellow 7,3,2.5in one single cell of csv. Can you please help me with the write to csv of this output? header shouldITEMSand below it in one cellred 8,0,2 blue 9 yellow 7,3,2.5ITEMSred 8,0,2 blue 9 yellow 7,3,2.5obtained outputITEMSred 80 2 blue 9yellow 7 32.5ITEMSand first cell with contentred 8,0,2 blue 9 yellow 7,3,2.5?