Stories
Slash Boxes
Comments
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.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • I looked into doing something very much along those lines some time ago (during OSCON::EU 2006 in Brussels, I think).

    One of the problems is that callers which do use warnings will get lots of “Useless use of bitwise or (|) in void context” warnings. I considered whether this sort of thing would alleviate the problem:

    package Whatever::Name::It::Gets;

    use strict;
    use warnings;

    sub import {
        warnings->unimport(qw<void>);
    }

    It would, through the surprising scope of *^H, but there’s an obvious disadvantage: you don’t get any other void-context warnings.

    I was additionally trying to get <> , and >> to work as redirection operators. That turned out to be even trickier: things like

    Pipe('zcat') | [qw<tar x -O>] > $filename;

    won’t work because of operator precedence. Perl conveniently warns you about this: “Possible precedence problem on bitwise | operator”; whether that’s actually better than the alternative is debatable in this case.

    Finally, I believe it’s also impossible to use pipe as the convenience function name for these purposes:

    $ cat foo.pl
    use strict;
    use warnings;
    sub pipe { 1 }
    pipe('foo') | pipe('bar');
    $ perl foo.pl
    Ambiguous call resolved as CORE::pipe(), qualify as such or use & at foo.pl line 4.
    Ambiguous call resolved as CORE::pipe(), qualify as such or use & at foo.pl line 4.
    Not enough arguments for pipe at foo.pl line 4, near "'foo') "
    Not enough arguments for pipe at foo.pl line 4, near "'bar')"
    Execution of foo.pl aborted due to compilation errors.

    That’s by no means an insuperable objection, of course. For that matter, the other issues can all be worked around to produce a good interface, but it’s particularly annoying that what seems initially to be an ideal interface isn’t apparently implementable.

    • I wouldn’t particularly care about the redirection operators. I would rather let the desugared API handle the more complex cases than try to stuff them all into symbols.

      The warning is an annoyance, I agree.