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 |