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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Perl Sub routine (Too many arguments)

Status
Not open for further replies.

clueo8

Programmer
Jun 13, 2005
47
US
I have a sub routine set up that accepts 1 argument. When I try to call the subroutine again in my program, it says there is "Too many arguments" Even though there is the same ammount on the first call!

Any help would be appriciated!

Thanks
 
Code:
sub sortby()
{
  my $query = shift;
  ...
}

First Call (In beginning)
Code:
sortby($main_query);

Second Call (later in the code)
Code:
sortby($prev_query);

 
That's because it's Perl and not C.
By putting the brackets after the sub name in the declaration you are supplying a prototype that insists that there be NO parameters.
Loose the brackets and all will compile ok.
Code:
sub sortby
{
  my $query = shift;
  ...
}


Trojan.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top