David Newman wrote:
On 1/2/09 5:22 PM, Rob Dixon wrote:
David Newman wrote:
my $lfile = $ARGV[0];
my $rfile = $ARGV[1];
It would also be nice to make sure that there are in fact two parameters
die "The parameters must be the the two files for comparison"
unless @ARGV == 2;
my ($lfile, $rfile) = @ARGV;
Is this for readability?
List assignment is one of the more common idioms in Perl, and as such
has been optimised to perform better in most cases. Although in this
instance speed is not really an issue.
I always found it "cleaner", and have heard others say it's preferable,
to declare all variables at the top of the program (although admittedly
I didn't do that even in this short script).
It is always better to limit the scope of variables. If variables need
to be in file scope anyway then a few lines one way or the other
probably won't make that much difference.
John
--
Those people who think they know everything are a great
annoyance to those of us who do. -- Isaac Asimov
--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/