if ($x>=2 && $line !~ /^Text/) { $string .= $line; print "In 'if, line ne text', string is:\n$string\n"; $x++; next; } if ($x!=0){ push (@texts, $string); # whether I use this line or the one after, the result is the same # $texts[$i] = $string; print "In if, using push, \@texts is:\n"; print Dumper(@texts), "\n"; $string = ''; $i++; $x = 0; goto TT; } #### In 'if, line ne text', string is: some text here\n some text here In if, using push, @texts is: $VAR1 = 'some text here.'; etc... $VAR10 = 'some text here.\\n some text here.';