in reply to Re^2: reiterateing over array
in thread reiterateing over array

And I did not understand this

use List::Util qw( first ); my $pro = first { $user[0] eq $_ } @protected; do_stuff_with( $pro ) if defined $pro;

Replies are listed 'Best First'.
Re^4: reiterateing over array
by blazar (Canon) on Aug 20, 2008 at 18:20 UTC

    I personally believe that you should explain exactly what you couldn't understand, given that you've been shown the relevant documentation:

    my $pro = first { $user[0] eq $_ } @protected;
    assigns to $pro the first value in @protected which is equal to $user[0], that is, $user[0] itself, if the latter is in @protected, or else an undefined value. Thus the following line chooses what to do depending on whether $pro is defined or not, which appears to be what you want, ain't it?
    --
    If you can't understand the incipit, then please check the IPB Campaign.