|There's more than one way to do things|
Re: ilf - input line frequency time event visualizationby graff (Chancellor)
|on Jul 13, 2005 at 04:36 UTC||Need Help??|
Lots of room for improvement here. First off, why do you abandon sensible line-breaks and indenting in those
Second, why not use the perl-internal time and date functions (or one of the many modules for manipulating date/time values and strings), instead of relying on an OS-dependent "date" shell command? (Yes, the "date" command could have different default output formats on different versions of unix.)
Third, that "whatchar" sub is kind of ugly and way too long. Here's how I would do it:
Note that in the OP code, a "$diff" value of zero had the effect of not changing the value of the global "$pchar". Was that intentional?
Also, my version is written so that the caller doesn't need to do "int($diff)" before calling "whatchar()" (not that it matters, but it just makes more sense to me that way).
Other things can be done to clean up and simplify your code -- I'm just hitting the points that leaped out at me.
update: actually one more thing does jump out at me: fix the usage message; something like this:
Be a little less verbose and exhaustive in the examples, and more "schematic" and structured in the overview of args and options, to make it clear what the command line syntax is.