I don't know about you , but I am here to learn.And as a seasoned member, you would be more progressive in your didactic efforts if your prose were less drenched with condescension and judgmental overtones. If you look through my posts I have never come here for a handout or for anyone to complete my work for me and any solution that I use I have to understand it before implementing it(that's just me).Why would I LIE about anything?? My boss keeps changing requirements and I adjusted them without properly informing the thread, I will own that.Nevertheless I thank you , you helped me to learn another method of doing something and fixed errors in my code as well , so here goes my explanation of code beyond my abilities lol

$app_insert = $dbh->prepare("INSERT INTO bitium_apps(id, app_slug, app +_Name, team_id, provider_id, provider_slug, provider_saml, config_saml, confi +g_login, config_url, created_date, status, key_vault, mfa_code, configuration_i +nstall) VALUES (?, ?, ?, \"$response\", ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?") o +r die $dbh->errstr; use JSON; my $json=new JSON; my $unjson=$json->allow_nonref->decode($api_results); for my $row (@$unjson) { my @insert;

##This stores all the headers you want from the json output into a variable vars

for my $var (qw/.id .slug .name .provider.id .provider.name .provider.capabilities.has_saml .configuration.sam +l .configuration.login .configuration.url .created_a +t .status .key_vault .requires_mfa_code .configurati +on.install_type /){

#Next since the headers have . in them, we will substr and split to just have the header names by themself. Substr takes each header and with an offset of 1 stores those headers with a single . in the format we want into $var2

    my $var2=substr($var,1);

##There are however some complex json headers so we will use split to remove those as well, storing our desired result into an array

     my @parts=split('\.',$var2);

##This transfers out json output which is in a hash format into another variable

   my $base=$row;

##Since we have complex headers we will need to store them into multiple parts and assemble them together again.From the array @parts which houses our headers void of . we will now use pop to put the ending/last of each json header into the terminal variable

   my $terminal=pop @parts;

##I believe this converts the array into a scalar so its easier to determine when it is empty

   while (scalar(@parts)>0) {

##The broken first section or single header values will now be removed from @parts so shift will now move them into variable subparts

  my $subpart=shift @parts;

## Here we begin the reforming of header process referencing the array hash of our json format in base which we transferred from $row

$base=$base->{$subpart}; }

##Then we are going to complete the reforming of our headers referencing our array hash which includes our initial header values from subpart, using terminal then push our derived text output based on our headers into an array @insert

push @insert,$base->{$terminal}; } # var

##Use the perl DBI module to insert our desired values into the database.

$app_insert->execute(@insert[0,1,2,4 .. 15]) or die $app_insert->errs +tr; } # row

In reply to Re^8: Perl Database Entries by cbtshare
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.