in reply to for mistake with shift
If any part of LIST is an array, foreach will get very confused if you add or remove elements within the loop body, for example with splice. So don't do that.
The shift within the for loop is doing just that.
Here is an alternate version of the sub that behaves the way I think you intend, which does not use the shift:
sub article_title1 { local $_ = shift(@text); # left in for side effect my $BlankSeen=0; for (@text){ $BlankSeen ? print "# TEXT-2 = '$_'\n" : print "# TEXT-1 = '$_'\n"; $BlankSeen = 1 if (/^$/); } }
|
|---|