|Pathologically Eclectic Rubbish Lister|
Re: Re: Passing multiple data types to a subroutineby Chmrr (Vicar)
|on Nov 28, 2003 at 20:20 UTC||Need Help??|
Err -- whoa there. There are a few problems with this code. First off, let me clean it up a little (such as actually passing it an array with some elements in it) and feed it though with -w -Mstrict
..to which perl says:
..which shows the two most glaring bugs in the code. First off, you've given your subroutine a prototype, which only works if your calls to the subroutine are after its declaration. If you move the subroutine to above the call, however, we discover that you're giving the wrong prototype, anyways! (Too many arguments for main::my_subroutine at - line 15, near "$scalar2)")
You're also passing in an array, and trying to treat it as an array reference in the code. That's what the second error message is telling you.
These are all vaguely fixable by changing your code to:
..but don't do that, as prototypes are mostly broken and confusing. This public service announcement has been brought yo you by the letter P and the number 42.
Networking -- only one letter away from not working