CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner:
Need help (new perl user)



Jun 29, 2009, 7:17 AM

Post #1 of 3 (813 views)
Need help (new perl user) Can't Post

Basically i have been using Perl for about 5 days now at the company for my work experiance i have been doing well with some basic tasks that i needed to complete. But i have a problem with one of the tasks that was set. The question he gave me was

5. While loops and If conditions

Using the while loop. Add some code to check if a number divides by 2. If it does then print "number divides by 2"

So far i have thought that this code that i have started with may be required

#while loops and if conditions


print " Enter a number to see if it is a multiple of 2\n";

$num = <STDIN>;

my $var = $num

Correct me if im wrong or state that i have started correctly. So my question is how can i solve this question


Jun 29, 2009, 8:42 AM

Post #2 of 3 (811 views)
Re: [Zoob] Need help (new perl user) [In reply to] Can't Post

Hi Zoob,

I suggest you bookmark and read:

Beginner's Introduction to Perl

Language reference -

These should get you started. Come back if you have a specific problem. Bonus points if you post your code.




Jun 29, 2009, 6:30 PM

Post #3 of 3 (807 views)
Re: [Zoob] Need help (new perl user) [In reply to] Can't Post

basic format use % then check for remainder

$number = '101'; 
if ($number % 2 == 0) {
print 'ok';
}else {
print "not ok";


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives