[ILUG] ot: perl

Justin Mason jm at jmason.org
Wed Mar 8 13:00:10 GMT 2000


Michael Turley said:

> Whats the difference between my and local in Perl? 

* my is newer than local (perl5 vs. perl4).

* my can be used halfway through a func whereas local needs to be right
at the top scope IIRC.

* local allows you to scope global variables, e.g.
	local ($_);
will allow you to use $_ without affecting whatever value a higher-level
function may have been using in it.

* my is better for perl's garbage collection mechanism I think.

* etc.: see http://www.plover.com/~mjd/perl/local.html and
http://www.plover.com/~mjd/perl/FAQs/Namespaces.html

--j.




More information about the ILUG mailing list