Beefy Boxes and Bandwidth Generously Provided by pair Networks Joe
"be consistent"
 
PerlMonks  

Re: Re: weird perl verion and/or OS problem with newlines

by vinforget (Beadle)
on Sep 25, 2003 at 11:20 UTC ( [id://294172]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Re: weird perl verion and/or OS problem with newlines
in thread weird perl verion and/or OS problem with newlines

Thanks for the quick response. I think a little more explanation is in order on my part. I have a file with multiple concatenated sections that begin with #:lav and end with #:eof and I want to process each of these one at a time e.g.
--start of file-- #:lav some text #:eof #:lav some text #:eof #:lav some text #:eof --end of file--
This is why I used the while loop with the concatenated string... so I can do some processing of the subsections that I find that satisfy the above criteria. Writing a while loop to process the code line by line would be more efficient in memory, but more time in development. Vince

Replies are listed 'Best First'.
Re^3: weird perl verion and/or OS problem with newlines (tye)
by tye (Sage) on Sep 25, 2003 at 12:02 UTC

    <IN>; # skip "--start of file--" while( <IN> ) { if( $_ eq "#:lav\n" ) { local $/= "#:eof\n"; my $block= <IN>; # ... process $block here ... } elsif( $_ eq /^--end of file--/ ) { warn "Unexpected line: $_"; } }

    Updated: Thanks to graff for noting that I wrote $\ when I meant $/.

                    - tye

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://294172]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.