#! usr/bin/perl -w use strict; if (@ARGV == 0) { print "usage: perl test.pl infile [infile]\n"; exit(1); } my $outfile = "outfile.txt"; open (OUTFILE, '>', $outfile) or die "unable to open $outfile : $!\n"; my @result; foreach my $infile (@ARGV) { open (INFILE, '<', $infile) or die "unable to open $infile : $!\n"; while () { chomp; my (@vars) = split(/;/,$_); push @result, "@vars"; print "Processed $infile line no.: $. vars= @vars\n"; } } print "Result Array contains: " . @result . " element(s).\n"; writeToFile( \@result); sub writeToFile { my $array_ref = shift; foreach ( @{ $array_ref } ) { print OUTFILE "$_\n"; } } __END__ infile.txt: 1;2;3 a;b;c 4;5;6 infile2.txt: X;Y;Z 9;10;11 C:\TEMP>perl newbie3.pl infile.txt infile2.txt Processed infile.txt line no.: 1 vars= 1 2 3 Processed infile.txt line no.: 2 vars= a b c Processed infile.txt line no.: 3 vars= 4 5 6 Processed infile2.txt line no.: 4 vars= X Y Z Processed infile2.txt line no.: 5 vars= 9 10 11 Result Array contains: 5 element(s). C:\TEMP>cat outfile.txt 1 2 3 a b c 4 5 6 X Y Z 9 10 11