I'd have to double-check the overload documentation again, but I don't think overload derives cmp from string conversion, so you have to check for cmp as well.


It doesn't seem to work. I think because the method isn't named '""', it's just how it's set up with overload. (I have not delved into the internals of overload.)

This is simpler:

  sub is_string_like {
    return 1 unless ref($_[0]);
    return eval {
      ("$_[0]") && (($_[0] cmp $_[0])==0);
    };
  }

I'm of the impression that Class::Stringify is a dead issue. Maybe just modifying overload to derive cmp.



On 14/11/2004 13:29 Tim Bunce wrote:

This all seems overkill. Isn't something like this (untested) enough?:

sub is_string_like {
    return 1 unless ref $_[0]; # returns 1 for undef
    return UNIVERSAL::can($_[0], '""');
}

Tim.


Reply via email to