Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • Fatal (Score:3, Interesting)

    by Juerd (1796) on 2003.08.12 3:21 (#23011) Homepage
    And in case anyone thinks "it's just a one-time hack" and "this is just a proof of concept" are valid excuses: no, they're not!

    If your code works, it will be used.

    Make sure that it provides enough information to fix the problem when it stops working.

    If you don't like checking return values (most of the time it's just a matter of adding "or die $!"), let something (or someone) do it for you.
    use Fatal qw(:void open close);
    open my $fh, $filename;
    close $fh;
  • Don't return undef (Score:3, Informative)

    by pdcawley (485) on 2003.08.12 6:36 (#23014) Homepage Journal
    Throw an exception. Any code I write for my own use is guaranteed to do one of three things:

    1. Return $self
    2. Return an 'interesting' value
    3. Throw an exception

    In general I'm slightly wary of object methods that return interesting values though, especially when those interesting values are simple attributes.