I've got a set of modules that use objects to represent nodes on a graph, and uses simple references to represent the arcs between them. What I'm trying to do now is introduce a concept whereby I can declare an arc as 'active' or 'inactive' without severing the arc. Similar to how you can leave a lamp plugged into the wall socket, and the electricity is either on or off.

What I'm wondering is if there might be a good metaphor using simple perl syntax to represent this phenomenon without a secondary data structure to store this active/inactive information. I tried adding a level of indirection, such as:
#active: push @{$object->{related}}, $object2; #inactive @{$object->{related}}, \$object2;
but that got to be a nightmare in remembering to dereference it everywhere. So I'm now wondering if there's a way to tag the reference in such a way as to be able to test for it's 'activeness'. Scalar::Util's weaken() function would be a great metaphor for this (testing with the isweak() function) but I can't afford to have weaken's intended effect as a side effect.

Note that I don't want to annotate the targeted object. The object isn't 'active' or 'inactive'. It's the arc drawn between the two.

I'm willing to entertain black magic at this point even if it doesn't prove feasible down the line. I'm a stickler for useable, straightforward syntax, even if it means some vodoo underneath.

update: After some discussion in the chatterbox with Mr. Muskrat and atcroft it became obvious that I hadn't provided enough information: At the moment the best strategy seems to be to keep the active/inactive information in a parallel data structure inside the tied array. That way i can do something like
[% IF object.related.isActive( related_obj ) %]...[% END %]
but if anyone has any other interesting approaches to this I'd be glad to hear them. The simpler for the template authors, the better.

In reply to adding meta-data to references-as-graph-arcs by AidanLee

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.