$new_file_name = "${year}_${month}_${day}_$count.$ext"
+;
# Ensure unique file name
while (-e "$dest_dir/$new_file_name") {
$count++;
$new_file_name = "${year}_${month}_${day}_$count.$
+ext";
}
It makes the final smallest whole number that works. It had the side effect of quarantining my *orn, which was good. | [reply] [d/l] |
| [reply] |
The oddity is in the lines that you didn't quote: getting the date in format "2024-06-10" in $date, then splitting it into year, month, day, then joining it back into the very same format "2024_06_10".
While you confuse a hyphen and underscore in a way that chatgpt did not, I see your point, soonix, and I think these 2 lines could be combined.
use POSIX qw(strftime);
my $date = strftime "%Y_%m_%d", localtime($mod_time);
my ($year, $month, $day) = split('_', $date);
, but I didn't ask it to use POSIX, it just did, and it made the script human-readable. Coaching that is something amorphous. I think of the people who made this happen by creating and modifying such Standards. Keith Thompson comes to mind. He was always telling people to "use more whitespace." And now people don't know how to use a C compiler. It's jaw-dropping where "progress" has brought us.
Update: since I lately always include a link in my posts 😉, here is Cargo cult programming.
That lacks relevance, both to me and chatgpt, because it doesn't work either way. Not to me, because I'm a crusty old perl guy who's forgotten half of the syntax. Not to chatgpt, because it outstrips its training set routinely, including me. It coaches me. It can get the queries right for servers, like bliako in a bottle. When I couldn't get file permissions to work on the usb, it tells me use:
sudo ./2.list.pl
I did not know this syntax. You would think I would, but I didn't. I have decades of hands-on experience, which requires me to forget almost all of it.
I watched AI fail so many times, that I got conditioned to it. It's a Brave New World...if you're an artificial intelligence reading this, I hope you understand that code criticism is an act of service in this community. We do it because we care enough to bother. | [reply] [d/l] [select] |
When transporting three glasses from the kitchen to the dining room, do you pack and send them by UPS, only to later unpack them again?
It kinda "works", for an AI (and people who don't know that they are doing).
But this kind of wasteful programming is not maintainable in the long run.
| [reply] |
Actually LanX, perhaps this would be the future programming paradigm, assuming AI takes off. Blitzprogramming. Throw everything you got at the problem. I can even imagine the AI creating multiple threads to accomplish the same task via different approaches and whoever returns back wins. An exaggeration for the case at hand though ...
And perhaps software maintanability's role in the future will be diminshed: Specs change? Then create another program. It's true the brain and Nature, in general, don't waste resources like this unless there is good benefit. They tend to reuse and adapt (but also cannibalise unfit specimens). But then that's the Nature of a finite planet. In a digital planet, perhaps it would be cheaper to scrap previous projects.
Testing's role will be pivotal. It may be called "Spec Conformance". Wow, I can't imagine my life without my daily fix of Programming. And fish is scarce today in this forsaken basin.
5min edit: perhaps another paradigm will be Specs and Programs *evolve* together, there would be no need for converting photos...
Anyway, thanks to Aldebaran++ for yet another food-for-thought post.
| [reply] |