I'm using the Everything Engine to build a searchable photo archive, and have run into the following problem...

I have an "htmlcode" (which means it behaves like a subroutine so far as I can tell) called "showphotogroup()" Here's how I think it works - but this might all just be voodoo.

It takes an array of references to Node objects (each one corresponding to an image), and lists in a table the thumbnail and the annotation associated with each one. This subroutine is being used in several places - on the search page to display results, on a page called "your new photos" which displays any photos you've uploaded in the last 24 hours (so you can annotate them efficiently), and in scrapbooks - collections of photos that someone has put together by hand.

In some of these instances, it works, and in others, it doesn't, so I don't think the problem is in the subroutine itself, but rather in the way I'm calling it. The following version works fine:

my $str; my $GROUP = getNodeWhere("createtime > DATE_SUB(now(),INTERVAL 24 HOUR +) AND author_user = $$USER{user_id}", 'photo', 'photodatetime'); $str .= showphotogroup(@$GROUP); return $str;
I'm still not 100% clear on what the '@$GROUP' means - is it "treat me like an array, even though I'm just a scalar", in which case how does it know where to break things up into the different elements of the array?

The following version does not work:

my $str; my $GROUP = $$NODE{group}; $str .= showphotogroup(@$GROUP); $str;
Instead, I get the error: null: Can't use string ("7557") as a HASH ref while "strict refs" in use

7557 is the node_id ($$NODE{node_id}) of the first node in the list of nodes contained in @$GROUP.)

The simplified version of the showphotogroup() subroutine that I'm using for testing right now, is:

my @GROUP = @_; return "<p><b>No photos to display</b>\n" unless (@GROUP); my $str; $str .= "<ol>"; foreach my $ptolist (@GROUP) { $str .= "<li>".$$ptolist{title}."</li>"; } $str .= "</ol>"; $str;
Enlightenment wholeheartedly appreciated.

In reply to subroutines and references in Everything by zane

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.