When creating large Perl scripts I like to restrict my freedom to make mistakes, that is after all why we always start scripts with: use strict; and run with -w.
I recently found out about the function prototype stuff (I know it has been there for a long while but I still have to run some of my scripts under Perl 4, so I am a bit behind the times).
So I put prototypes on all my subroutines, but they are not being checked since I like to visually flag my routines with & characters. Removing all the & characters doesn't work, sometimes the -w flag correctly points out things that are difficult for the interpreter to work out. So I end up removing most of the & characters but not all.
In addition the definition of prototypes does not behave as I would have expected. For example:
sub fun1 ($;@) { my($cat,@vals) = @_; ... } my(@args); $args[0] = "type1"; push(@args,"a","b","c"); fun1(@args);
Sets $cat to 4 (the number of items in the list). Yes, upon reflection that is probably the right thing to do, but it is still not what I expected.
So my questions:
Thank you for your attention
In reply to Perl Prototypes by hawtin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |