v_melnik has asked for the wisdom of the Perl Monks concerning the following question:
Dear colleagues,
I upgraded XML::LibXML from 1.x to 2.x and now all its objects return their textContent() when no methods are given.
I've got used to log object's class names with their unique identifiers, so now I can't just say something like: $log->trace("Information has been loaded as $dom");
ow to get object's name and ID?
Thank you!
P.S. Updated:
sub mm_sprintify { my($message, @values) = @_; return($message) unless(@values); for(my $i = 0; $i < @_; $i++) { given($values[$i]) { when(undef) { $values[$i] = "< undef >"; } when(blessed($_)) { $values[$i] = sprintf("[%s\@0x%x +]", blessed($_), refaddr($_)); } when(ref($_) eq 'HASH') { $values[$i] = Dumper($_); } } } return(sprintf($message, @values)); }
So, now I say $log->debug("The %s %s is loaded as %s", $element_name, $element_type, $element_dom); and feeling quite happy.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to use object's reference in "object" context if being used in scalar context it does something wrong?
by perlfan (Parson) on Jul 08, 2014 at 14:24 UTC | |
|
Re: How to use object's reference in "object" context if being used in scalar context it does something wrong?
by Anonymous Monk on Jul 08, 2014 at 14:26 UTC | |
by v_melnik (Scribe) on Jul 08, 2014 at 14:49 UTC | |
by tobyink (Canon) on Jul 08, 2014 at 15:43 UTC |