in reply to Regex with variables
Yep, switch the variables in your match test.
But if your data are really like that then you should have them in a hash and check them there rather than stringifying and testing with a regexp.
#!/usr/bin/env perl use strict; use warnings; my %hash; for(qw/1689 9679 6978 2792 2514 5472 1520 9342 5544 1268 0165 1979 731 +4 2101 7221 +9539 3882 1812/) { $hash{$_}++; } my $tested = '2101'; if( exists $hash{$tested} ) { print "OK"; } else { print "Not there"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Regex with variables
by stevieb (Canon) on Jun 29, 2015 at 14:19 UTC | |
by 1nickt (Canon) on Jun 29, 2015 at 14:37 UTC | |
by stevieb (Canon) on Jun 29, 2015 at 15:21 UTC | |
|
Re^2: Regex with variables
by cormanaz (Deacon) on Jun 29, 2015 at 14:09 UTC |