Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

pray help a poor wanderer with syntax

I am populating a table with some statistics, e.g.
$tables{$day}->{$state} = \[$deathsToday, $m, $double, $intercept, + $corr];
These are grouped in my mind as an array, so that's why I used the anonymous array above. So then it gets used later, viz
foreach my $point ( @${$tables{$day}->{$state}} ) { print $fh "\t", $point;
After time, I want to add a feature, for which I need to access just the first element. It seems like it should be something like ${$tables{$day}->{confirmed}}[0]; but that isn't right. dump $tables{$day} helpfully offers
{ confirmed => \[1, 0.334638642561918, 2, 0.873307778517249, 0.8539438 +57158699], deaths => \[], }
(This is a covid visualization thing.) I could of course convert that five element array to a hash (and actually, just because it comes back from a linear regression as an array doesn't mean it has to stay that way) but I'd like to understand the syntax. Pray, give insight to this lost soul?

In reply to accessing an anonymous array by WoodyWeaver

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2024-03-29 10:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found