Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

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]
[Corion]: Hmm - the longer I work, the more such sentences I collect:
[Corion]: "If I wanted to work with people, I would have become a coroner."
[Corion]: "If I wanted to work with hot air, I would have become a baloonist"
[Corion]: "If I wanted to work with flaps, I would have become a mailman"
[Corion]: (I'm not sure if the last one works in English too ;) )

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (7)
As of 2017-09-21 14:26 GMT
Find Nodes?
    Voting Booth?
    During the recent solar eclipse, I:

    Results (248 votes). Check out past polls.