Miq19 has asked for the wisdom of the Perl Monks concerning the following question:
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 @scales; struct( Scale => { name => '$', offset => '$', foo => '$', index => '$', chords => '@', notes => '@' });
which runs without an issue, but leaves the array empty. If I use Dumper to show the data I get likemy $sref = $scales[$scale]->chords; push @{$sref}, $found_chord . ';' . $c[1];
which looks like there are just empty arrays in that struct. How is the correct push syntax here?... 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' ), ...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Push to array as part of Struct
by choroba (Cardinal) on Sep 10, 2024 at 14:14 UTC | |
|
Re: Push to array as part of Struct
by LanX (Saint) on Sep 10, 2024 at 14:14 UTC | |
|
Re: Push to array as part of Struct
by Fletch (Bishop) on Sep 10, 2024 at 14:57 UTC | |
|
Re: Push to array as part of Struct
by Miq19 (Novice) on Sep 10, 2024 at 14:21 UTC |