in reply to file check not working

Is $path relative or absolute? If relative, maybe you are running your code from the wrong directory. Show us some output.

Replies are listed 'Best First'.
Re^2: file check not working
by jose_m (Acolyte) on Oct 07, 2014 at 13:09 UTC

    thanks. $path is declared. and the filename is a combination of variables.

    my $path = "/home/jose_m/"; my $extension = `date +%Y%m%d.csv`; my $file1 = ("longname_of_file.$extension");

      Are you using warnings or run your script using -w?

      If so, Perl already tells you what goes wrong:

      > perl -wle 'my $f=`date +%Y%m%d.csv`; open my $fh, "<", $f' Unsuccessful open on filename containing newline at -e line 1.

      Personally, I would avoid calling a shell just to run date. Use POSIX::strftime instead:

      use POSIX 'strftime'; my $extension= strftime( '%Y%m%d.csv', localtime ); ...

        so. i didnt see the harm or the gain in this. but you have a point on keeping it conventional and not going to the shell for something simple like date. i implemented your recommendation and the file check is working. must be something with how the file name is built using shell and using posix. ill try to see what the difference is later on but now i want to deliver this thing. thanks!! -Jose.