Hi, I approached with your suggestions, but facing some issues after appending some identical data for a key.
my %HoA; print "Input Data parsed into 3 columns:"; while (my $line = <DATA>) { my ($col1,$restcol) = split /:\s*/, $line ,2; my @restColumns = split '', $restcol; $HoA{$col1} = [@restColumns]; } print "Dumping Output \n"; for my $dataKey (keys %HoA) { print "$dataKey: ", join("\t\t", @{$HoA{$dataKey}}), \n"; } __DATA__ ULTRIX : CW18.72.0.3 IP-HOST1.log DEC_DECSTATION : CW180.72.0.3 IP_HOST_AL.log DEC_DECSTATION_ADDR : CW180.72.0.3 IP_HOST_al2.log FOR_VISITORS23_HOST : HL617.253.1101.2 IP_HOST_hostinfo.log FOR_VISITORS24_HOST : HL617.253.1101.2 IP_HOST_hostinfo2.log FOR_VISITORS25_HOST : HL617.253.1101.2 IP_HOST_webform3.log FOR_VISITORS25_HOST : HL617.253.1101.2 IP_HOST_webform4.log FOR_VISITORS25_HOST : HL617.253.1201.2 IP_HOST_webform4.log
I get the output as below:
FOR_VISITORS25_HOST HL617.253.1201.2 IP_HOST_webform4.log DEC_DECSTATION CW180.72.0.3 IP_HOST_AL.log FOR_VISITORS23_HOST HL617.253.1101.2 IP_HOST_hostinfo.log DEC_DECSTATION_ADDR CW180.72.0.3 IP_HOST_al2.log ULTRIX CW18.72.0.3 IP-HOST1.log FOR_VISITORS24_HOST HL617.253.1101.2 IP_HOST_hostinfo2.log
As shown DATA contains two rows for key FOR_VISITORS25_HOST. But in output is considered only once(As keys are unique to hash).
FOR_VISITORS25_HOST HL617.253.1101.2 IP_HOST_webform3.log FOR_VISITORS25_HOST HL617.253.1101.2 IP_HOST_webform4.log
I understand every entry for the same key overwrites previous one and keeps the last value encountered for the key. Tried swapping key and values but no luck!!!
Another approach is, Now I can have data in below format
FOR_VISITORS25_HOST HL617.253.1101.2 : IP_HOST_webform3.log FOR_VISITORS25_HOST HL617.253.1101.2 : IP_HOST_webform4.log
Where I can consider key as <FOR_VISITORS25_HOST HL617.253.1101.2> and values are IP_HOST_webform3.log & IP_HOST_webform4.log
But yet, Is there a way out I can prepare a output as below or I am thinking wrong?Thanks.FOR_VISITORS25_HOST HL617.253.1101.2 IP_HOST_webform3.log IP_HOST_webform4.log ...... ...... <more values for + same key>
In reply to Re^2: Storing the log file name as key/value in hash
by Magnolia25
in thread Storing the log file name as key/value in hash
by Magnolia25
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |