Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Seeking an idiom for localizing $/

by perlcgi (Hermit)
on Apr 29, 2004 at 15:27 UTC ( #349159=perlquestion: print w/replies, xml ) Need Help??

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

I'm processing very large text files of delimited records, and localizing $/ to be my delimiter works great.
{local $/ = "DELIMITER"; while( <FILE> ){ do_this(); do_that(); do_the_other(); } }
However, I don't like having $/ altered for the scope of the entire while-loop 'cos that's pretty much my whole program and it could have consequences for the subroutines within the loop. I'm seeking a nice idiom to return it to its previous value, after it has done it's thing, for each iteration. Suggestions much appreciated.

Replies are listed 'Best First'.
•Re: Seeking an idiom for localizing $/
by merlyn (Sage) on Apr 29, 2004 at 15:29 UTC
      Thanks once again Randal.
      A grateful perlcgi makes mental note to purchase his own copy of Learning Perl Objects, References & Modules and wonders if this idiom is well know, or just an off-the-cuff creation of the wizard.
        wonders if this idiom is well know, or just an off-the-cuff creation of the wizard
        Just synthesized from smaller idioms. It's not that I'm necessarily a wizard: I just remember lots of little things that work, and put them together in interesting ways.

        -- Randal L. Schwartz, Perl hacker
        Be sure to read my standard disclaimer if this is a reply.

    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: Seeking an idiom for localizing $/
by ihb (Deacon) on Apr 30, 2004 at 00:25 UTC
    Just don't forget to localize $_ too.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://349159]
Approved by Tomte
Front-paged by Roy Johnson
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2022-12-03 19:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?