in reply to Re: Style, *again*
in thread Style, *again*
Speaking of style... I took the liberty of rewriting your script.
#!/usr/bin/perl -w use strict; my $infile = shift; my $outfile = "$newfile.tmp"; open my $infh, '<', $infile or die "Cannot open $infile: $!\n"; open my $outfh, '>>', $outfile or die "Cannot open $outfile: $!\n"; while (<$infh>) { s/^\s+//g; s/\s+$//g; print $outfh $_, "\n" or die "Cannot write to $outfile: $!\n"; } close my $outfh or die "Cannot close $outfile: $!\n"; close my $infh or die "Cannot close $infile: $!\n"; system('perltidy', $outfile) == 0 or die "Perltidy failed\n"; rename "$outfile.tdy", $infile or die "Cannot rename $outfile.tdy: $!\ +n"; unlink $outfile or die "Cannot unlink $outfile: $!\n"; chmod 0755, $infile or die "Cannot chmod $infile: $!\n";
Changes include:
Juerd
- http://juerd.nl/
- spamcollector_perlmonks@juerd.nl (do not use).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Style, *again*
by zentara (Cardinal) on Apr 10, 2003 at 12:12 UTC |