Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
As others have said, two very different things. However, perhaps it's worth mentioning here Capture::Attribute which allows subs to declare that the stuff they print should be returned instead. I wrote it about a month ago as a bit of an experiment, and while it's probably not a great idea for code you actually want to be portable and reliable, it can be quite nice for quick scripts you want to write, run once, and then forget about.
perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
In reply to Re: Print Vs Return In a Subroutine
by tobyink
|
|