Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Re: Perl oddities

by Joost (Canon)
on Mar 01, 2005 at 11:03 UTC ( #435357=note: print w/replies, xml ) Need Help??

in reply to Perl oddities

I think the filehandle functions are generally messy: Bareword file handles, indirect object syntax for print() and close(), open() modifies it's $fh argument, and my least favorite "feature": defaulting to ignoring errors, which just means you end up having to type open FH,"<","file" or die "Can't open file: $!"; every time you use open, print and close.

I would prefer something like this:

my $fh = open "<","filename"; $fh->print "stuff"; $fh->close;

Which would also make it easier to replace a filehandle with some other object.

Replies are listed 'Best First'.
Re^2: Perl oddities
by TimToady (Parson) on Mar 01, 2005 at 18:27 UTC
    Change your arrows to dots and that's almost exactly how it looks in Perl 6.
Re^2: Perl oddities
by Corion (Pope) on Mar 01, 2005 at 11:35 UTC

    See Fatal, which does exactly that, override open (or whatever else you want) to die if it fails. The scheme falls down for system, as system returns a false value on success ...

      Fatal will be a built-in pragma in Perl 6, and any code which uses the fail keyword will fail in the way specified by the caller, which might be to throw a fatal exception, or to return an unthrown exception that is behaves like undef, or to cause some form of backtracking, in the case of the pattern matching engine.

      I'll talk about system elsewhere.

        Don't consider - use it. It will make your life a whole lot simpler. I know it has mine :-)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://435357]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2020-09-24 08:23 GMT
Find Nodes?
    Voting Booth?
    If at first I donít succeed, I Ö

    Results (132 votes). Check out past polls.