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

Re: Perl Beginner

by Marshall (Canon)
on Nov 26, 2016 at 02:25 UTC ( [id://1176575]=note: print w/replies, xml ) Need Help??


in reply to Perl Beginner

You are reading a line from the terminal, not just a single character. You need chomp to remove the line ending character(s). Also, get in the habit of indenting your code one level when looping.
print "please enter one character: "; $char = <>; chomp $char; while ($char ne ".") { if ($char eq "a") { $count++; } print "please enter one character: "; $char = <>; chomp $char; } print "The number of a is $count\n"; print "done";

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (2)
As of 2024-04-19 20:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found