in reply to converting libraries into modules
Say you create your module and export the half() function as before, you can have your function look like this:
so that, if called via $m->half(), it works the first way, but if called just via half() it works the second way.sub half { my $number; if (ref($_[0]) eq 'MyPackage') { my $self = shift(); $number = shift(); } else { $number = shift(); } return $number / 2; }
($_='kkvvttuu bbooppuuiiffss qqffssmm iibbddllffss')
=~y~b-v~a-z~s; print
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: converting libraries into modules
by chromatic (Archbishop) on Mar 05, 2006 at 21:27 UTC | |
by Limbic~Region (Chancellor) on Mar 05, 2006 at 22:34 UTC | |
by chromatic (Archbishop) on Mar 06, 2006 at 00:08 UTC | |
by wazoox (Prior) on Mar 07, 2006 at 13:12 UTC | |
|
Re^2: converting libraries into modules
by Andre_br (Pilgrim) on Mar 05, 2006 at 18:16 UTC | |
by Andre_br (Pilgrim) on Mar 05, 2006 at 18:34 UTC | |
|
Re^2: converting libraries into modules
by rvosa (Curate) on Mar 05, 2006 at 22:43 UTC | |
by blahblah (Friar) on Mar 06, 2006 at 16:05 UTC | |
by rvosa (Curate) on Mar 07, 2006 at 04:28 UTC |