> >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;
@results seems would be re-assigned when the next file comes...
Besides, I guess chomp is not nesessary here.. \s+ means [\t\r\n\f]+,
so \r, \n or \r\n would seem to be cleared by the s expression.
> $line } (<IN>);
> close IN;
> }
>
I would suggest to write in this way :
my @res = ();
foreach( @ARGV ) {
open IN, $_ or die "Couldn't open $_: $!\n";
my @data = <IN>;
close IN;
s/\s+//g for @data;
@res = ( @res, @data );
}
Code not been tested, but the concept is something like this.
HTH
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>