gzip file # compress file gunzip file # decompress file diff `which gzip` `which gunzip` #NONE!
Now, here's the problem I've got: I'm writing a simple library, which should provide two methods, get and slurp, usage scenario looks like this:
$rv=$sth->get("var"); $value=$sth->slurp("var");
Now, the problem at hand is those methods are almost completely identical, they differ in only ~2 lines ( while being ~50 lines long, and expected to grow to ~1k lines ).
Normally I would go with something like this:
but what when you've got arrays as arguments?sub slurp { my ($self,$stuff)=@_; $self->get($stuff,"SLURP"); } sub get { #..... if ($slurp) { # difference.. } else { #... } }
So, I figured I'd use AUTOLOAD... but - first, I don't know how, and second - I'm not really sure if that's the best route... it looks like with AUTOLOAD it's all getting messy...
What do monks think?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Should one treat method name as input?
by demerphq (Chancellor) on Jan 07, 2005 at 12:13 UTC | |
by Eyck (Priest) on Jan 07, 2005 at 12:21 UTC | |
|
Re: Should one treat method name as input?
by Anonymous Monk on Jan 07, 2005 at 12:55 UTC | |
by Jenda (Abbot) on Jan 07, 2005 at 14:47 UTC | |
by Mutant (Priest) on Jan 07, 2005 at 16:21 UTC |