Search code examples
perlfilepermissionscentosslurp

'No such file or directory' even though I own the file and it has read permissions for everyone


I have a perl script on CentOS and am trying to read a file using File::Slurp:

my $local_filelist = '~/filelist.log';
use File::Slurp;
my @files = read_file($local_filelist);

But I get the following error:

Carp::croak('read_file \'~/filelist.log\' - sysopen: No such file or directory') called at /usr/local/share/perl5/File/Slurp.pm line 802

This is despite the fact that I am running the script as myuser and:

(2013-07-26 06:55:16 [myuser@mybox ~]$ ls -l ~/filelist.log
-rw-r--r--. 1 myuser myuser 63629044 Jul 24 22:18 /home/myuser/filelist.log

This is on perl 5.10.1 x86_64 on CentOS 6.4.

What could be causing this?


Solution

  • Just use the glob function. That's what it is for.

    my $local_filelist = glob '~/filelist.log';