In article <[EMAIL PROTECTED]>,
 [EMAIL PROTECTED] (Peter N Lewis) wrote:

> At 7:23 PM -0700 13/9/03, Rich Morin wrote:
> >This is interesting, but it doesn't answer the question of how one
> >opens a file with this sort of name weirdness.  Basically, I think
> >I've found a bug.  Prolly should check for it in Panther...
> 
> There is no problem with opening a file with a CR in its name.
> 
> The problem is only with a file who ends in any sequence of carriage 
> returns or line feeds.  It would appear these are stripped from the 
> file name by perl (presumably trying to be helpful so you can open a 
> file even if the name is read from a file and you forget to chomp it).

Yes, open() is "magic" and will open files similarly to if you passed it the 
name in the shell.  The solution is to use sysopen(), or to add a null to 
the end of the filename.

  $ cat > Icon^M 
  foo 
  ^C
  $ perl -e 'open $fh, "Icon\r" or die $!; print scalar <$fh>'
  No such file or directory at -e line 1.
  # add null
  $ perl -e 'open $fh, "Icon\r\0" or die $!; print scalar <$fh>'
  foo
  # use sysopen
  $ perl -e 'sysopen $fh, "Icon\r", 0 or die $!; print scalar <$fh>'
  foo
  $ 

-- 
Chris Nandor                      [EMAIL PROTECTED]    http://pudge.net/
Open Source Development Network    [EMAIL PROTECTED]     http://osdn.com/

Reply via email to