in reply to Re^2: script running on linux but not windows -- File::Spec
in thread script running on linux but not windows

As debugging 101, I ran the first part of your code (below). Making a simple example for us is good, but in the future please make it a "runnable as is" example.

An obvious problem is that colon ":" is not valid in a Windows file name. Also regardless of that issue, the complete path does look a bit suspicious to me - that path does not exist on the Windows machine I'm writing this post upon using to write this post.

#!/usr/bin/perl use strict; use warnings; use POSIX qw(strftime); my $creationTime = strftime "%F-%R:%S", localtime; my $sqlLog = "C:/Users/thclotworthy/squirrel/logs/squirrel-sql-" . $cr +eationTime . ".log"; my $scriptLog = "C:/Users/thclotworthy/squirrel/logs/squirrel-" . $cre +ationTime . ".log"; print "$sqlLog\n$scriptLog\n"; __END__ prints: C:/Users/thclotworthy/squirrel/logs/squirrel-sql--:23.log C:/Users/thclotworthy/squirrel/logs/squirrel--:23.log
As an extra updated note: I use Windows as my development platform and often move programs to a Unix environment. I try to only use file names that are compatible with both Windows and Unix. For example Windows allows a "space" in the name but Unix does not.(see post by choroba - my recollection of this is was evidently wrong). So I use underscore "_" instead of that (where possible). Of course there are situations on Windows where a space is need, e.g. "My Documents". Always use "/" instead of "\" for path names. That even works from the Windows command line (which BTW is NOT DOS). There are some weird situations where the backslash is needed, but I encounter this so rarely that I can't think of such an example right now. Perl is amazingly good at being multi-platform.

Replies are listed 'Best First'.
Re^4: script running on linux but not windows -- File::Spec
by choroba (Cardinal) on Dec 21, 2017 at 15:57 UTC
    > For example Windows allows a "space" in the name but Unix does not

    That's not precisely true.

    perl -wle 'open my $fh, ">", "a b" or die $!; opendir my $dh, "." or d +ie $!; print for grep / /, readdir $dh' a b

    As you can see, the outer quotes are single, so I'm not on MSWin.

    ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,