http://qs321.pair.com?node_id=1077646


in reply to Re: Replace new line with white space
in thread Replace new line with white space

It's difficult to know what the OP needs, even after the OP said, "...I read text from file into string...", since the following reads text from a file into a string, but chomp--in this case--will not remove newlines from $record:

use strict; use warnings; local $/ = \1024; open my $fh, '<', 'records.txt' or die $!; while ( my $record = <$fh> ) { # process 1024-byte, fixed-length, newline-containing record } close $fh;