in reply to Re^4: 'do' command is dead? Surely not?
in thread 'do' command is dead? Surely not?

You don't show us the output of the file existence tests. Maybe the filename has whitespace at its end. If -f 'whatever.pl' fails, then for sure, Perl cannot see that file, for whatever reason.

Also, the interesting variable is @INC, not %INC.

You can also check if do './whatever.pl' works for you. That would also work around the problem of . not being in @INC.

You can also check if do '/home/Andy/Desktop/whatever.pl' works for you. That would also work around the problem of . not being in @INC.

Replies are listed 'Best First'.
Re^6: 'do' command is dead? Surely not?
by ACI (Acolyte) on May 19, 2017 at 15:08 UTC

    AHHH!!! my $file='/home/andy/Desktop/test-response.pl'; works!!!! I'm assuming something happened in a recent update. Edit - './test-response.pl' works too. EDIT2 - use lib '.'; my $file='test-response.pl'; also works

    (but, given that my Perl portfolio contains thousands of these, is there a way of telling Perl never to require the absolute path, other than use lib '.'? I think I now understand the importance of '.' in @INC, but soooooo many scripts to edit!)

      See perlrun on how to modify @INC globally via $ENV{PERL5LIB}.

      Personally, I would modify the scripts on an as-needed basis.

Re^6: 'do' command is dead? Surely not?
by ACI (Acolyte) on May 19, 2017 at 15:03 UTC

    Thanks, Corion

    if (-e $file){ print "File exists\n"; } if (-f $file){ print "File is plain\n"; }

    produces both messages

    @INC contains

    /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.24.1 /usr/local/share/perl/5.24.1 /usr/lib/x86_64-linux-gnu/perl5/5.24 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.24 /usr/share/perl/5.24 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base