I have the following:
#! /usr/bin/perl
use Fcntl ':flock';
use strict;
...
my (@list, $fh);
open $fh, "<:encoding(utf8)", $file or die "$file: $!";
flock $fh, LOCK_EX;
use sigtrap 'handler' => sub {flock($fh, LOCK_UN);}, 'normal-signals'; # line 72
It runs but gives an error when I press ^C:
$ verify.pl
...
Can't use an undefined value as a symbol reference at ./verify.pl line 72.
The docs says it's OK
$ perldoc sigtrap
...
use sigtrap 'handler' => \&my_handler, 'normal-signals';
I can't figure out what's wrong.