in reply to Re^2: Regex and array
in thread Regex and array

Am I missing something?
Yes, you are ignoring important warnings because you did not use strict and warnings.

One way to search an array for a specific value is to use grep. I think you are looking for something like this:

use strict; use warnings; my @array = qw( ciccio paperino palla gigio pluto ); my $test = 'pluto'; if (grep { $test eq $_ } @array ) { print "It matched!\n"; }

Replies are listed 'Best First'.
Re^4: Regex and array
by Deus Ex (Scribe) on May 25, 2010 at 13:07 UTC

    Thanks toolic.

    As I've been explaining to Corion, I use to use the "strict" pragma in my scripts. The code I posted before, just was a shortened example to focus more on the problem i was experiencing.

    Thanks to your suggestion, with grep() applied to the array, I've been able to make the code work! Thank you very much for your help!