develooper Front page | perl.perl5.porters | Postings from July 2008

Re: Creative and *routine* use of so-called "magic" ARGV (was[perl #2783] Security of ARGV using 2-argument open)

Thread Previous | Thread Next
From:
Abigail
Date:
July 29, 2008 07:32
Subject:
Re: Creative and *routine* use of so-called "magic" ARGV (was[perl #2783] Security of ARGV using 2-argument open)
Message ID:
20080729143221.GA18775@almanda
On Tue, Jul 29, 2008 at 09:20:28AM -0500, David Nicol wrote:
> On Tue, Jul 29, 2008 at 8:22 AM, Mark Mielke <mark@mark.mielke.cc> wrote:
> > Specifically, \Q...\E will prefix certain characters with '\', and this will
> > make it impossible to represent file names with the same special characters
> > (the theoretical filenames with '|', '<' or '>') but that are not escaped in
> > the file name.
> 
> phooey.
> 
> Prefixing < takes care of opening and reading files with pipes and so
> on in them, but leading/trailing space seems impossible to represent
> with a 2-arg open.


It has been documented for a long, long time how to solve this:

    my $file = " hello ";
    open my $fh, "< ./$file\0";


Granted, "\0" is a bit of an oddity, but it is possibly. And you don't
need sysopen.

I think the current documentation is in perlopentut.


Abigail

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About