Simple cross platform perl/Tk timer app

For PC type software that runs under some PC opsys.

Simple cross platform perl/Tk timer app

Postby Doug Coulter » Mon Jul 19, 2010 10:24 am

I wrote software for a living for years, generally C++ or assembly, and like those languages a lot - the right tool for the jobs I was doing, C++ for fast PC apps, and some assembly when needed for speed or size in embedded uPs.

However, now that I do it for myself, sometimes just for fun, I do a lot in Perl, and use Tk for the GUI parts. This in most cases makes it very easy to write applications that are cross platform. Though Perl is an interpreted language, and pretty weird if you came from a land of strong typing, it's the fastest interpreted language out there (much faster than Java or any .NET). This doesn't mean you'd write number crunching code in it (and if you did, you'd use C libraries for that), but it's quick enough that most users won't notice lags. Perl makes great duct-tape for sticking other big chunks of things together (like say, sox, MySQL, serial I/O and the like).

Here is a little Perl/Tk application that should run on just about any platform that has perl and Tk. You get the Tk module for windows if you just get the ActiveState download, and in linux your distro almost surely has Perl already, but you may need to get and install Tk from CPAN. I use Tk, clunky as it is, because it's truly cross platform, and simple for the windows guys to get going. In windows, you generally have to run perl from a dos prompt, but some of the books show how to do it right in windows itself and make a launcher shortcut to avoid having to type >perl myapp at the dos prompt. In linux, it's as easy as invoking the "Add to panel" after right clicking on the taskbar. I will run even GUIs from a terminal sometimes, as then you can use print() for debugging, and the errors or just informational messages you print don't have to show up in the GUI itself.

Perl is most fun in linux, where the standard text editor, Gedit, will do syntax highlighting based on content once you've saved the file once. This makes it one heck of a lot easier to handle and understand the sometimes-strange syntactic constructs it allows.

This little app just does one thing -- it's an eggtimer, more or less, that I use to time my PCB exposure when making boards.
Perl gurus will probably groan about this one -- I made it as wordy as possible for reasons I mention in the comments. I intended this to be "steal this code" example, so I made it easy to copy/paste from.
Attachments
pctim.txt
Open with Gedit for syntax highlighting. I added .txt to this to make it uploadable -- rename as needed.
(4.14 KiB) Downloaded 293 times
Posting as just me, not as the forum owner. Everything I say is "in my opinion" and YMMV -- which should go for everyone without saying.
User avatar
Doug Coulter
 
Posts: 3515
Joined: Wed Jul 14, 2010 7:05 pm
Location: Floyd county, VA, USA

Return to PC

Who is online

Users browsing this forum: No registered users and 4 guests