@ikegami, I believe you've mistaken bichonfrise74 and myself as being the same person, however it seems they've simply stumbled across this thread and wanted some clarification on how perl's prototypes work.
I would like to note, though, that I made some hasty last-minute changes to that subroutine before posting in an attempt to trim it down to only the code that I felt was relevant to the issue at hand. Unfortunately I neglected to remove the $self initialization at the top of the subroutine, which seems to have caused some confusion.
@bichonfrise74, I'm rather new to perl, myself, but I did some digging and it seems that the prototypes don't necessarily enforce constraints on subroutine arguments, rather they coerce the arguments that are passed into the variable types listed in the prototype. At least, that's the impression I got from http://www.perlfoundation.org/perl5/index.cgi?prototype
Update: Seems I was a little hasty in my interpretation. "Coerced" isn't necessarily the correct word there, as it implies the variable's value would remain yet be offered in a new context. Instead, the arguments are interpreted by the subroutine as being in the context of the prototype, meaning if an @array is passed where a $scalar is expected, what would result is actually the length of that array, since $scalar = @array assigns the length of @array to @scalar.
I hope that's clearer, my apologies for any misunderstandings.
In reply to Re^4: Using s/// Inline
by Jason Hutchinson
in thread Using s/// Inline
by Jason Hutchinson
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |