in reply to Re: run away ?
in thread run away ?

If your going to change $/ use local $/ = "new value";.

Why?

I ask because this is one of those cases I struggle with. Sometimes I use local $INPUT_RECORD_SEPARATOR = "some string"; in Perl scripts (not modules), sometimes I don't. I feel like I should localize the variable, but doing so also seems inert. Why should I care about the scope that doesn't exist outside the universe of my standalone Perl script? Isn't local just needless noise here?

I should add that I usually set this built-in variable outside any blocks within my scripts unless I have a specific reason to do otherwise (and I usually don't).

Replies are listed 'Best First'.
Re^3: run away ?
by GrandFather (Saint) on Nov 07, 2010 at 22:49 UTC

    Because it's a useful default behaviour that doesn't cost a lot and doesn't add much noise when it's not required, but can save a huge amount of pain when it is required. Think of it as a good habit like using strictures, three parameter open and all those other good habits that just naturally flow off the ends of your fingers or are part of your standard boilerplate.

    True laziness is hard work

      I accept that. I do a lot of things in my Perl scripts based on the rationale you described, many of which I learned from Perl Best Practices.

      local: You're in!

Re^3: run away ?
by kcott (Archbishop) on Nov 08, 2010 at 04:56 UTC