logo       

Subroutine foo redefined a bar: msg#00385

perl-beginners

Subject: Subroutine foo redefined a bar

Hi,

I noticed this error appearing when I stop/started my httpd server
recently (yes this is modperl 1 code).

This offending code reads a like this:


package Some::Pack;
..
..


sub addItemsToBasket {
my ($bid, $items) = @_;
foreach my $i (@items) {
addItemToBasket($bid, $i);
}
}

sub addItemToBasket {
my ($bid, $item) = @_;
...
...
# do some work that adds item
}


addItems expects an array ref, addItem expects a scalar. I'm sure it's
possible to merge the 2 subroutines with the use of `wantarray` or
`ref` to see what the 2nd argument is. I'm a bit nervous of doing that
because if I remove one of the subs, there might be a bit of code
somewhere that still refers to it. grep -r might help but still I am
uneasy with the thought. I'd appreciate any strategy that might help
with this.

My question though is why the warning? Is it simply the order in which
the subroutines are placed within package? My experiments would say
not.

Thanx,
Dp.

--
To unsubscribe, e-mail: beginners-unsubscribe@xxxxxxxx
For additional commands, e-mail: beginners-help@xxxxxxxx
http://learn.perl.org/


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | Mail Home | sitemap | FAQ | advertise