# WARNING: This is a very basic question - Maybe only the beginners should answer it?
Spoiler Warning! Stop reading here, if you want to solve it yourself...
#! perl use strict; use warnings;
my ($first, $last, $out) = '';
I suspect you meant to initialize more than just the first one here:
my($first, $last, $out) = ('', '', '');
I also suspect this will silence the error.
while (<>) { if (/^-----BEGIN/ .. /^-----END/) { if (/^-----BEGIN/) { $first=$_; next; } if (/^-----END/) { $last=$_; next; } $out.=$_;
I know it's a style gripe, but I prefer:
if (/^-----BEGIN/) { $first=$_; next; } elsif (/^-----END/) { $last=$_; next; }
$out = $_;
} } $out =~ s/\s//g; $out =~ s/(.{128})/$1\n/g; print "$first$out\n$last\n";
__END__
QUESTION: Why do I get -
Use of uninitialized value in concatenation (.) or string at sx.perl line 18, <> line 1680
I'm guessing you never find the end tag, thus leaving $last uninitialized.
Hope that helps.
James
When executing this code with a 1,680 line input file? BTW - There is in fact data on line 1,680 ...
-Sx-
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>