> >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>
- How to dynamically taking the multiple input arguments? Edward WIJAYA
- Re: How to dynamically taking the multiple input argu... Errin Larsen
- Re: How to dynamically taking the multiple input ... Errin Larsen
- Re: How to dynamically taking the multiple in... David Greenberg
- Re: How to dynamically taking the multipl... Errin Larsen
- Re: How to dynamically taking the mu... David Greenberg
- Re: How to dynamically taking th... Errin Larsen
- Re: How to dynamically taking the mu... John W. Krahn
- Re: How to dynamically taking the multipl... Bee
- Re: How to dynamically taking the mu... Errin Larsen
- Re: How to dynamically taking th... David Greenberg
- Re: How to dynamically takin... Errin Larsen
- Re: How to dynamically takin... David Greenberg
- Re: How to dynamically takin... Bee
- Fwd: How to dynamically taki... Errin Larsen
- Re: How to dynamically takin... John W. Krahn
- Re: How to dynamically taking th... Bee
- Re: How to dynamically taking the mu... John W. Krahn
- Re: How to dynamically taking the multiple input argu... John W. Krahn
