The stupid question is the question not asked | |
PerlMonks |
Bless a stringby Sewi (Friar) |
on Dec 01, 2011 at 09:33 UTC ( [id://941021]=perlquestion: print w/replies, xml ) | Need Help?? |
Sewi has asked for the wisdom of the Perl Monks concerning the following question: Dear Monks, I know that the following usage of Perl is not suggested and may cause trouble because things are not like they look. It's a very special usage case and I won't ever use this for new designs. We're using a selfmade template module to load, modify and output templates:
I'ld like to allow template functions to be used on the template variable itself like
for fewer typing and less error risks. I know how to handle this on the sub/method side, but I can't replace $template (currently containing HTML source) by bless {}, __PACKAGE__ as some source parts still modify $template's contents in place. MongoDB::OID is using a blessed scalar for it's self-generated IDs. It's a plain scalar when being print'ed but is blessed on MongoDB::OID when Dumper()ed or ref()ed. MongoDB is using C for building these ID objects and I clearly don't like them because it took me hours until I noticed that they were blessed. My usage case is only being used by a small team of developers and it would be clearly documentated. Is it possible to bless a scalar value using pure Perl? bless $string, __PACKAGE__; doesn't work (Can't bless a non-reference). Thanks,
Back to
Seekers of Perl Wisdom
|
|