Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: New and Stumped

by kyle (Abbot)
on Feb 11, 2008 at 04:38 UTC ( [id://667318]=note: print w/replies, xml ) Need Help??


in reply to Stumped UPDATED!?!?!

jcassie420,

Welcome to the Monastery. Please have a look at Writeup Formatting Tips. It appears your entire question is in code tags, but only the code should be.

In answer to your question, see here:

sub more { print "more()\n" } sub fallover { print "fallover()\n" } print "Welcome to johns fun house\n"; print " : "; my $command=<>; chomp $command; if ($command eq "fun") { more; } if ($command eq "laugh") { fallover; }

The first important change is to us "eq" when comparing strings. The "==" comparison is only for numbers. See perlop for details.

The other important change is to chomp the input after you get it. Otherwise, $command will have a trailing line terminator.

As an aside, if you haven't looked into them already, I recommend you use strict and warnings with everything you write. You may want to go without them later, but for now they'll probably save you more headaches than they cause.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://667318]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2024-04-25 14:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found