>foreach( @ARGV ) {
>       open IN, $_ or die "Couldn't open $_: $!\n";
>       chomp( my @data = <IN> );
>       close IN;
>       foreach( @data ) { s/\s+//g; }
>       foreach( 0..$#data ) { $results[$_] .= $data[$_]; }
>}
This is a little shorter and saves on iterations:
for my $file (@ARGV) {
     open IN, $file or die "Couldn't open $file: $!\n";
     @results = map { my $line = $_; chomp $line; $line =~ s/\s+//g;
$line } (<IN>);
     close IN;
}

-David

On Fri, 10 Sep 2004 11:35:09 -0500, Errin Larsen <[EMAIL PROTECTED]> wrote:
> Here ya go ... this works for me.  I tested it with up to 5 input
> files and it was still workin'.  It does have a bug, though.  It
> doesn't check whether all the input files are the same length.  Nor
> did I test what happens when they AREN'T the same length.  Let me know
> what ya think:
> 
> #!/usr/bin/perl
> 
> use warnings;
> use strict;
> 
> unless( @ARGV >= 2 ) { die "Usage: $0 file1 file2 [file3...]\n"; }
> 
> my @results;
> 
> foreach( @ARGV ) {
>         open IN, $_ or die "Couldn't open $_: $!\n";
>         chomp( my @data = <IN> );
>         close IN;
>         foreach( @data ) { s/\s+//g; }
>         foreach( 0..$#data ) { $results[$_] .= $data[$_]; }
> }
> 
> foreach( @results ) { print "$_\n"; }
> 
> 
> 
> --Errin
> 
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
> 
>

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to