Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Re: Re: variables allowed inside iterative loops in regular expressions?

by dvergin (Monsignor)
on Nov 06, 2002 at 20:25 UTC ( [id://210881]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: variables allowed inside iterative loops in regular expressions?
in thread variables allowed inside iterative loops in regular expressions?

Been there. Paid the price. No t-shirt.

Let me suggest the advice to newbies be stronger than "it's a good idea not to".

Yes, $a and $b can be declared lexically and they work fine. But this trashes their subsequent use in a sort within the same scope.

I wasted half a day recently trying to debug a failing sort. After much gnashing of teeth I finally discovered that $a and $b had been declared and used at an earlier stage in the routine. I changed $a and $b to meaningful names and the later sort ran fine.

My advice: Just say no to "my ($a, $b);" It will work fine in the immediate context but some time in the future you or someone else may decide to sort something at a later point in the same scope -- and there will be much needless weeping and wailing until you discover the problem.

  • Comment on Re: Re: Re: variables allowed inside iterative loops in regular expressions?

Log In?
Username:
Password:

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

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

    No recent polls found