Bronston has asked for the wisdom of the Perl Monks concerning the following question:
I'm assuming that's a hash in a hash, if I'm wrong please correct me there. Here's some of my code.my $items = [{ name => 'Arbitrary menu name', url => \&Arbitrary menu function, },{ name => 'Arbitrary menu name 2', 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.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 });
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Stuck trying to append to a hash, I think
by NetWallah (Canon) on Nov 18, 2013 at 21:54 UTC | |
by Bronston (Novice) on Nov 18, 2013 at 22:20 UTC | |
|
Re: Stuck trying to append to a hash, I think
by ww (Archbishop) on Nov 18, 2013 at 22:07 UTC | |
|
Re: Stuck trying to append to a hash, I think
by Laurent_R (Canon) on Nov 18, 2013 at 22:28 UTC |