in reply to Re^2: Win32 File Creation Weirdness, ActivePerl 5.8.8
in thread Win32 File Creation Weirdness, ActivePerl 5.8.8
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):
Enjoy!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
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: Win32 File Creation Weirdness, ActivePerl 5.8.8
by missingthepoint (Friar) on Jul 07, 2009 at 22:23 UTC | |
by AnomalousMonk (Archbishop) on Jul 07, 2009 at 22:47 UTC |