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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl Prototypes
by djantzen (Priest) on Nov 02, 2002 at 09:34 UTC | |
|
Re: Perl Prototypes
by broquaint (Abbot) on Nov 02, 2002 at 18:03 UTC | |
|
Re: Perl Prototypes
by Dominus (Parson) on Nov 02, 2002 at 20:42 UTC | |
|
Re: Perl Prototypes
by theorbtwo (Prior) on Nov 03, 2002 at 09:27 UTC | |
|
Re: Perl Prototypes
by perrin (Chancellor) on Nov 02, 2002 at 21:13 UTC | |
|
Re: Perl Prototypes
by John M. Dlugosz (Monsignor) on Nov 04, 2002 at 21:36 UTC |