Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error in syntax

Status
Not open for further replies.

NashTrump

Technical User
Jul 23, 2005
38
0
0
GB
Hi there,

Im building a small psub procedure to do maths.
Now its a very simple procedure however im getting errors i cant explain:
Heres the code:

my $barone = 10;
my $bartwo = 5;
my $mathage = maths($barone, $bartwo);

line 269 Sub maths{
line 270 ($betone, $bettwo);
line 271 $mather = $betone / $bettwo;
line 272 return $mather;
line 273 }

i get this error:

syntax error at C:\Documents and Settings\Lee Nash\Desktop\GAF Projects\Betting\Perl\betfred.pl line 271, near "$mather "
syntax error at C:\Documents and Settings\Lee Nash\Desktop\GAF Projects\Betting\Perl\betfred.pl line 273, near "}"
Execution of C:\Documents and Settings\Lee Nash\Desktop\GAF Projects\Betting\Perl\betfred.pl aborted due to compilation errors.

Can anyone help me on this?

Regards

Nash

 
Try this:
Code:
#!/usr/bin/perl 

use strict;
use warnings;

my $barone = 10;
my $bartwo = 5;
my $mathage = &maths($barone, $bartwo);
print "Returned value: $mathage\n";

sub maths{
my ($betone, $bettwo) = @_;    
my $mather = $betone / $bettwo;
return $mather;
}

You had "sub" with a capital "S", and you didn't declare your variables in the subroutine.

Let us know your results!

X
 
Thank you that worked great!!

It was the capital S that knackered me!!
So irritating when i miss something like that

Thanks again

Nash
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top