Variable interpolation happens only inside double quotes. Change this ... to ...
And perhaps even better, change to the three-argument form of open:
open my $fh, '<', $filename or die "Can't open '$filename': $!";
(no need to string-interpolate $filename in open call, quoting $filename in error message makes all whitespace explicit).
In reply to Re^2: open file and write the content into another file
by AnomalousMonk
in thread open file and write the content into another file
by cesapun
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |