in reply to Use of "my" after Perl v5.14
I missed one of your questions, apologies:
Significance of "my": It has a measurably distinguished behavior distinct from "our". Most notably useful in Modules.
Pay attention to the value of $TRUE in the sample:
This is t2.pm:
#!/usr/bin/perl use strict; package t2; # -------------------------------------------------------------------- +---------- # Constants (Operationally, if not technically) # -------------------------------------------------------------------- +---------- our $RET_SUCCESS = 0; our $RET_FAILURE = (-1); our $RET_FATAL = (-2); my $TRUE = 1; my $FALSE = 0; # -------------------------------------------------------------------- +---------- # version() - Returns the version number of this module # -------------------------------------------------------------------- +---------- sub version { return sprintf "0.10a"; } # -------------------------------------------------------------------- +---------- # Perl modules MUST return true # -------------------------------------------------------------------- +---------- 1; __END__
This is t3.pl:
#!/usr/bin/perl use strict; use t2; print "our: \$t2::RET_FAILURE = '$t2::RET_FAILURE'\n"; print " my: \$t2::TRUE = '$t2::TRUE'\n"; exit; __END__
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Use of "my" after Perl v5.14
by Rohit Jain (Sexton) on Sep 20, 2012 at 22:58 UTC | |
Re^2: Use of "my" after Perl v5.14
by Rohit Jain (Sexton) on Sep 20, 2012 at 22:55 UTC | |
by marinersk (Priest) on Sep 21, 2012 at 01:10 UTC | |
by AnomalousMonk (Archbishop) on Sep 21, 2012 at 09:19 UTC |
In Section
Seekers of Perl Wisdom