Dermot wrote:
Hi,
Hello,
I noticed this error appearing when I stop/started my httpd server recently (yes this is modperl 1 code).
Which error? Copy and paste the error message you are receiving.
This offending code reads a like this: package Some::Pack; .. .. sub addItemsToBasket { my ($bid, $items) = @_; foreach my $i (@items) {
Is @items global? Because you are not declaring it in lexical scope.
addItemToBasket($bid, $i); } } sub addItemToBasket { my ($bid, $item) = @_; ... ... # do some work that adds item }
That is very confusing. Why do you have two subroutines with almost identical names and almost identical functionality?
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`
wantarray() is used for the return value of a subroutine, not for the arguments a subroutine accepts.
or `ref` to see what the 2nd argument is.
Why not just pass a scalar and a list? sub addItemsToBasket { my ( $bid, @items ) = @_;
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?
Earlier you said it was an error? And what exactly is it?
Is it simply the order in which the subroutines are placed within package? My experiments would say not.
Are you using parentheses every time you use these subroutines? John -- Those people who think they know everything are a great annoyance to those of us who do. -- Isaac Asimov -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/