Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: New and Stumped

by kyle (Abbot)
on Feb 11, 2008 at 04:38 UTC ( #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
Node Status?
node history
Node Type: note [id://667318]
help
Chatterbox?
[choroba]: :-)

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2018-02-21 14:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When it is dark outside I am happiest to see ...














    Results (281 votes). Check out past polls.

    Notices?