in reply to Re^4: Perl Database Entries
in thread Perl Database Entries
what did you assign to $api_results? Remember my line dropped the pipe into jg, what you showed us above is not json
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: Perl Database Entries
by cbtshare (Monk) on Jul 16, 2017 at 06:51 UTC | |
But after running the code I am getting the error Not a HASH reference at line 79, <> line 2. line 79 is push @insert,$row->{$var}; | [reply] [d/l] |
by huck (Prior) on Jul 16, 2017 at 08:15 UTC | |
No that is not your $api_results, is it? Again that is invalid json, when i fixed it i got the same result you did. If you lie to us why do you expect to get valid advice? And you dont follow instructions well do you? you changed THREE major parts of what i had posted, resulting in a whole different result from what you would have gotten if you had just cut & pasted what i wrote. but not knowing what jg did, i misinterpreted part of what was needed to make this work, so i included the fix in this version. See if you can figure out what you did wrong and why was it wrong from what i had first posted. Then try to figure out what i did to simulate how jg worked. But i suspect both tasks are beyond your abilities. Dont screw up again, and try to learn about what you are doing rather than just trying to get someone to do it for you | [reply] [d/l] |
by cbtshare (Monk) on Jul 16, 2017 at 20:39 UTC | |
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
##This stores all the headers you want from the json output into a variable vars
#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
##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
##Use the perl DBI module to insert our desired values into the database.
| [reply] [d/l] [select] |
by huck (Prior) on Jul 16, 2017 at 21:39 UTC | |
by huck (Prior) on Jul 17, 2017 at 02:04 UTC | |
by poj (Abbot) on Jul 16, 2017 at 08:15 UTC | |
Try this, check the log and if OK un-comment the database commands poj | [reply] [d/l] |
by cbtshare (Monk) on Jul 16, 2017 at 20:42 UTC | |
| [reply] |