Trey Harris <[EMAIL PROTECTED]> writes: > I think I've missed something, even after poring over the archives for > some hours looking for the answer. How does one write defaulting > subroutines a la builtins like print() and chomp()? Assume the code: > > for <> { > printRec; > } > printRec "Done!"; > > sub printRec { > chomp; > print ":$_:\n"; > }
You could take advantage of subroutine signatures and multi-dispatch sub printRec() { printRec($_) } # No args, therefore no new topic. sub printRec($rec) { .chomp; print ":$rec:\n" } # 1 arg Assuming we *get* multidispatch that is. It would be nice to hope that the compiler could optimize that... -- Piers "It is a truth universally acknowledged that a language in possession of a rich syntax must be in need of a rewrite." -- Jane Austen?