in reply to Confessional: why I wrote bad Perl code.

vladb++

Another problem that hit me sometimes is the question "Hi Martin, could you just write a script for doing xyz? Takes you less than 30 Minutes? Yes, afterwards you can throw it away, we won't need it any more..."

When the script is running somehow, enhancements are required. "... just this little enhancement, and you can forget it. It will save us some hours of work...".

And by and by functionality is increasing, and the script gets worse and worse. And suddenly, sometimes gets the great idea: "...if you just add this feature, we could use it for other problems as well...".

I try to prevent such situations by trying to write every script as good as possible (if possible because of time and the like). I try not to say, it will take me about 30 minutes, but instead I say: 2 hours. So, at first it always takes me more time than necessary at the beginning, but saves me lots of time (and reputation as well) in future.

The (nearly) only throw-away-scripts I write are one-liners or the like (I normally don't save them to a file)...

But nevertheless, I sometimes produce code that I'm not so much proud of, because of many reasons already mentioned in this thread. But I will keep on learning.

Best regards,
perl -le "s==*F=e=>y~\*martinF~stronat~=>s~[^\w]~~g=>chop,print"

  • Comment on Re: Confessional: why I wrote bad Perl code.