James Edward Gray II wrote:
1. You show a means of variable declaration that you say replaces my() when in fact it's equivalent to our().

2. Your use of local() is scary at best. It looks like a step backwards in Perl history to me. local() is pretty misunderstood to begin with and I don't think we, of all people, should be adding to the problem.


I guess I am think as a brick:

#! /usr/bin/perl -T

use strict;
use warnings;

my $outside = 5;

sub change_5 () {
# *local* is needed to fix this...
  $outside = 7;
  print "Inside sub: $outside\n\n";
}

&change_5();
print "Out of sub: $outside\n\n";

our $alsooutside = 5;

sub change_5a () {
# *local* is needed to fix this...
  $alsooutside = 7;
  print "Inside sub: $alsooutside\n\n";
}

&change_5a();
print "Out of sub: $alsooutside\n\n";

# both vars - (also)outside - came into
# existence by some other means - usage
# is to shorten the example...


3. You are knowingly encouraging beginners to riddle their code with global variables. I think they can come up with enough bad habits

Not trying to invent anything -- these are real examples I see everyday in the wild...

without us inventing new ones for them. My feeling is that we should be doing exactly the opposite, helping them to find the good habits.


We are ;)

--
_Sx_ http://youve-reached-the.endoftheinternet.org/ _____
perldoc -qa.a | perl -lpe '($_)=m("(.*)")' | grep Martian

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to