in reply to Re^2: Matching Regular expression at EOF
in thread Matching Regular expression at EOF

Then I assume the match doesn't span more than one line?
my @match; while (<>)) { my @caps = /pat/ or next; @match = @caps; } if (@match) { print("Captured @match\n"); } else { die("No match\n"); }
or
my $match; while (<>)) { $match = $_ if /pat/; } if (defined($match)) { print("Matched $match"); } else { die("No match\n"); }

All this guessing is leading to suboptimal solutions and wated work. If this is still not good, please provide more info about your problem.