Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Why or why not? - local undef $/

by TGI (Parson)
on May 22, 2001 at 20:41 UTC ( [id://82284]=perlquestion: print w/replies, xml ) Need Help??

TGI has asked for the wisdom of the Perl Monks concerning the following question:

Japhy wrote this node, in repsonse to a recent post. In it he says most emphatically to not use local undef $/;

So I trotted over to the Super Search and did some looking. I found lots of stuff that uses it, I've posted code that uses it, I've encouraged people to use it. I found no dire warnings.

Is there a some problem with local undef $/;? When do you slurp? Why or why not? What method do you use?


TGI says moo

Replies are listed 'Best First'.
Re (tilly) 1: Why or why not? - local undef $/
by tilly (Archbishop) on May 22, 2001 at 20:55 UTC
    Try it:
    print "Before: '$/'\n\n"; { local undef $/; } print "After: '$/'\n";
    I leave it to the people who mistakenly thought that japhy was just talking a stylistic issue to realize their mistake.

      Monks posting code and expecting all several hundred of us readers to run that code in order to learn from it is becoming a pet peeve of mine. The above code produces (when warnings are turned on):

      Before: ' ' Use of uninitialized value in concatenation (.) at localundef.pl line +6. After: ''
      So now you can understand the problem rather than just that there is some problem just by reading.

              - tye (but my friends call me "Tye")
        I will match you peeve for peeve.

        If people see something that they do not understand, they should be willing to write small sample programs like the above, just to see what happens. If that leaves them with questions about why it works as it does, then ask. But first do some experiments.

        Therefore I want to encourage people to read with a command prompt nearby, and I consider that encouragement to be worth having my comment go past some people who probably don't care enough about what I am talking about for it to stay in their memory.

(jeffa) Re: Why or why not? - local undef $/
by jeffa (Bishop) on May 22, 2001 at 20:47 UTC
    UPDATE: thanks to tilly for showing me something I never thought about: (/duck)
    local undef $/ == local (undef $/) == bad local $/ == good

    You can pick your friends, you can pick your nose, but you can't pick your friends' noses

    Seriously, what i mean by that is there is no reason to say { local undef $/ }, all you need is { local $/ }, although japhy may know something about Perl 6 that I don't . . .

    Jeff

    R-R-R--R-R-R--R-R-R--R-R-R--R-R-R--
    L-L--L-L--L-L--L-L--L-L--L-L--L-L--
    

      I always use the shorter version. Is there a difference, other than golf score?


      TGI says moo

Re: Why or why not? - local undef $/
by princepawn (Parson) on May 22, 2001 at 20:52 UTC
    Most special globals are being removed from Perl 6. You can read the recent article on Perl.com to verify this.

      Can you supply a reference to this article. I'm assuming you mean either of Larry's Apocalypses or Damian's Exegesis, but the nearest I can find is this from Apocalypse 2

      Various special punctuation variables are gone in Perl 6, including all the deprecated ones.

      And I find it a difficult leap from there to "Most special variables are being removed from Perl 6". Especially when Larry goes on to say:

      (Non-deprecated variables will be replaced by some kind of similar functionality that is likely to be invoked through some kind of method call on the appropriate object. If there is no appropriate object, then a named global variable might provide similar functionality.)
      --
      <http://www.dave.org.uk>

      "Perl makes the fun jobs fun
      and the boring jobs bearable" - me

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2024-04-19 02:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found