Microsoft
Software
Hardware
Network
Question : How to check if value in a list in Perl?
Hi,
I am trying to create a conditional statement "if" that will check if a value is in a list of values. Right now, I simply do this:
if ( $myvar == 'VAR0123' || $myvar == 'VAR1234' || $myvar == 'VAR2345' )
{
}
I would prefer to setup all my "values" in an array or hash at one place and then do something like:
if ( $myvar ISIN $mylist )
{
}
Can this be done easily in Perl? Maybe using a hash table? Any ideas?
Answer : How to check if value in a list in Perl?
generally, $mylist{$myvar} would be better for this kind of thing than grep or foreach or =~
$i == 'VAR0123'
will match anything that does not look like a number
Random Solutions
delete a record using VBA.
Keep Alias Name in Exchange on inbound emails
Bulk Insert with Text Qualifiers
Need to insert a value into a textbox (which is in an iFrame) from an HTML page
Need help understanding how to run a parameterized query
Why is uploading through CF so SLOW compared to an ISAPI DLL?
Symantec Ghost 14.0 - - Ghosting Problems
unable to validate or Register Win XP Prof. Oem anymore
PERL DBI MYSQL Import .sql into MySQL using PERL DBI
Failed to backup sql server 2000