Ed Mills wrote:
> The fact that something can be accomplished in Perl doesn't necessarily mean 
> its the best or most desirable way to do it. I respect the programming 
> abilities, but
> 
>    grep { ref($a) eq ref($b) } @b)
> 
> is far less intuitive than the proposal. 

...and is an example of why it may be desirable to have basic functions
like this built in: something so simple, people should be able to write
it in their sleep, but they still get it wrong.  It should have been

     grep { ref($a) eq ref($_) } @b)
                           ^^

Not to mention the fact that if $a is not a ref, the result contains
all the items of @b for which ref($_) is also ''.

        % cat foo.pl
        my @b = ( 1, 0, [], {} );
        my $a = 'foo';

        my @c = grep { ref($a) eq ref($_) } @b;
        print scalar(@c), " items: (@c)\n";

        % perl -w foo.pl
        2 items: (1 0)

Of course, this stuff could be in a (core) module, rather than
in the CORE.

-- 
John Porter

        We're building the house of the future together.

Reply via email to