What is the difference between  my $unjson=$json->allow_nonref->decode($api_results); and

my @unjson=$json->allow_nonref->decode($api_results);
What happened differently when you replaced the $ with @? what was the contents of @unjson in your version

What is the difference between

for my $row (@unjson) {
and
for my $row (@$unjson) {
What happened differently between the two after the change to @unjson=

What is the difference between

for my $var (qw/.id .slug .name .provider.id .provider.name .../){
and
for my $var (qw/.id, .slug, .name, .provider.id, .provider.name,.../) +{
What happened differently after you made that change

Yes the substr removed the leading dot, but its presence was more to remove a leading blank token after the split. The purpose of the split had less to do with removing the dots but instead broke the value into its subparts that were separated by the periods. $row is a hash reference, we did not transfer any json data in that assignment but instead made a copy of the pointer into a working variable that we could then modify without consequence. The scalar value of an array is the number of members in that array. The loop will only first execute if there was more than one period separated subpart to the name/value and will continue to execute while there are still subparts to deal with. $subpart represents the next value in the chain of array references we want to deal with. $base=$base->{$subpart}; then places into $base the reference to the subarray we named via $subpart. if $var was a.b.c on the first loop of the while $base now points to the hash $row->{a} instead of $row. on the second pass of the while loop $base will become $base->{b} which would be the same as $row->{a}{b}. As pop removed subparts from the array the loop finishes when there are no more subparts left in the array and $base is left as the pointer to the deepest hash we need so that $base->{$terminal} will point to the value of the last name of the original @parts. IF there was only 1 subart in the original @parts $base still points to the original hash of $row. if there were 2 subparts left after terminal was popped off, such as in a.b.c $base now points to $row->{a}{b} and $row->{a}{b}{c} would be placed into @insert. If there was only a terminal in $var (such as d) $row->{d} would be placed into @insert since $base would have never been changed from its original setting of $row.

What was the difference between what you posted as $api_results in Re^4: Perl Database Entries and Re^6: Perl Database Entries. What was still wrong with the supposed json in Re^6: Perl Database Entries, (hint there were two errors that poj fixed for you without mentioning them)

So you skipped explaining what went wrong when you changed what i posted, you still dont understand how not telling us what your data was or why posting incorrect data presented a problem in determining what needed to be done, and you dont understand what happened when you changed the for $var (qw/.../) sequence. Given the explanation above ill let you grade yourself on your understanding of what the perl simulation of jg did

.

In reply to Re^9: Perl Database Entries by huck
in thread Perl Database Entries by cbtshare

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.