[EMAIL PROTECTED] schreef:
> use strict;
> use warnings;
>
> open (MYDATAS , "<testing.txt") || die $!;
> my @datas = <MYDATAS>;
> close MYDATAS;
>
> foreach (@datas){
> s/^\s*$//;
> }
>
> open (WRITEDATAS, ">testing.txt") || die $!;
> print WRITEDATAS @datas;
> close WRITEDATAS;
That looks a lot like Perl 4. Study this:
#!/usr/bin/perl
use strict;
use warnings;
my $fname_in = "testing.in";
my $fname_out = "testing.out";
{ open my $fh_in, "<", $fname_in or die $!;
open my $fh_out, ">", $fname_out or die $!;
while (<$fh_in>) {
s/\A\s+//;
s/\s+\z//;
print $fh_out $_, $/;
}
}
__END__
Strong variant:
#!/usr/bin/perl -wlpi.bak
s/^\s+//;
s/\s+$//;
__END__
(meant to be called with the names of all files to be converted
(in-place))
See also perlrun, specifically about the -i argument.
--
Affijn, Ruud
"Gewoon is een tijger."
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/