[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] Bad subroutine!



Greetings,
This one's driving me crazy and I know the answer must be simple.
I've got this sub:

sub removeLeadingTrailingDoubleSpaces(){
$string = shift;
$string =~ s/^ +//g;
$string =~ s/ +$//g;
$string =~ s/ +/ /g;
return $string
}

When I call it from the "main" part of my program (not within any other
subs) it works as would be expected:

$searchItem = "    hello   ";
$searchItem = removeLeadingTrailingDoubleSpaces($searchItem);

But when I call it from within a subroutine:

sub searchModel(){

$searchItem = shift;
my $modelLabel;
$searchItem = removeLeadingTrailingDoubleSpaces($searchItem);
foreach $modelLabel (keys(%Models)){
	if ($searchItem =~ /$modelLabel/i){
		push(@FoundModels,$modelLabel);
} #end if
} # end foreach
} #end sub

I get the following error:

# Too many arguments for main::removeLeadingTrailingDoubleSpaces, near
"$searchItem)"
File '<AppleEvent>'; Line 183
# Execution of <AppleEvent> aborted due to compilation errors.

I guess I don't understand this at all. I removed any 'my' lexical
scoping from variables cause I thought that was it.
What am I doing wrong?

Allan Greenier

agreenier@snet.net
http://www.geocities.com/~autoscript

===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org