# assuming text is in $_ my @lines = split /\n/; my $text = join '||', @lines; print "||$lines||\n";