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

Re: [MacPerl] Error opening file w/trailing spaces in name



<x-flowed>At 07:40 -0700 1/28/99, Ero Brown wrote:
> I get an error when performing the following operation on
> a file that has trailing spaces in its name:
>
>  open(THEFILE, "<$theFileName")
>
> e.g., $theFileName = "Problem File   ";
>
> What am I doing wrong?

You're trying to open a file with trailing whitespace in its name :-)

>From the documentation for open():

"After the filehandle is determined, the filename string is 
processed. First, any leading or trailing whitespace is removed from 
the string. Then..."

On p. 194 (Programming Perl) is an example to protect leading and 
trailing whitespace "in order to open a file with arbitrary weird 
characters in it".

  $file =~ s#^(\s)#./$1#;
  open (FOO, "<$file\0");

They say "but we've never actually seen anyone use that in a script". 
So if you use it, you can mail it to booktech@orielly.com :-)

- Vicki
---
      |\      _,,,---,,_       Vicki Brown <vlb@cfcl.com>
ZZZzz /,`.-'`'    -.  ;-;;,_   Journeyman Sourceror: Scripts & Philtres
     |,4-  ) )-,_. ,\ (  `'-'  P.O. Box 1269  San Bruno  CA  94066
    '---''(_/--'  `-'\_)       http://www.cfcl.com/~vlb  www.ptf.com/macperl

***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch


</x-flowed>