Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re: Re: Perl Programming guidlines/rules

by BUU (Prior)
on Nov 21, 2002 at 23:48 UTC ( #214958=note: print w/replies, xml ) Need Help??

in reply to Re: Perl Programming guidlines/rules
in thread Perl Programming guidelines/rules

I support using $_, but you should perhaps implement a standard/guideline in the form of 'Localize $_ in all user created subs', as something like the following:
sub foo{my $blah=shift; $_=substr $blah,0,1; /foo/;}
Which looks fairly innocuous in the use of $_ to avoid more temporary vars (It's not an extremely good example, but it serves), but then you do something likemap{foo($_->[0]);$_;} which can return wildly different results then you expected, and lead to many.. interesting.. bugs.

Replies are listed 'Best First'.
Re: Re: Re: Perl Programming guidlines/rules
by belden (Friar) on Nov 22, 2002 at 17:13 UTC
    Wow, that really localizes $_ ? To me, it looks more like a straight assignment to $_. I would've expected something like:

    sub foo { local $_ = shift; /foo/; }


      No, it doesn't localize, and I'm fairly certain that BUU was pointing out that failing to do so is dangerous.

      Makeshifts last the longest.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://214958]
[Eily]: LanX how does the first link work, should I send a message to rat? :D
[LanX]: yes, or click the second link
[LanX]: hmm there is an xml ticker for threads

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (8)
As of 2018-03-19 09:58 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (238 votes). Check out past polls.