Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: reset function (never)

by Anonymous Monk
on Nov 21, 2013 at 01:57 UTC ( [id://1063660]=note: print w/replies, xml ) Need Help??


in reply to reset function

never use the reset function to reset variables

Also read Tutorials: Variable Scoping in Perl: the basics,
Coping with Scoping , Mini-Tutorial: Perl's Memory Management,
Lexical scoping like a fox,

Also

Learn Perl in about 2 hours 30 minutes
chromatics free book Modern Perl a loose description of how experienced and effective Perl 5 programmers work....You can learn this too.
PLEAC - Programming Language Examples Alike Cookbook

Replies are listed 'Best First'.
Re^2: reset function (never)
by LanX (Saint) on Nov 21, 2013 at 02:33 UTC
    Once in a while I repeat saying something like

    "Perl doesn't stop to surprise me!"

    And I always hope the intervals between these moments will get bigger...

    But now... oh man ... this reset builtin is really scary!

    DB<132> @x=(4,2);$x=42; $y=0; while ($y++<3) { $x=$y; print "$x -" ; reset('x') if $y>1 ; print " $x : @x\n"; } 1 - 1 : 4 2 2 - : 3 - :

    IMHO it doesn't "reset" at all, it just deletes all variables of the glob *x without deleting the glob.

    Only delete $main::{'x'} is more radical...

    o_O WTF !?!

    Cheers Rolf

    ( addicted to the Perl Programming Language)

    update

    Me thinks this must be a relict of one-liner hacking. Anything else is just to dangerous..

      WOW!! WTF, indeed! I can understand something that would reset a match, but variables that start with a given letter? Can someone provide a use-case for this that makes sense?

      It helps to remember that the primary goal is to drain the swamp even when you are hip-deep in alligators.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2024-04-19 23:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found