Fix Those Legacy Subroutines or Methods

Maybe you know the feeling… you go to add an option to that method or subroutine and… cue Jaws theme

sub update_shopping_cart {
    my $cart_id        = shift;
    my $item           = shift;
    my $quantity       = shift;

Argh. You don’t want your legacy code to break but you also don’t want to add a fourth unnamed parameter to the existing problem. And the solution is simple:

more

1 Comment

This is a pretty elegant solution. I like it.

Leave a comment

About tinypig

user-pic I blog about Perl.