state-o-dis-array has asked for the wisdom of the Perl Monks concerning the following question:
I'm looking for something more efficient, though. I have to test about 20-40 cases against 30-40 possible matches, and do this about 400 times, in a somewhat time sensitive environment, so effiency is key.my @array = (A0-7:123:C, B8-15:456:D); my $check = A4:123:C; foreach my $line(@array){ my $subline = join(":", (split(":", $line))[1,2]); #not sure is that join/split thing works just consider this whateve +r it takes to get the 123:C into $subline my $subcheck = #again whatever it takes to get 123:C if ($subcheck =~ /$subline/){ $match = &checkRange($check, $line); } }
This way I still have my $check value, and a possible match in @found, and I can send these to a sub to check if the A4 part is in the range of the A0-7 part of the matching value. Thanks to those who were part of my problem solving process.my @array = (A0-7:123:C, B8-15:456:D); my $check = A4:123:C; my $test = join(' ', @array); my $find = join(':', ((split(':',$check))[1,2])); my @found = ($test =~ m/\b\w\d+\-\d+:$find\b/g);
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: matching numeric range
by jimbojones (Friar) on Feb 24, 2005 at 22:44 UTC | |
by state-o-dis-array (Hermit) on Feb 24, 2005 at 23:18 UTC | |
by jimbojones (Friar) on Feb 24, 2005 at 23:36 UTC | |
|
Re: matching numeric range
by esskar (Deacon) on Feb 24, 2005 at 22:21 UTC | |
by state-o-dis-array (Hermit) on Feb 24, 2005 at 22:42 UTC | |
|
Re: matching numeric range
by Roy Johnson (Monsignor) on Feb 24, 2005 at 22:19 UTC | |
|
Re: matching numeric range
by sh1tn (Priest) on Feb 24, 2005 at 22:43 UTC |