Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Did ChatGPT do a good job?

by Bod (Parson)
on Mar 29, 2023 at 23:31 UTC ( [id://11151332]=note: print w/replies, xml ) Need Help??


in reply to Did ChatGPT do a good job?

Following this trial by cavac, the next post I looked at was Print %HoH values

So, I thought I would try out ChatGPT to debug the code in that question. I'll leave you to decide how well it did but I feel it would, at the very least, help me with starting the debugging process. It failed to suggest adding use strict.

------------------------------------------

It looks like there is a syntax error in the Perl code that might be causing the issue with the output not being displayed properly. Specifically, the "+" symbol at the end of the line in the inner for loop seems to be an error. Here is the corrected code:

for my $dia (sort keys %HoH) { print "<br>$dia: <br>"; for my $horarios (sort keys %{$HoH{$dia}}) { print "$horarios=>" . $HoH{$dia}->{$horarios} . "<br>" +; } } print "VALUE:<br>"; print ${"2023-01-01"}{"00:00"};
In the last line, the code is attempting to print the value of the key "00:00" in the hash associated with the key "2023-01-01". However, it is not clear from the code snippet whether this key exists in the hash %{"2023-01-01"}. If this key does not exist, the output will be undefined.

Replies are listed 'Best First'.
Re^2: Did ChatGPT do a good job?
by LanX (Saint) on Mar 30, 2023 at 00:34 UTC
    > Specifically, the "+" symbol at the end of the line in the inner for loop seems to be an error.

    you have to click download before copying the code. did you?

    It seems like you copied the monasteries wrap-around symbol + and fed it to the beast.

    > key exists in the hash %{"2023-01-01"}

    For me it's a good hint what's wrong, tho.

    Alas ChatGPT was trained with human text not Perl code, that's what makes this whole discussion bogus.

    It doesn't grasp that dia and horarios are Spanish for what "2023-01-01" and "00:00" stand for and thinks %{"2023-01-01"} is a legit hash.

    Cheers Rolf
    (addicted to the 𐍀𐌴𐍂𐌻 Programming Language :)
    Wikisyntax for the Monastery

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11151332]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2024-03-28 08:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found