Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^2: problem in printing the result in the out put file

by johngg (Canon)
on Feb 28, 2017 at 19:12 UTC ( [id://1183187]=note: print w/replies, xml ) Need Help??


in reply to Re: problem in printing the result in the out put file
in thread problem in printing the result in the out put file

Another way to correct it is to use open with the :crlf IO layer (if that's the correct term):

johngg@shiraz:~/perl/Monks > perl -Mstrict -Mwarnings -E ' my $file = qq{Line 1\r\nLine 2\r\nLine 3\r\n}; open my $inFH, q{<:crlf}, \ $file or die $!; while ( <$inFH> ) { chomp; say qq{>$_<}; } close $inFH or die $!;' >Line 1< >Line 2< >Line 3<

I hope this is of interest.

Cheers,

JohnGG

Replies are listed 'Best First'.
Re^3: problem in printing the result in the out put file
by Eily (Monsignor) on Feb 28, 2017 at 19:46 UTC
    I hope this is of interest

    It sure is! I actually find this method better than modifying $/, it is easier to understand and you don't have to worry about contaminating the way other handles are read. I did read about it a while ago, but I had completely forgotten this is something you can do, thanks for the reminder.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2024-04-24 06:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found