Devel::Hints

rafael on 2003-01-30T14:01:36

Autrijus Tang has just uploaded Devel::Hints on CPAN. I was about to code this module myself, but Autrijus did a better job (and obviously he did it faster.) I was going to use Inline::C instead of XS, and I didn't thought about adding an optional call stack level parameter to the cop_* functions. (More on that topic in the next P5P summary.)


A neat hammer...

petdance on 2003-01-30T17:47:14

A neat hammer, but I don't see what the nails for it are. I'd love to see some examples that show how this can help the average programmer. Or is it a module that only an internals-lovin' programmer could love?

Re:A neat hammer...

autrijus on 2003-01-30T19:52:10

Here's the nail I wrote the hammer for, a CORE::GLOBAL::open() overrider that respects the 'use open' pragma in the caller's block:

sub open (*;@) {
        # ...
        my $ret = CORE::open($fh, $mode, $file) or return 0;
        # ...
        my $binmode = Devel::Hints::cop_io(1);
        $binmode = (split(/\x00/, $binmode))[($mode =~ />/) ? 1 : 0];
        binmode($fh, $binmode) if $binmode;
        $_[0] ||= $fh;
        $ret;
}