Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

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.


Comment on Re: Perl oddities
Select or Download Code
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 ...

        Don't consider - use it. It will make your life a whole lot simpler. I know it has mine :-)
      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.

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.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (13)
As of 2014-09-01 13:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (13 votes), past polls