"Alan C." wrote:
> 
> Hello,

Hello,

> It's now a previously formatted text block with line breaks at every 70
> characters width.
> 
> And the block's first line begins with a leading period or dot as well
> as approximately every third line thereafter begins with a leading
> period or dot.
> 
> How do I rid the block of line breaks on every line except for the lines
> that begin with the leading period or dot?
> 
> I want to end up with a fewer number of lines whereby each of them is
> both longer and is preceded by the period or dot (sample output below).
> --
> 
> #!/perl/bin/perl -w
> undef $/;    # Enter "file slurp" mode.
> $text = <>;  # This file/selection slurped into the scalar
> for ($text =~ s/\n\.//g) {
> print $text;
> }
> 
> I tried the above removes each \nPERIOD combo, not quite yet what I want.
> 
> I'm aware that split is an array but I don't yet know how to use split.
>   And I'm not sure if split is what is needed.
> 
> How to, using regex, split, or otherwise?

Here is one way to do it:

#!/perl/bin/perl -w
use strict;

my $text = do { local $/; <> };
$text =~ s/\n(?!\.|\z)/ /g;
print $text;

__END__



John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to