#!/usr/bin/perl -w use strict; print "Content-type: text/html\n\n"; my @locations = qw(LA LB LC LD LE); # this list could have more values +, thats my concern with the rest of the code. my $c_position; foreach my $location(@locations) { # Let me explain this value,$test_loc will have a different value for +each element of @locations, # I just added this way to show how it would work. my $test_loc = "Park: SW at 10 position"; #this could be for LA #my $test_loc = "Park: NE at 21 position"; #this could be for LB #my $test_loc = "Park: E at 11 position"; #this could be for LC #my $test_loc = "Park: NW at 17 position"; #this could be for LD #my $test_loc = "Park: NE at 06 position"; #this could be for LE ... my $locs = substr $test_loc, 6,2; # maybe using regular expression wou +ld be more efficient? $locs=~s/\s+//; if( ($location=~/LA/ig) && ( ($locs eq "NE") || ($locs eq "E") || ($locs eq "SE") || ($locs eq "S") || ($locs eq "SW") )) { $c_position=$c_position." 1LA= NE|E|SE|S|SW"; } elsif( ($location=~/LB/ig) && ( ($locs eq "NE") || ($locs eq "SW") || ($locs eq "W") || ($locs eq "NW") )) { $c_position=$c_position." 2LB= NE|SW|W|NW"; } elsif( ($location=~/LC/ig) && ( ($locs eq "SE") || ($locs eq "S") || ($locs eq "SW") )) { $c_position=$c_position." 3LC= SE|S|SW"; } elsif( ($location=~/LD/ig) && ( ($locs eq "SE") || ($locs eq "S") || ($locs eq "SW") )) { $c_position=$c_position." 4LD= SE|S|SW"; } else { $c_position=$c_position." 5ALL OTHERS HERE."; } } print "Results= $c_position\n\n"; exit;
In reply to Code Efficiency and Dynamic Help! by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |