[LA.pm] perl/file path on mac x

Peter Benjamin pete at peterbenjamin.com
Sun Feb 19 14:39:05 PST 2006


At 10:15 PM 2/18/2006, David Heayn wrote:
>My first guess is I have to do some escaping. But as I said before, 
>they are escaped when viewed in the debugger. Any insights would be 
>wonderful.

Here are my tricks for cross platform handling of pathnames with
strange characters.  Typically I find one method will work across
all platforms (perl is good), but it depends on what levels of
variable subsitution *I* have coded into my code.

Try removing the escaping, especially if you see it in the debugging
print statements, as then it likely means it is looking for a path
name on the hard drive that contains the backslash.

Try double escaping?  that is: \\\>   which changes to \>  and changes to >
if there are two rounds of variable subsitution.

Also, try using single quotes for hardcoded values,
and try it with and without the escaping.  You may
find single quotes give you more predictable perl
behavior.

For argument inputs try putting the value into double quotes in open

open ( HANDLE, "<$ARGV[0]" )

as

open HANDLE $ARGV[0]

will not get you far (I think).




More information about the Losangeles-pm mailing list