rahji.com

Main menu:

Site search

Categories

My Other Sites

People

Places

Perl template for TextMate

Here’s how you can create perl scripts in TextMate, starting from a template instead of a blank screen.

TextMate is well worth the money if you do any programming and you own a Mac. In case you use it and haven’t noticed that there’s a “New from Template” menu, take a look. You can create HTML, XML, and other files with this menu item and it starts you out with some stuff that you probably would’ve typed anyway. For some reason, though, it doesn’t have an option for creating new Perl scripts from a template.

To set this up, just follow these steps:

TextMate New from Template menu Go to the “New from Template…” menu and choose “Edit Templates…”

TextMate Edit Template dialog Find “Perl” in the list and use the plus sign in the lower left to create a “New Template”. Edit it to look like the image at left (or you can cut and paste from here)

TextMate Edit Template File dialog Once that’s all set, use the plus sign in the lower left to create a “New Template FILE”. Call it “script.pl” (note that’s the same name mentioned in step 2, so if you use a different name you’ll have to change it in step 2).

Edit the text to look like the image above (or you can cut and paste from here). Of course you can make this look like anything you want. In fact, it’s a good place to put the GNU GPL license.

That’s it. You might have to restart TextMate, but after that you’ll be able to create perl scripts with all of your header business already in there.


If this post is interesting to you, subscribe to this site.

Comments

Comment from Justin Catterall
Time: September 3, 2008, 3:58 pm

I wasn’t looking for a Perl template, but now I’ve found one, that’s handy! Thanks. Co-incidentally, I was actually looking for a MarkDown template for use with TextMate and WordPress. Your post has definitely given me a clue on how to achieve this, thank you.

Comment from nicitita
Time: September 23, 2009, 8:33 am

Thanks, this helps a lot!

Write a comment