Adding Arrays as Hash Keys

From: Gohaku (gohaku_at_earthlink.net)
Date: 06/20/04

  • Next message: Charles K. Clarkson: "RE: Adding Arrays as Hash Keys"
    To: Perl Beginners <beginners@perl.org>
    Date: Sun, 20 Jun 2004 01:04:10 -0400
    
    

    Hello everyone,
    I would like to know if there is a cleaner way of Merging Hash Keys
    with Arrays
    and what the correct terminology is for describing this merging.
    I find the syntax somewhat confusing since @ usually refers to an Array
    while
    % refers to a Hash

    @array = qw(1 2 3 4 5);

    #Hash Key and Array Merging...
    @VALS{@array}++;
    #OR.... @VALS{@array} = "";
    #.......fin

    print join(" ",sort keys %VALS),"\n";
    #1 2 3 4 5

    TIA,
    -gohaku


  • Next message: Charles K. Clarkson: "RE: Adding Arrays as Hash Keys"

    Relevant Pages

    • RE: Adding Arrays as Hash Keys
      ... I would like to know if there is a cleaner way of Merging ... Hash Keys with Arrays and what the correct terminology is ... I find the syntax somewhat confusing since @ usually refers ... #Hash Key and Array Merging... ...
      (perl.beginners)
    • Re: Mergesort Vs Quicksort
      ... I might not have correctly remembered my algorithm of months ago ... for sorting records in an array using one auxilary of the ... Merging two parts of greater half: Starting situation: ...
      (comp.programming)
    • Re: value or reference inside foreach ?
      ... Syntactically {shift} is the same as 'shift' which is also why barewords ... as hash keys don't require quotes around them. ... The braces are used for a hash key, as quoting delimiters, to ... dereference an array, and to create an anonymous hash, but none of these ...
      (comp.lang.perl.misc)
    • Re: bit sequence match
      ... :> Edo wrote: ... :> Are the hash keys really going to be numeric? ... %h3 which I think it could be an array @a3 instead, ...
      (comp.lang.perl.misc)
    • Re: Two-dim array: Strange "cant use string as ARRAY ref"
      ... Hash keys are forced to be strings. ... If you give it an array ref as a hash key, ...
      (comp.lang.perl.misc)