I came across a situation (when registering various data changes) where I need to determine if the link has the correct string enforcement (for example, it can be correctly printed in the log or saved in the database). There is nothing in Scalar :: Util for me to do something using other methods in this library:
use strict; use warnings; use Scalar::Util qw(reftype refaddr); sub has_string_coercion { my $value = shift; my $as_string = "$value"; my $ref = ref $value; my $reftype = reftype $value; my $refaddr = sprintf "0x%x", refaddr $value; if ($ref eq $reftype) {
However, I suspect that there may be a better way to determine this by checking the gut of this variable. How can this be done better?
reference perl coercion
Ether
source share