code4pay has asked for the wisdom of the Perl Monks concerning the following question:
sub doSomething { my ($var) = @_; print $var; }
Say I have a case where If $var equals a particular value I want it to print in a different way. What's the best way to add this extra functionality cleanly.
To add some perspective I have a large legacy code base that has some nice subs for creating html output but they are littered with little if functions so that the sub does something slightly different if x or y is true.
I can see 2 optionsAny thoughts?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Best way to handle small changes to subroutines
by almut (Canon) on May 26, 2010 at 06:38 UTC | |
|
Re: Best way to handle small changes to subroutines
by Anonymous Monk on May 26, 2010 at 06:22 UTC | |
|
Re: Best way to handle small changes to subroutines
by LanX (Saint) on May 26, 2010 at 16:05 UTC | |
|
Re: Best way to handle small changes to subroutines
by ikegami (Patriarch) on May 26, 2010 at 15:03 UTC |