# this works as a bash include
#
#PRIO 1.5
#COMM MainLib::Data
#COMM - &DataPrint on objects without overloaded DataPrint() method
#
function homogaddr {
  perl -n -e 's/(ARRAY|HASH)\(0x\w{5,8}\)/$1(0x123ABC)/; print' "$@"
}
perl -e '
  use lib shift();
    # give include precedence to code directory, perl -I would not work!
  use MainLib::Data;
  print "ARRAY-based object on top level\n";
  &DataPrint(OOArray->new(),-space=>2);
  print "ARRAY-based object, nested\n";
  &DataPrint([ OOArray->new() ],-space=>2,-NoMyRef=>1,-NoAddr=>1);
    # frame by ARRAY in order to observe output from root to node
  print "ARRAY-based object, nested, including address\n";
  &DataPrint([ OOArray->new() ],-space=>2,-NoMyRef=>1);
    # frame by ARRAY in order to observe output from root to node
  print "HASH-based object on top level\n";
  &DataPrint(OOHash->new(),-space=>2);
  print "HASH-based object, nested\n";
  &DataPrint([ OOHash->new() ],-space=>2,-NoMyRef=>1,-NoAddr=>1);
    # frame by ARRAY in order to observe output from root to node
  print "HASH-based object, nested, including address\n";
  &DataPrint([ OOHash->new() ],-space=>2,-NoMyRef=>1);
    # frame by ARRAY in order to observe output from root to node
  #-------------
  package OOScalar;
  sub new {
    bless q(S);
  }
  package OOArray;
  sub new {
    bless [ q(a), 2 ];
  }
  package OOHash;
  sub new {
    bless { q(a)=>1, 2=>q(B) };
  }
  ' "$dircode"  \
| homogaddr
