Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^5: = rather than =~ ? (too brief?)

by Aristotle (Chancellor)
on Jan 02, 2004 at 22:00 UTC ( #318424=note: print w/ replies, xml ) Need Help??


in reply to Re^4: = rather than =~ ? (too brief?)
in thread = rather than =~ ?

No, that is wrong. Satisfying strict depends only on the compile-time effect of my, for which its mere presence suffices. However, a conditional prevents its run-time effect of allocating a new scalar for that lexically scoped name, so that the name remains associated with the previously used variable. Observe:

use strict; use warnings; sub remember { my $memory if 0; print "Previous value of \$memory: $memory\n"; $memory = shift; } remember "foo"; remember 42; remember "bar"; remember; __END__ Use of uninitialized value in concatenation (.) or string at - line 6. Previous value of $memory: Previous value of $memory: foo Previous value of $memory: 42 Previous value of $memory: bar
This if 0 hack has been known for a long time and might even be useful if it weren't such a dirty trick. An actual condition in that place nearly certainly means that someone is going to be very surprised.

Makeshifts last the longest.


Comment on Re^5: = rather than =~ ? (too brief?)
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (7)
As of 2014-12-22 04:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (110 votes), past polls