Re: Subroutines and '&'



"Sherm" == Sherm Pendley <spamtrap@xxxxxxxxxxx> writes:

Sherm> It *does* make a difference - if you don't know or understand what that
Sherm> difference is, or you don't specifically want the behavior specified by
Sherm> the &, you shouldn't use it.

Or, for the opposite point of view, if you have:

sub log { print STDERR localtime() . ": @_\n" }

then you better darn well invoke it as:

&log("my message");

and *not*:

log("my message"); # invokes built-in logarithm function

And until you know all the perl built-ins, you should use &. And this
is what we teach in Learning Perl.

Please don't be so quick to dismiss the value of the leading &.

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@xxxxxxxxxxxxxx> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

--
Posted via a free Usenet account from http://www.teranews.com

.



Relevant Pages

  • Re: SOLVED: How do I scope a variable if the variable name contains a variable?
    ... Sherm> A related question - I recall reading here that Perl has a ... Sherm> limit on the length of its symbols. ... Sherm> reason to limit key lengths for one particular hash tree when ... has now been relaxed (as of Perl 5.6, ...
    (comp.lang.perl.misc)
  • Re: Subroutines and &
    ... Sherm> the &, you shouldn't use it. ... Or, for the opposite point of view, if you have: ... And until you know all the perl built-ins, ...
    (comp.lang.perl.misc)
  • Re: Subroutines and &
    ... Sherm> the &, you shouldn't use it. ... Or, for the opposite point of view, if you have: ... And until you know all the perl built-ins, ...
    (comp.lang.perl.misc)
  • Re: Perl, IIS 6.0 Win2K3 and CGI
    ... I dont want to get into an IIS vs Apache battle. ... I was even thinking there maybe a web framework for Perl. ... Thanks again Sherm. ...
    (comp.lang.perl.misc)
  • Re: long running perl programs & memory untilization
    ... >> nothing like 'local' in C, but more like the opposite. ... >> In Perl you should use 'my' to localise variables. ... "They that would give up essential liberty for temporary safety deserve ...
    (comp.lang.perl.misc)