in reply to Re^2: Problems with grep
in thread Problems with grep

| \|/ scalars<-- /|\ |
perldoc -f grep is better :)

Replies are listed 'Best First'.
Re^4: Problems with grep
by citromatik (Curate) on Jan 30, 2009 at 15:11 UTC

    That is not correct, as I said before grep returns a list, and that list is not restricted to be a list of scalars as you are claiming:

    update: References are scalars, sorry for the confusion

    use strict; use warnings; use Data::Dumper; my @t = ( [1,2,3], 0, [4,5,6] ); my @k = grep { ref $_ eq "ARRAY" } @t; print Dumper \@k;
    Outputs:
    531(255)[1603][/home/pignatelli/tmp]$ perl kkk.pl $VAR1 = [ [ 1, 2, 3 ], [ 4, 5, 6 ] ];

    citromatik

      that list is not restricted to be a list of scalars

      Yes it is, as all lists are. You can't have a list of anything but scalars. In your example, grep returned two scalars, both of which are references.