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

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

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

 



Zoob
Novice

Jun 29, 2009, 7:17 AM

Post #1 of 3 (387 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


1arryb
User

Jun 29, 2009, 8:42 AM

Post #2 of 3 (385 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 http://www.perl.com/pub/a/2000/10/begperl1.html

Language reference - perldoc.perl.org http://perldoc.perl.org/index-language.html

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

Cheers,

Larry


ichi
User

Jun 29, 2009, 6:30 PM

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

basic format use % then check for remainder

Code
$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