Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^2: Determining the dayname for the last day of any given month

by davorg (Chancellor)
on Jun 19, 2006 at 14:43 UTC ( #556265=note: print w/ replies, xml ) Need Help??


in reply to Re: Determining the dayname for the last day of any given month
in thread Determining the dayname for the last day of any given month

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


Comment on Re^2: Determining the dayname for the last day of any given month
Re^3: Determining the dayname for the last day of any given month
by greenFox (Vicar) on Jun 19, 2006 at 16:00 UTC

    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

Re^3: Determining the dayname for the last day of any given month
by leocharre (Priest) on Jun 19, 2006 at 18:28 UTC

    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.

      That all makes perfect sense. Just two points to add:

      1. People come to this site a look for examples of code to copy or adapt. If you're writing code here that is just a quick hack (and there's no reason why you shouldn't do that) then please clearly mark it as such so that it doesn't get misused in the future.
      2. There are, of course, times when running external programs is a good idea (as long as you're aware of my caveats above). Date and time handling is never one of those times :-)
      --
      <http://dave.org.uk>

      "The first rule of Perl club is you do not talk about Perl club."
      -- Chip Salzenberg

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://556265]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (16)
As of 2014-09-19 14:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (140 votes), past polls