Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: New to Programming and I have chose PERL

by kamesh3183 (Beadle)
on Jan 12, 2005 at 06:25 UTC ( [id://421516]=note: print w/replies, xml ) Need Help??


in reply to New to Programming and I have chose PERL

I would have written the above logic like this
#!/usr/local/bin/perl use strict; use warnings; my $input; my $hrate = 0; my $yrate = 0; while (!defined $input) { print "\nDo you wish to calculate yearly salary (y) or hourly rate + (h)?"; chomp ($input = <STDIN>); if ($input =~ /h/i) { print "\nEnter your yearly salary:"; chomp ($yrate = <STDIN>); $hrate = ($yrate / 52) / 40; print "\nYour hourly rate is $hrate"; }elsif ($input =~ /y/i) { print "\nEnter your hourly rate:"; chomp ($hrate = <STDIN>); $yrate = ($hrate * 40) * 52; print "\nYour yearly salary is $yrate"; }elsif ($input =~ /q/i) { exit; }else { print "\nError in input"; } undef $input; #to continue in the loop }
I would like to suggest that a good place to start learning Perl is to read "Learning Perl", published by O'Reilly & Associates. And one more book is freely available online. Name is Simon Cozens' Beginning Perl.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-04-19 23:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found