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

Christopher Nielsen christopher.nielsen at gmail.com
Sat Feb 18 23:14:35 PST 2006


> I am having a miserable time trying to figure out how perl sometimes
> can and can't read a string with a non-POSIX (?) compliant file path.

That is a bummer :(

> The trouble arises when a mac user (maybe others) tries to point the
> script to watch "current directory" [...] because mac's terminal program
> escapes the blank

I really like that feature; it's great for working with the shell,
where it escapes the characters that have special meaning.

The thing is, unlike the shell in Terminal, those characters in Perl,
like <space>, don't need escaping.  So those back-slashes (\) that
make changing the dir easy in shell, confuse Perl and chdir.

You could get the path entered into the Perl script somehow without
the *escaping*, or maybe strip out the escapes, after they're entered.

# This could strip out the escapes (back-slashes)
# Terminal.app/Finder puts in, so chdir works for you
$input =~ s#\##;

> Now, I'm also working on something similar with regards to moving
> paths based on user input. [...]

I think the same things is happening with this program, too. 
Although, I don't see where $bus and $mar are coming from, in the Perl
that was pasted in the email, to be sure.

I attached another version of this program.  I added a line to get rid
of any trailing newlines from user input that could help (this happens
when users press enter to continue).

I hope this puts you on the right track,

Chris

--
christopher.nielsen at gmail.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: read_line_of_file.pl
Type: text/x-perl-script
Size: 881 bytes
Desc: not available
Url : http://mail.pm.org/pipermail/losangeles-pm/attachments/20060219/da7a44c5/read_line_of_file.bin


More information about the Losangeles-pm mailing list