in reply to Re^3: removing files with perl based on age and name
in thread removing files with perl based on age and name

gurpreetsingh13:

They think everything should be in perl itself and think that pure perl can take them to the other side.

Untrue--there are numerous articles where people suggested just using a command line operation instead of writing a perl script. I've done so a few times myself.

We have a unix system and should recognize the power of that OS which has been there since 30 years ago. What is the problem there in shipping out something to shell when the work gets done easily.

Many of us here are Unix-centric and have no problem shelling out for some tasks. But the way I read the situation is more like this:

Hippo: Why are you using the cutting blade of your swiss-army knife to remove that screw? You know it has a couple screwdriver blades, right?
gurpreetsingh13: That's the problem I have with you guys...knife blades are perfectly capable of opening paint cans, removing screws, driving nails. You don't need all those other fancy attachments.

Hmmm ... okay. Or maybe a better analogy might be this:

Hippo: You're trying to drive a nail with a chainsaw. Are you sure you really need the chainsaw to be running while you're doing that? Seems a bit iffy.
gurpreetsingh13: But chainsaws are powerful tools! Why not use them?

But ... the blood ... the detached limbs ... possible severed heads ...

But since this code is workable (tested few times on my home directory), so I had to put that rm -rf there.

Just because you tested it in your home directory, doesn't make it require -rf. But I'm guessing you didn't test it in your home directory, unless you (a) just created a brand-new virtual machine to run it under, (b) just created a new account to run it under, (c) had spaces in the names of all your important files and directory names, or (d) didn't have any important files anyway.

This is a simple script and we can forget about execution speed here.Any intelligent guy would never run the script without reading the code.

True, instead he'd delete the script and then run away screaming. That's a pretty scary script to have on your system. If you happened to be in the wrong directory and ran it, your first clue to a problem might be something like:

bash: stat: command not found

showing up after a couple minutes of disk thrashing. Since it helpfully provides -r, it could merrily wreak havok on the filesystem ... at least until enough programs died that the script would fail.

While I agree that shelling out to other programs to solve a problem is fine, it pains me to see:

hippo raised a couple issues with the script, but your dismissal of those issues is rather peremptory.

Update: A couple fixes: s/amputations/limbs/, changed a ? to a !.

...roboticus

When your only tool is a hammer, all problems look like your thumb.

Replies are listed 'Best First'.
Re^5: removing files with perl based on age and name
by Laurent_R (Canon) on Jul 18, 2014 at 21:45 UTC
    Thank you for your detailed answer, roboticus, I fully endorse it. There were numerous things in gurpreetsingh13's post that I would have wanted to comment (not necessarily exactly the sames as you, but mostly along the same lines), but you did it in a masterful way, no point to add further debunking, you just did it right.

    Just in case someone might understand it false, I am using almost daily Unix powerful tools (sort, find, cut, etc., sometimes even awk and sed, and many others), and yes, they are very powerful. For example, one thing I am doing regularly is to use the Unix sort utility to sort (usually with relatively complicated sort, field by field, for which the Unix sort is very good) a very large file and then piping the output to a Perl program that will remove duplicates or do all kinds of other interesting things. In some cases, I am also using the Unix shell to create parallel Perl processes in a very easy way. But shelling out of Perl to just stat a file last modification date, to remove a file or changing permissions is just plain stupid non-sense when the language can do it so easily.

    To gurpreetsingh13: I did not downvote your original post with the script, because, despite what I said earlier about its shortcomings, I still think it can be considered as a valuable and useful contribution (even though I fully agree with Hippo's comments on it), but, yes, I did downvote your last answer, which is just pathetically wrong, as beautifully demonstrated by roboticus. Having done that, I can see that I am far from being the only one: you've made it to the top worst node of the day (and probably soon top worst node of the week, it is probably just a matter of time for update).

    No personal hostility, I think your argument is just plain wrong.

Re^5: removing files with perl based on age and name
by 1s44c (Scribe) on Jul 19, 2014 at 04:10 UTC

    This is without a doubt the best response I've ever read on this site.