But with prototypes, they aren't:sub ratio_change {...} my @args = ($start_value, $start_total, $new_value, $new_total); ratio_change @args; # Same result as: ratio_change $start_value, $start_total, $new_value, $new_total;
sub ratio_change ($$$$) {...} my @args = ($start_value, $start_total, $new_value, $new_total); ratio_change @args; # Eeks. Won't do what you think it does. ratio_change $start_value, $start_total, $new_value, $new_total;
I don't shy away totally from using prototypes, but the only types I use are:
that is, I purely use prototypes to tell the parser how to parse things. I don't use it for argument checking (which is the typical use for '$$$$' style prototypes) as that get annoying fast - due to '$''s side effect of creating scalar context.sub foo (); sub foo ($); sub foo (&@); sub foo (\@@); sub foo (\%@);
In reply to Re^3: warnings and strict -- The 2 Best Ways You Can Improve Your Programming
by Perl Mouse
in thread warnings and strict -- The 2 Best Ways You Can Improve Your Programming
by liverpole
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |