Hi
I am trying to validate that the user only enters a (Yy/Nn)
this is what i have but it does not work.. it comes out of a bigger script but the validation is what im having a problem with
the problem comes in when i enter a correct value.. i want the ques_noagrs to loop if the user puts in any thing other than Y,y,n,N - this part works if not beautifully it still works..(TIPS here would be great..)
if i enter a y/Y "I must search thru the DIR" gets printed out and the program exits.. BUT!!! if i enter n/N nothing gets printed out and the program continues from after the response subroutine..
any help would be much appreciated..(Feel free to critisize the style or methods of programming as i would like to improve my overall coding skills)
Rgds
AcidHawk
----
Of All the things I've lost in my life it's my mind I miss the most.
I am trying to validate that the user only enters a (Yy/Nn)
this is what i have but it does not work.. it comes out of a bigger script but the validation is what im having a problem with
Code:
sub ques_noargs
{
print "Fetch Performance Data for ALL servers in cube Directory [Yy/Nn]?\n\n";
&check_args;
}
sub check_args
{
chomp($_=<STDIN>);
if ($_=~/[yn]/ig)
{
&response;
} else {
print "\nYou Have Entered and Incorrect Option\n";
print "Valid Options are [Yy/Nn]\n\n";
&ques_noargs;
}
}
sub response
{
if ($_=~/n/ig)
{
print "\nUsage: xPerfCollector <ServerName>\n";
exit;
}
if ($_=~/y/ig)
{
print "\nI must search thru the DIR\n";
exit;
}
}
the problem comes in when i enter a correct value.. i want the ques_noagrs to loop if the user puts in any thing other than Y,y,n,N - this part works if not beautifully it still works..(TIPS here would be great..)
if i enter a y/Y "I must search thru the DIR" gets printed out and the program exits.. BUT!!! if i enter n/N nothing gets printed out and the program continues from after the response subroutine..
any help would be much appreciated..(Feel free to critisize the style or methods of programming as i would like to improve my overall coding skills)
Rgds
AcidHawk
----
Of All the things I've lost in my life it's my mind I miss the most.