Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: This could have DWIM better

by radiantmatrix (Parson)
on Mar 01, 2006 at 21:48 UTC ( #533766=note: print w/ replies, xml ) Need Help??


in reply to This could have DWIM better

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?

<-radiant.matrix->
A collection of thoughts and links from the minds of geeks
The Code that can be seen is not the true Code
I haven't found a problem yet that can't be solved by a well-placed trebuchet


Comment on Re: This could have DWIM better
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2014-08-23 21:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (178 votes), past polls