Hi rruser,
I can't figure out how to combine my two files to get the desired output.
Since, you are reading both files the same way there is no need doing the same it over and over again.
If I may give you a head up, something like so:
Output:use warnings; use strict; use Data::Dumper; my %collector; foreach my $file (@ARGV) { open my $fh, '<', $file or die $!; while (<$fh>) { chomp; my @vals = split /,/, $_, 4; if ( !exists $collector{ $vals[0] } ) { $collector{ $vals[0] } = [ @vals[ 1 .. 3 ] ]; } else { push @{ $collector{ $vals[0] } }, $vals[2]; } } } print Dumper \%collector;
Do the display as you wish, sir... :)$VAR1 = { 'CRDX 7067' => [ ' L', ' 04/05/13', ' TYCO', ' 04/20/13' ], 'AOKX 495408' => [ ' L', ' 04/02/13', ' SWCOMP', ' 04/20/13', ' 04/15/13' ], 'BLHX 102' => [ ' L', ' 04/01/13', ' WILDCOM', ' 04/03/13', ' 04/30/13' ], 'WW 9030' => [ ' L', ' 04/02/13', ' HALLI', ' 04/30/13' ] };
In reply to Re: combining 2 files with 4 columns need help
by 2teez
in thread combining 2 files with 4 columns need help
by rruser
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |