Rob Dixon wrote:
Your code works super for the job!my $last = undef;while (<>) { next unless defined $last; chomp $last unless /^\./; print $last; } continue { $last = $_; } print $last;
I had thought of chomp and unless. But I'm too new, didn't know how to implement them.
Just to take yours apart, my trying to understand it, I thought next would work.
while (<>) {
chomp unless m/^\./;
print "$_";
}
But I tried it. It does not work, and I don't know why.
perldoc -q continue turned up nothing.
I understand the regex part of your code--looks like that line of code means "chomp the line if it is a line that does not begin with a period"
The first iteration, $last is not defined therefore next will make it what (try on the next line of my text that's my guess)(therefore when $last is undef it doesn't chomp but instead trys/begins on the next line of my text????)
providing condition met, "next" makes it skip to the next iteration?
I don't understand the workings of 1. how it might potentially go from undef to defined 2. what the continue does or how it works
Is there a documentation to help me understand it or would you explain it?
Meanwhile I'll be continuing my studies/practice with "Learning Perl 3rd" and later I'll reference "Programming Perl 3rd" on continue and undef
--
Alan.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]