[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] problem specifying path



On Tue, 15 Feb 2000, Paul Schinder wrote:

> The simplest thing to do is to get used to using sysopen() all the 
> time, which doesn't do any of the whitespace ignoring that open() is 
> documented to do.  Read the documentation for open() to see what's 
> happening, but ignore the part where it tells you to put ./ in front 
> of the file name, because that won't work.  The next simplest thing 
> is to bite the bullet, rename your drive, and fix your AppleScripts.
> 
  The Perl Cookbook suggests:

===========
Use open like this:

  $filename =~ s#^(\s)#./$1#;
  open(HANDLE, "< $filename\0") or die "cannot open $filename: $!\n";

Or simply use sysopen:

  sysopen(HANDLE, $filename, O_RDONLY) or die "cannot open $filename: $!\n";

==========

  Obviously the first method is very UNIX-centric.  Since whitespace can
never occur at the beginning of a fully-specified filename in UNIX, they
can assume that any filename with whitespace at the beginning is relative.
Since you can't make this assumption on a Mac, the first method won't
work.  I'm not sure if there is some sort of substitution that would work.

  In any case, sysopen is probably the simpler option.  *grin*

Andy

-- 
===========================================================================
Andy Berkvam          | The surface of the strange, forbidden planet was
                      | roughly textured and green, much like cottage
Email:                | cheese gets way after the date on the lid says it 
 aberkvam@coredcs.com | is alright to buy it.          - Scott Davis Jones
 aberkvam@voyager.net |-WWW Pages: <http://www.coredcs.com/~aberkvam/>
===========================================================================


# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org