in reply to Re: Win32 File Creation Weirdness, ActivePerl 5.8.8
in thread Win32 File Creation Weirdness, ActivePerl 5.8.8

jwkrahn, I fixed the bug like so after taking a break - I'm rather sleep deprived :|

my ($id) = /(\d+)$/; unless (defined $id) { ($id) = /^(\d+)/ }

Windows never ceases to astonish me. Thanks all for your help :)


The zeroeth step in writing a module is to make sure that there isn't already a decent one in CPAN. (-- Pod::Simple::Subclassing)

Replies are listed 'Best First'.
Re^3: Win32 File Creation Weirdness, ActivePerl 5.8.8
by AnomalousMonk (Archbishop) on Jul 07, 2009 at 16:44 UTC
    Windows never ceases to astonish me.
    You think that's astonishing? Brace yourself.

    The Windows CLI wants redirection operator characters (e.g.,  > < |) in a double-quoted string to be escaped with a  ^ (hat) character if they are preceded by an odd number of backslash-escaped double-quote characters in the string! (Don't even ask what happens if the backslash escapes are themselves backslash-escaped.)

    Consider (this just illustrates redirection-character escaping; the scalar/list context problem with the regex is not addressed):

    C:\@Work\Perl\junque>dir Volume in drive C has no label. Volume Serial Number is EC11-ED1D Directory of C:\@Work\Perl\junque 07/07/2009 11:42 AM <DIR> . 07/07/2009 11:42 AM <DIR> .. 07/07/2009 11:41 AM <DIR> 16 07/07/2009 11:41 AM <DIR> 17 foo bar 07/07/2009 11:42 AM <DIR> 18- baz quux 0 File(s) 0 bytes 5 Dir(s) 10,227,699,712 bytes free C:\@Work\Perl\junque>perl -e "for (<*>) { my ($id) = /(\d+)$/ || /^(\d+)/; print qq{$_ => \"id=^>$id\" => x \n}; } " 16 => "id=>1" => x 17 foo bar => "id=>17" => x 18- baz quux => "id=>18" => x C:\@Work\Perl\junque>perl -e "for (<*>) { my ($id) = /(\d+)$/ || /^(\d+)/; print qq{$_ => \"id=>$id\" => x \n}; } " The system cannot find the path specified. C:\@Work\Perl\junque>perl -e "print qq{ (\") \n}; for (^<*^>) { my ($id) = /(\d+)$/ ^|^| /^^(\d+)/; print qq{$_ =^> \"id=>$id\" =^> x \n}; } " (") 16 => "id=>1" => x 17 foo bar => "id=>17" => x 18- baz quux => "id=>18" => x x => "id=>" => x
    Enjoy!

      I am speechless. Needing those chars escaped if preceded by an odd number of \"?? That requirement's straight out of Monty Python!


      The zeroeth step in writing a module is to make sure that there isn't already a decent one in CPAN. (-- Pod::Simple::Subclassing)
        You said it, brother!

        Also – take a look at ikegami's user image: those tomes are Windows manuals. Bonk.