I have a data structure like
my @scales; struct( Scale => { name => '$', offset => '$', foo => '$', index => '$', chords => '@', notes => '@' });
I found no way on how to push data to the @chords and @notes arrays of a record with that structure. I tried f.i.
my $sref = $scales[$scale]->chords; push @{$sref}, $found_chord . ';' . $c[1];
which runs without an issue, but leaves the array empty. If I use Dumper to show the data I get like
... bless( { 'Scale::index' => '8', 'Scale::notes' => [], 'Scale::name' => 'Major Bebop Eb', 'Scale::chords' => [], 'Scale::foo' => 'E61100', 'Scale::offset' => undef }, 'Scale' ), bless( { 'Scale::offset' => undef, 'Scale::foo' => 'E61100', 'Scale::chords' => [], 'Scale::name' => 'Major Bebop F', 'Scale::notes' => [], 'Scale::index' => '9' }, 'Scale' ), ...
which looks like there are just empty arrays in that struct. How is the correct push syntax here?

In reply to Push to array as part of Struct by Miq19

Title:
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, details, 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, summary, 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.