Uses perl core util "date"
date isn't a "perl core util", it's an external operating system command. It's a bad idea to use external commands if they aren't necessary because a) you can never be sure what external commands will be available if you have to move your program to another platform and b) opening a new shell unnecessarily is inefficient. Perl contains everything you need to handle dates. There is no need to use external programs.
--
< http://dave.org.uk>
"The first rule of Perl club is you do not talk about
Perl club." -- Chip Salzenberg
| [reply] |
There are times when I do shell out because I am certain your points a) and b) aren't going to bite me or are outweighed by ease/speed of implementation (I am a unix admin and not a developer after all:) but there is another issue with calling external programs which can hurt as much- the output of any external command you call is not in your control and can change. Usually this will be to the detriment of your program which is relying on the output format to parse out the required data. Click, Boom! Ouch!
-- Do not seek to follow in the footsteps of the wise. Seek what they sought. -Basho
| [reply] |
As I had said, it all depends on what you are trying to achieve. If you're on deadline for a temporary hack, and there is such a thing- then you should be aware of your enviroment. Perl was originally a collection of unix hacks and tools, wasn't it?
You don't code a distribution app that depends on unix tools. But on day to day problems in the office, maintaining a hosting server, whatever- It's shooting yourself in the foot if you imagine perl is the only tool in your box.
The original post was what would *i* do. I got tangled up and wrote a solution that does not address the question.
| [reply] |
| [reply] |