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:
my $template = Project::Template::load($filename); $template = Project::Template::replace($template, \%substitution_value +s);
I'ld like to allow template functions to be used on the template variable itself like
$template->replace(\%substitution_values);
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,
Sewi
In reply to Bless a string by Sewi
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |