Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

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!?!?!


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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://667318]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (8)
As of 2018-07-17 21:41 GMT
Find Nodes?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

    Results (378 votes). Check out past polls.