http://www.perlmonks.org?node_id=871818


in reply to filehandle regex

I am using $` but it does not display any output.

There's nothing before /^/ in the matched variable, so there's nothing in $`.

The solution is to stop overwriting the value you want.

my $prev; while (<>) { print($prev) if /^Func_file_permission$/; $prev = $_; }