Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- use strict;
- use warnings;
- use Scalar::Util qw(looks_like_number);
- #*************TEST VALUES*************
- print "Enter a type (0 - 4): ";
- my $usrInput = <STDIN>;
- chomp $usrInput;
- errorCheck($usrInput, "Type");
- print "Enter a geo code (1-48): ";
- $usrInput = <STDIN>;
- chomp $usrInput;
- errorCheck($usrInput, "GeoCode");
- print "Enter a valid violation code: ";
- $usrInput = <STDIN>;
- chomp $usrInput;
- errorCheck($usrInput, "VioCode");
- print "Enter a number from 1 - 14: ";
- $usrInput = <STDIN>;
- chomp $usrInput;
- errorCheck($usrInput, "StaCode");
- print "Enter a province: ";
- $usrInput = <STDIN>;
- chomp $usrInput;
- isProvince($usrInput);
- print "Enter a city: ";
- $usrInput = <STDIN>;
- chomp $usrInput;
- isCity($usrInput);
- sub errorCheck {
- while (0 == 0) {
- if (looks_like_number($_[0])) {
- if ($_[0] >= 0 && $_[0] <= 4 && $_[1] eq "Type"){ #Type
- return $_[0];
- }
- elsif ($_[0] == 1 && $_[1] eq "Choice1"){ #Correlation
- return $_[0];
- }
- elsif ($_[0] >= 1 && $_[0] <= 4 && $_[1] eq "Choice2"){ #String
- return $_[0];
- }
- elsif ($_[0] >= 1 && $_[0] <= 3 && $_[1] eq "Choice3"){ #Numerical
- return $_[0];
- }
- elsif ($_[0] >= 1 && $_[0] <= 2 && $_[1] eq "Choice4"){ #Percentage
- return $_[0];
- }
- elsif ($_[0] >= 1 && $_[0] <= 48 && $_[1] eq "GeoCode"){ #Geo Code
- return $_[0];
- }
- elsif ($_[0] >= 1 && $_[0] <= 255 && $_[0] != 25 && $_[0] != 72 && $_[0] != 73 && $_[0] != 217 && $_[0] != 218 && $_[1] eq "VioCode"){
- return $_[0]; #Violations
- }
- elsif ($_[0] >= 1 && $_[0] <= 14 && $_[1] eq "StaCode"){ #Statistics
- return $_[0];
- }
- }
- print "Invalid input, please reenter: ";
- $_[0] = <STDIN>;
- chomp $_[0];
- }
- }
- sub isProvince {
- while (0==0){
- if (looks_like_number($_[0])){
- if ($_[0] == 2 || $_[0] == 4 || $_[0] == 5 || $_[0] == 7 || $_[0] == 9 || $_[0] == 16 || $_[0] == 28 || $_[0] == 30 || $_[0] == 33 || $_[0] == 36 || $_[0] == 40 || $_[0] == 42){
- return $_[0];
- }
- }
- print "Invalid input, please reenter: ";
- $_[0] = <STDIN>;
- chomp $_[0];
- }
- }
- sub isCity {
- while (0==0){
- if (looks_like_number($_[0])){
- if ($_[0] >= 3 && $_[0] <= 48 && ($_[0] != 4 || $_[0] != 5 || $_[0] != 7 || $_[0] != 9 || $_[0] != 16 || $_[0] != 28 || $_[0] != 30 || $_[0] != 33 || $_[0] != 36 || $_[0] != 40 || $_[0] != 42)){
- return $_[0];
- }
- }
- print "Invalid input, please reenter: ";
- $_[0] = <STDIN>;
- chomp $_[0];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement