in reply to combining 2 files with 4 columns need help

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:

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;
Output:
$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' ] };
Do the display as you wish, sir... :)

If you tell me, I'll forget.
If you show me, I'll remember.
if you involve me, I'll understand.
--- Author unknown to me

Replies are listed 'Best First'.
Re^2: combining 2 files with 4 columns need help
by rruser (Acolyte) on May 29, 2013 at 16:52 UTC

    thanks so much just the data I need. not sure how to get it into columnar form..so much to learn

      how would i create a regex to read the multiline record? I can't seem figure out how to do this. thanks for the help.

      'CBTX 741274' => [ ' E ', ' 04/07/13', ' EOG ', ' 04/11/13'