You misunderstand the objection to the code, it is not about efficient or clever syntax, it is about having ineffective code present. Instead of

my $mod_time = (stat($file_path))[9]; my $date = strftime "%Y_%m_%d", localtime($mod_time); my ($year, $month, $day) = split('_', $date); # ... $new_file_name = "${year}_${month}_${day}_$count.jpg";

Someone thinking about how the program works and what it does (and not just focusing on the sequence of line commands as the LLM does) would be more likely to do something like:

my $mod_time = (stat($file_path))[9]; my $date = strftime "%Y_%m_%d", localtime($mod_time); # ... $new_file_name = "${date}_$count.jpg";

(this is definitely is NOT about computational efficiency, nobody cares whether the computer is doing unnecessary work in this context – this is about crafting and understanding the code.)

Similarly, there are these lines which are some of the "other oddities":

move($file_path, "$dest_dir/$new_file_name") or die "Failed to move fi +le $file_path: !\n"; unlink $file_path or warn "Failed to delete original file $file_path: +$!\n";

The first line MOVEs the file. The file should not exist for the second line to unlink. If the file does still exist the move failed and deleting the original file is probably not a good idea. Again, thinking about the program, what it does, and why each piece of the program is there is something LLMs aren't doing.

Your comments about syntax and module inclusions does touch on an important piece that does often get lost in these conversations, ChatGPT is a tool of empowerment. Much like the classic days of applescript (and indeed Perl itself), these LLMs do bring automated processes to an audience that would not otherwise have the skill to wield more traditional or complex programming tools. It is a aspect that those of us skilled in programming should keep in mind.

At the same time, however, showing a ChatGPT generated script to a programmer is a lot like showing your 4th-grade cub scouts birdhouse to master woodcrafter. The woodcrafter will say "That's nice" and move on. If you continue to insist that the program is worthy of study that's more like saying "Look, anyone can do what you do, you aren't needed anymore – see it's got a hole for the bird (way too big so will allow predators in) and a roof (that doesn't join at the top so rain will get in)." Generated programs may get some work done but they are not good code, are not a path to programming enlightenment, and not going to replace programmers any time soon.

Someone wielding ChatGPT at a site like PerlMonks should focus on attempting to understand the generated code and ask questions of the community about how to learn from the code and how to create code that is better than the generated code (E.g., your .heic file name security bug is still present in the latest program revision).

Good Day,
    Dean


In reply to Re^5: a nifty utility script from chatgpt by duelafn
in thread a nifty utility script from chatgpt by Aldebaran

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.