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

Re: Re: Is your module clobbering predefined variables?

by IlyaM (Parson)
on Apr 14, 2003 at 12:16 UTC ( #250264=note: print w/replies, xml ) Need Help??

in reply to Re: Is your module clobbering predefined variables?
in thread Is your module clobbering predefined variables?

I was burned by this construct once: while(<>) { ... } considered harmful.

Ilya Martynov,
Quality Perl Programming and Unix Support UK managed @ offshore prices -
Personal website -

  • Comment on Re: Re: Is your module clobbering predefined variables?

Replies are listed 'Best First'.
Re: Re: Re: Is your module clobbering predefined variables?
by zby (Vicar) on Apr 14, 2003 at 12:51 UTC
    Shouldn't it be in the language - that the $_ variable is by default localized to module? It's hardly usefull to maintain the topic across multiple modules. Anybody knows how it is to be in Perl 6?
      No, that would be very, very bad. That would disable you to write functions "the Perl" way, that is, when given no arguments, they act on $_.

      Besides, from the language aspect, there is no such thing as a "module scope".


        I did not say that it should be mandatorily localized. What I meant was to localize it by default, and when the author wants there should be a language construct to override that behaviour.
      It's discussed in Apocalypse 6, though lore had it that $_ would indeed be lexically scoped to each sub.

      Furthermore, a method will see $_ as "this" upon entry, so it will almost never work the old way (sorry, Abigail-II).

      Page 9 shows "Your caller's current topic is named $CALLER::_." and goes on to illustrate how to use it as a default parameter, so if you call it without an argument the function uses the caller's $_. But the function can call it by whatever formal name it likes for that parameter.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://250264]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (9)
As of 2018-06-23 16:08 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (125 votes). Check out past polls.