Loading ...
Sorry, an error occurred while loading the content.

Re: [PBML] I need help with hash of array (and references). Urgent please.

Expand Messages
  • Jeff 'japhy' Pinyan
    ... I don t have that problem with your code: while ( ) { my ($x, @y) = split ; $z{$x} = @y; } for (keys %z) { print $_ = @{ $z{$_} } n ; } __DATA__
    Message 1 of 3 , Apr 22, 2002
    • 0 Attachment
      On Apr 22, GARCIA Lionel said:

      >while (<REFERENCE>) {
      > my ($name, @datas)=split /:/;
      > $reference{$name}=\@datas;
      >}
      >
      >But of course, and that's why I need help, all my elements in hash refer to
      >the last item read. So how could I store a reference to each entry ?

      I don't have that problem with your code:

      while (<DATA>) {
      my ($x, @y) = split ' ';
      $z{$x} = \@y;
      }

      for (keys %z) {
      print "$_ => @{ $z{$_} }\n";
      }

      __DATA__
      ab cd ef gh
      ij kl mn op
      qr st uv wx


      --
      Jeff "japhy" Pinyan japhy@... http://www.pobox.com/~japhy/
      RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/
      ** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
      <stu> what does y/// stand for? <tenderpuss> why, yansliterate of course.
      [ I'm looking for programming work. If you like my work, let me know. ]
    Your message has been successfully submitted and would be delivered to recipients shortly.