Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^2: error printing all text in text file

by davido (Cardinal)
on Jan 11, 2022 at 16:14 UTC ( [id://11140376]=note: print w/replies, xml ) Need Help??


in reply to Re: error printing all text in text file
in thread error printing all text in text file

It's likely that snippet should be:

while(chomp(my $line = <$fh>)) { $show .= "$line\n"; }

And that is pretty much functionally equivalent to:

{ local $/ = undef; $show = <$fh>; }

...except that his code would append a newline at the end of the file if one wasn't there already. So $show =~ s/(?<!\n)\z/\n/ if that trailing newline is important. If he intended to keep the lines separated then he could slurp into an array.


Dave

Replies are listed 'Best First'.
Re^3: error printing all text in text file
by bigup401 (Pilgrim) on Jan 12, 2022 at 11:40 UTC

    i appreciate thanks

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2025-12-12 19:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your view on AI coding assistants?





    Results (92 votes). Check out past polls.

    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.