a.alandkar has asked for the wisdom of the Perl Monks concerning the following question:
Hello all mates, I am a new user to this site and a beginner with PERL. I am trying to get input form keyboard and the am comparing it with stored value but its not working, instead if i dont take value from keyboard and hard write it in the code then it works.
Problem Elaboration: When i run above mentioned program and take D or NV as input the if condition fails. --------------------------------------------------------Non-working code: #! usr/bin/perl -w $dynamic = 'D'; $nvolatile = "NV"; print ("Enter class: "); $storage = <STDIN>; if(($storage eq $dynamic) || ($storage eq $nvolatile)) { print("\n $storage"); print("\n Done"); } else { print("\n $storage"); print("\n Wrong Class"); }
Working Code: #! usr/bin/perl -w $dynamic = 'D'; $nvolatile = "NV"; print ("Enter class: "); $storage = 'D';#<STDIN>; if(($storage eq $dynamic) || ($storage eq $nvolatile)) { print("\n $storage"); print("\n Done"); } else { print("\n $storage"); print("\n Wrong Class"); }
------------------------------------------------------ Please help out to clarify my concept if there is any missing point.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Error with User defined data
by choroba (Cardinal) on Aug 13, 2014 at 08:22 UTC | |
by a.alandkar (Novice) on Aug 13, 2014 at 14:38 UTC | |
|
Re: Error with User defined data
by Athanasius (Archbishop) on Aug 13, 2014 at 09:30 UTC | |
|
Re: Error with User defined data
by aitap (Curate) on Aug 13, 2014 at 09:53 UTC | |
by Anonymous Monk on Aug 13, 2014 at 11:40 UTC | |
by roboticus (Chancellor) on Aug 13, 2014 at 12:27 UTC | |
by aitap (Curate) on Aug 13, 2014 at 12:31 UTC |