I am no more than 2-3 weeks into perl and I am trying to better understand
while () loops a tad better.Here is a snippet from of a code I wrote up to work on my conditionals and loops:
while () {
print "Are you having/had a good, bad, or iffy day $name?: ";
chomp ($input = <STDIN>);
if ($input eq 'good') {
print "Glad you are doing well!\n";last;}
elsif ($input eq 'bad') {
print "Oi, that's not good to hear!\n";last;}
elsif ($input eq 'iffy') {
print "At least you're undecided...still hope after all.\n
+";last;}
}
print "\n";
In this block, I really wanted to do something like:
elsif ($input ne 'good'|| 'bad'|| 'iffy') {
next;}
and get rid of all the {last;} at the end of each elsif statement. The problem is that I can't seem to get this
or operator to work properlly and I was hoping someone could possibly point me in the right direction.
Thank you in advance.
BTW, the full code can be found at in my sketchpad titled
"Practicing Conditionals"
code in sketchpad updated 2005.12.02
"Es gibt mehr zu Leben als Bücher, kennen Sie.
Aber nicht viel mehr " -(Der Smiths)
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.