Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^4: Perl cheat sheet

by ikegami (Pope)
on Jan 07, 2009 at 01:24 UTC ( #734536=note: print w/ replies, xml ) Need Help??


in reply to Re^3: Perl cheat sheet
in thread Perl cheat sheet

That's something most people will never need to know.

The problem is that new programmers love to put *everything* in quotes. While it's a bad idea to pass global (lexical and package) variables as arguments, that is probably not a problem you'll ever run into. Just about every sub already creates a copy of the value before it can change.

sub logger { my ($arg) = @_; # The copying happens here, so ... # no need to do it in the caller. }

One could even argue it's the sub's responsibility to protect global variables it changes if it uses @_ at any other point.


Comment on Re^4: Perl cheat sheet
Select or Download Code
Replies are listed 'Best First'.
Re^5: Perl cheat sheet
by ursus (Acolyte) on Jan 07, 2009 at 06:10 UTC
    Sometimes I forget that "never" means "you probably don't want to". ;-) Next time I'm in that code, I'll make it the responsibility of the called function. Thanks.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://734536]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2015-07-29 23:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (269 votes), past polls