I'm working on this code for someone, using a bunch of other people's base code. Not sure what I'm working with which makes modifying it very difficult. Here's some functional base code.
my $items = [{ name => 'Arbitrary menu name', url => \&Arbitrary menu function, },{ name => 'Arbitrary menu name 2', url => \&Arbitrary menu 2, }]; $callback->({ items => $items });
I'm assuming that's a hash in a hash, if I'm wrong please correct me there. Here's some of my code.
opendir DIR, $currentDir or die "cannot open dir $currentDir: $!"; my @file= readdir DIR; closedir DIR; my $items = [{ name => 'Stuff', url => \&Arbitrary menu, foreach my $file (@file) { },{ name => $file, url => \&Arbitrary menu 2, } }]; $callback->({ items => $items });
Basically I just want to shove the name of each file in a directory into each name "key?" there. I'm sure it's obvious my code doesn't work and it's probably even obvious to someone other then me why. Please feel free to elaborate as much as possible when explaining this to me. This isn't going to be the end of this project and the better I understand it the less likely I am to have to bug you fine folks with questions. Thank you very much for any help in advance, Bronston ps. A common response I see on here is for more of the code being used. I don't know if that will come up here but I don't really have more. At least not without posting the entire server this uses.

In reply to Stuck trying to append to a hash, I think by Bronston

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.