http://qs321.pair.com?node_id=568722

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I'm attempting to do the following, be receive the following error: "Use of uninitialized value in pattern match (m//)"
foreach my $line (<FILE>) { if ($line =~ /PatternBegin/ .. /PatternEnd/) { $str .= $line; } }

If i remove the variable declaration and work from $_ with the following code everything works fine.
foreach (<FILE>) { if (/PatternBegin/ .. /PatternEnd/) { $str .= $_; } }

How do I make it work with the first example of code?