On Mon, May 27, 2002 at 09:04:13PM +0100, Alan Fry wrote:
> At 12:19 pm -0400 27/05/02, Chris Nandor wrote:
> > This works fine, with embedded spaces:
> >
> > my $f = "Bourque:Desktop Folder:file.txt";
> > open F, $f or die $!;
> > print scalar readline F;
> >
> >This does not:
> >
> > my $f = "Bourque:Desktop Folder:file.txt ";
> > open F, $f or die $!;
> > print scalar readline F;
>
> For the life of me, and please believe I am not being picky, I can't
> see the difference between the two. What am I missing?
One of the filenames has a space at the end.
> >The third is to specify your open sign ('>', '<', etc.) and add a
> >trailing null:
> >
> > my $f = "Bourque:Desktop Folder:file.txt ";
> > open F, '<' . $f . "\0" or die $!;
> > print scalar readline F;
> >
> >The greater danger with C< open F, $f > is that the filename might begin
> >with a ">" or somesuch. Both three-arg open, and the method above with
> >"\0", solve both problems; but the latter method works in any version of
> >perl. I am not a big fan of three-arg open, but I have to admit it looks a
> >lot nicer. :-)
Note that this solution does not work with leading spaces, however. You
have to use sysopen or the new three-arg open to handle those.
Ronald