View Single Post
  #10 (permalink)  
Old 03-13-2008, 01:01 PM
pvpchina pvpchina is offline
Newbie
 
Join Date: Mar 2008
Posts: 9
Credits: 0
Rep Power: 0
pvpchina is on a distinguished road
Default Re: Need a perl study-buddy

thanks, im totally pro at functions now! =) gimi a task involving sub routines and functions.. wanna see if im pro ^^


Code:
#!/usr/bin/perl -w
use warnings;
use strict;
sub one;
sub two;

print ("\nPlease Choose a converter \n \n celcius to farenheit (press 1) \n Farenheit to celcius (press 2) \n");
my $a = <STDIN>;
if ($a == 1) {
print ("You chose option 1. Enter your value below \n\n");
my $b = <STDIN>;
print one($b,32,1.8);
}
sub one {
	my $var1 = ($_[0] * $_[2]) +$_[1];
	return $var1;
	}
if ($a == 2) {
print ("You chose option 2. Enter your value below\n\n");
my $c = <STDIN>;
print two($c,32,(5/9));
}
sub two {
	my $var2 = ($_[0] - $_[1]) * $_[2];
	return $var2;
	}


maybe someone see any improvements here? =))))

Last edited by pvpchina; 03-13-2008 at 01:19 PM.
Reply With Quote

Sponsored Links