in reply to Re: Hash of Arrays
in thread Hash of Arrays

This will work, but is there a good reason not to simplify this code by using the 'push' builtin?


$;=sub{$/};@;=map{my($a,$b)=($_,$;);$;=sub{$a.$b->()}} split//,".rekcah lreP rehtona tsuJ";$\=$ ;->();print$/

Replies are listed 'Best First'.
Re: Re: Hash of Arrays
by Anonymous Monk on Oct 12, 2003 at 20:18 UTC
    actually the the reason i wanted the array is because multiple things will be stored in it...for example.... the input looks like <man> ::= <blah> <man> ::= <blah2> so, basically we can have identical keys on the left side in the input and only one string on the right. So in my hash of arrays I'd need to go through the input storing keys and if there is a duplicate key, store whats on the right side of the ::= into that key. thanks again for your help.
      the input looks like
      <man> ::= <blah> <man> ::= <blah2>

      Ah, in that case you'll want to go with either davido's solution or pg's (whichever one you understand better). I wasn't sure from your original post whether that was the case.


      $;=sub{$/};@;=map{my($a,$b)=($_,$;);$;=sub{$a.$b->()}} split//,".rekcah lreP rehtona tsuJ";$\=$ ;->();print$/
      oh i dont know how to make separate lines in this forum post...but <man>::=<blah> is one line and <man> ::= <blah2> is the second.
        That's why there is documentation below the submission area. And a preview button.

        And a link -- "If something looked unlike you expected it to you might need to check out Writeup Formatting Tips"