Your code doesn't seem to cope with consecutive lines starting with a semi-colon and it gets a bit noisy running with use warnings; against an empty file. The following seems to work.
use strict;
use warnings;
my $acc;
while ( <> )
{
chomp;
if ( m{^;} )
{
$acc .= substr $_, 1;
}
else
{
print $acc, qq{\n} if defined $acc;
$acc = $_;
}
}
print $acc, qq{\n} if defined $acc;
I hope this is of interest. Cheers, JohnGG
Update: added defined to test to cope with lines that are empty. My test file is
;ddadadwaew
sddjdsoeugfuiegf
euefuefuerfefg
;erreuruyegfegr
ueyrueuefeyr7e
;
;
erieihir
eiereyrgueyrgh
;ieruherueu
;ierhueryugr
reieruyeruy
|