in reply to How to copy an array to a hash?

Seems like a query similar to How [to] include a file in Perl script by OP, resulting quite possibly in the same responses.

Forgot to mention earlier ... There can be more reasons for failure to open a file other than a non-existing file: permission errors, running out of file descriptors, and possibly others (that I do not know about). Therefore, instead of ...

my $file = 'file-name'; if( open(HANDLE, $file) ) { ... } else { print "No such file or directory\n"; }

... should use $! (aka $OS_ERROR, $ERRNO) in printing of a message ...

if ( open my $handle, '<', $file ) { ... } else { print $!, "\n"; #warn "Cannot open file '$file' to read: $!"; }

... so that you can have as close to the real reason for open failure as possible.