in reply to Behaving appropriately based on ref() result

Data::Rmap has code doing something like this and may meet your needs. It just uses Scalar::Utils::reftype and if/elses.

ref() can return anything for blessed objects

perl -le 'print ref(bless{},"Hello World")'

Scalar util's reftype is better for this job.

Replies are listed 'Best First'.
Re^2: Behaving appropriately based on ref() result
by demerphq (Chancellor) on Jan 09, 2006 at 08:46 UTC

    Except that it (Scalar::Util::reftype()) can't tell a regexp from a ref to a scalar.

    ---
    $world=~s/war/peace/g