Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

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

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


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 16: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
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2024-05-20 00:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found