Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Comment on


If you're worried about polluting other's namespaces, why don't you just override the function locally? I started with japhy's modification and produced this:

BEGIN { use subs 'length'; sub length(;$) { my $arg = @_ ? $_[0] : $_; defined($arg) ? CORE::length($arg) : undef; } }

You could even modularize this pretty easily:

package Func::Smarter; require Exporter; use vars qw'@ISA @EXPORT @EXPORT_OK'; use subs qw 'length' @ISA = 'Exporter'; @EXPORT_OK = qw'length'; sub length (;$) { my $arg = @_ ? $_[0] : $_; defined($arg) ? CORE::length($arg) : undef; } 1;

Then you could just use Func::Smarter 'length';, yes?

A collection of thoughts and links from the minds of geeks
The Code that can be seen is not the true Code

In reply to Re: This could have DWIM better by radiantmatrix
in thread This could have DWIM better by Aristotle

and:  <code> code here </code>

  • Please read these before you post! —
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others studying the Monastery: (11)
    As of 2014-12-27 16:33 GMT
    Find Nodes?
      Voting Booth?

      Is guessing a good strategy for surviving in the IT business?

      Results (177 votes), past polls