in reply to Aliasing a builtin?

sub len { length; } my @array = qw( fu bar baaaaz ); foreach ( @array ) { print len; }

If that's all you want, there you go. Beware of a couple of things though. First, you'll need to make sure that Perl knows what len means -- either declare the sub before, as I have done, or use a forward declaration. Second, some built-ins have special prototypes. You can use prototype to discover them. There are a couple of gotchas I always have to look up documented there.

Replies are listed 'Best First'.
Re: Re: Aliasing a builtin?
by TimToady (Parson) on Mar 11, 2003 at 17:09 UTC
    Also, this will break in Perl 6, where $_ is lexically scoped rather than global. (There are other ways to get the same effect in Perl 6, but I don't know if the translator will recognize what you have there as something that needs translating.)