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
July 30, 2008 06:43
Re: Creative and *routine* use of so-called "magic" ARGV (was [perl #2783] Security of ARGV using 2-argument open)
Message ID:
Tom Christiansen wrote:
>What do we get today?  Bowdlerization!
>    How can I open a file with a leading ">" or trailing blanks?
>    Unless you have a particular reason to use the two argument form you
>    should use the three argument form of open() which does not treat any
>    characters in the filename as special.

I don't see Bowdlerisation here.  I see a better way to achieve the

>HELLO?  What happened to the right answer that was there before?

It was superseded by this simpler right answer, when the three-argument
form of open() became available.

>But what should I expect?  The perl faq is now a document that thinks 
>this is somehow clear and consistent code, and it's anything but:

I agree with your problems with this one, however.

>To this day, Perl's implicit closing of files doesn't warn you of errors,
>let alone exit nonzero.  This makes it do wrong thing and not even tell you
>it did them wrong.

I wholeheartedly agree with you in this gripe.  I often (but, admittedly,
not always) end up writing wrappers along the lines of

	sub IO::Handle::safe_print { shift->print(@_) or die $! }
	sub IO::Handle::safe_flush { shift->flush or die $! }

and I wish such dying versions of I/O functions were standardised and
the norm.  Proper use of the exception mechanism makes it a lot easier
to write correct programs.  Roll on autodie.


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About