Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Echoing BrowserUK ... “the key,” in any hashref, must be “a string.” What you are using right now will be coerced by Perl into “a string,” but it won’t be a string that you can use in this case.   Therefore, you need to produce, from the arrays that you have, some kind of “single string,”   and to make sure that it’s the string that you want.   When developing code like this, I usually add a few extra statements ... creating a few extra scalar variables (my $d= ...; my $z= ...), inserting some statement (such as the suggested join() to produce the value, then perhaps initially adding print STDERR "d=$d, z=$z\n"; so that I can see what value Perl actually came up with (undoubtedly contrary to my expectations).   Once I’m satisfied with the two strings, I use them in a statement like $$haystack{$d}{$z} = \@zeroes;

The “extra” dollar-sign is functionally equivalent to $haystack->{$d}{$z} ... it’s up to you.

The backslash to the right of the equals-sign is also important:   a hashref is always a collection, indexed by “a string,” to “a scalar,” which in this case should be a reference to an array.   (Look up “references” here.)

Also, in all code, be sure to use: use strict; use warnings;.   Perl is designed to be very accepting and forgiving ... it will try to do what you ask, according to its own interpretation.   These two pragmas will tell it to alert you to mistakes that you probably didn’t realize you were making.   Your code should “run clean,” with no errors or warnings raised.


In reply to Re: Issue with hash definition & possibly some other stuff by sundialsvc4
in thread Issue with grep & getting the right hash values out & possibly some other stuff by crunch_this!

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    [Corion]: ambrus: AnyEvent(::HTTP) doesn't integrate well with Prima, that's my main problem
    [Corion]: There is a weirdo shim because there is a POE integration for Prima, and if you use that, you can use the POE adapter of AnyEvent. What I'd want is something transport agnostic that parses HTTP or produces HTTP output, so that the communication with ...
    [Corion]: ... the socket is done by my code. Ideally that module would not be based on callbacks ;)
    [Corion]: Basically, something that decouples the HTTP parsing (+ determining whether to redirect, etc) from the IO
    [Corion]: All clients I'm aware of don't do that but issue all IO themselves

    How do I use this? | Other CB clients
    Other Users?
    Others about the Monastery: (12)
    As of 2016-12-07 15:50 GMT
    Find Nodes?
      Voting Booth?
      On a regular basis, I'm most likely to spy upon:

      Results (130 votes). Check out past polls.