in reply to Re^2: file check not working
in thread file check not working

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 ); ...

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

    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.

      Unsuccessful open on filename containing newline at -e line 1.
      filename containing newline

      Reading the error message is at least half the battle.

      "...must be something with how the file name is built..."

      Others pointed you to it already - but anyway, i put in my two cent:

      host:~ # perl -MPOSIX=strftime -e 'print strftime( "%Y%m%d.csv", local +time );' | hexdump -c 0000000 2 0 1 4 1 0 0 8 . c s v 000000c host:~ # perl -e 'print qx(date +%Y%m%d.csv);' | hexdump -c 0000000 2 0 1 4 1 0 0 8 . c s v \n 000000d

      Best regards, Karl

      «The Crux of the Biscuit is the Apostrophe»