I got a test next week in perlIf someone could help me with a few things later on id appreciate it..
my msn is : pvpchina@hotmail.com - maybe I can pay you somethingwont take more than 1 hour i promise! just need sum questions answered
If you have questions you should just post them. If you are, on the other hand, trying to cheat on a test, forget it. As far as contacting you by email and providing personal service, I'll pass.
I agree with KevinADC. We do not cheat for you at school. If you are required to learn Perl in school then you should actually learn it, it may help you in the future.
its not cheating.. just hmextra tutoring to get an in-depth knowledge..anyways ill ask for some specific help later =) at the moment trying to figure out what chop means mhhhhh
The chop() function removes the last character of any string, regardless of what that character actually is. chop("jordan") would return cause the string to become "jorda" with a return value of "n".
Using the Perl chop() function
look up perls builtin functions on the perldoc website, Perl version 5.10.0 documentation - perldoc.perl.org but as a personal observation, if you need assistance with chop() you're in for a long and hard journey in learning perl. Hopefully you were just joking.
cool thanks, got it. so chop is used to remove the last character, and if i have
a new line, it will remove the new line when i press enter.
now i need to know difference between
$a = <STDIN>;
my $a = <STDIN>;
=)) which one to use?
#!/usr/bin/perl -w
use strict;
sub funky();
funky();
print(funky()."\n");
my $random = <STDIN>;
print(funky().$random);
sub funky(){
my $var1 = $_[0] * 30;
return $var1;
}
also need help with this one.. duno why it doesnt work =(
Stop doing this:
sub funky(){
do not put parenthesis after subroutine names, write it like this:
sub funky {
when you put parenthesis you are creating a prototype, there is no reason to do that and it will just complicate matters if you continue to do it.
Here it is rewritten simpler and passing $random into the function properly:
Code:#!/usr/bin/perl use warnings; use strict; my $random = 5; print funky($random); sub funky{ my $var1 = $_[0] * 30; return $var1; }
Last edited by KevinADC; 03-13-2008 at 01:22 AM.
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 10:19 AM.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks