in reply to Behaving appropriately based on ref() result

You forgot at least 2-3 possible return values, including SCALARREF. Check out ref for a more complete list. Data::Dumper may also be a good place to look for how to handle this.

But, I would rethink what you're doing if you have to do this. Especially, if you're doing this for configuration purposes. How on earth are you planning on persisting a CODE or Regexp reference in your configuration?


My criteria for good software:
  1. Does it work?
  2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?
  • Comment on Re: Behaving appropriately based on ref() result

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

    Data::Dump::Streamer can be used to serialize subroutines and closures properly under sane scenarios. (Yes you can deliberately craft a set of closures that will not dump properly, but it should be quite rare in practice as it would require using unwise var naming practices in the first place.)

    As for regular expressions, DDS can serilize them properly as well so long as they don't include (?{}) and (??{}). In other words regexes that arent closures are properly handled. Ill have to make a stab at handling regex closures in a future release.

    PS: i think you meant "SCALAR" and "REF", there is no perl type "SCALARREF". :-)

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