Re: creating a hash list from arrays

From: Radhika Sambamurti (radhika_at_schemamania.org)
Date: 10/28/03


Date: Mon, 27 Oct 2003 22:40:33 -0500
To: Daniel Staal <DStaal@usa.net>

Hmmm, This did not work.
my $count = keys %results_hash; gives me 0
And perl also complained that $results_hash had to be explicitly defined, so I had my $results_hash AND my %results_hash.
This is not working. my hash is empty.

Radhika

On Mon, 27 Oct 2003 21:24:28 -0600
Daniel Staal <DStaal@usa.net> wrote:

> --On Monday, October 27, 2003 21:22 -0600 Daniel Staal
> <DStaal@usa.net> wrote:
>
> >
> > my $results_hash;
>
> Sorry, correction. That should be:
>
> my %results_hash;
>
> > while (my $res = $sth->fetchrow_hashref()) {
> > push(@menu_id, $res->{"menu_item_number"});
> > push(@menu_desc, $res->{"description"});
> > $results_hash = ($res->{"menu_item_number"},
> > $res->{"description"});
> > }
> >
> > Then the hash won't expire at the end of the loop.
>
> Daniel T. Staal
>
> ---------------------------------------------------------------
> This email copyright the author. Unless otherwise noted, you
> are expressly allowed to retransmit, quote, or otherwise use
> the contents for non-commercial purposes. This copyright will
> expire 5 years after the author's death, or in 30 years,
> whichever is longer, unless such a period is in excess of
> local copyright law.
> ---------------------------------------------------------------
>
> --
> To unsubscribe, e-mail: beginners-unsubscribe@perl.org
> For additional commands, e-mail: beginners-help@perl.org
>



Relevant Pages

  • Re: Noob! Help required and would be really appreciated!
    ... You've read 60% of "Learning Perl"? ... On finding the keyword "New Order", it has to start building a hash. ... want to build a loop around this hash creation. ... transferred to %allOrders. ...
    (comp.lang.perl.misc)
  • Re: Passing an array to a sub routine
    ... but later you're using a hash. ... In Perl, these are very ... The LoadDataFile routine works correctly, ...
    (comp.lang.perl.misc)
  • Making Datatypes Constant and Emulating Const Correctness
    ... Being relatively new to Perl with Java and bits of C under my belt, ... I'm new to C+++, too, but remember a number of uses for the const keyword ... an array to some analizer function as a constant strongly signals that no ... some reference (e,g. a blessed hash reference) ...
    (comp.lang.perl.misc)
  • Re: taking references to functions
    ... > I'm building a diagnostic medical questionnaire using Perl Tk. ... > to create a reference to a named function but not for unnamed ones. ... Notice that %dispatch here is an actual hash variable. ...
    (perl.beginners)
  • Re: arrange form data in same order as on form
    ... In Perl, f you get your submitted name/value pairs from the ... module as a "hash", then of course the ordering has been lost by then. ... the element, now deprecated, from earlier versions of HTML). ... their scripts were easier to write, ...
    (comp.lang.perl.misc)