[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] droplet to run email code examples and programs



I use the following code as a shortcut to test the Perl examples I receive
on this list without having to save them first.

Save the code as a MacPerl droplet. I keep the droplet in my personal
MacPerl folder and put an alias to that on my desktop.

Using it you can execute example code or entire programs in 3 different ways:
  1) Select the code and copy it to the clipboard; then double click the
droplet or its alias.
  2) Select the code and drag a text clipping to the finder; then drag the
clipping over the droplet or its alias.
  3) Save the code as a text file; then drag that file over the droplet or
its alias.

If you drag the code as a text clipping over the droplet or copy the code
to the clipboard the code will first be printed to the MacPerl window and
then it will be evaluated. If you so desire you can delete any text printed
by the code you are trying out and then save the code for later use.

Modify your particular preferences.

I hope someone finds this helpful.

David Seay
http://www.mastercall.com/g-s

-----------------------

#!perl

use Mac::Resources;
use Mac::Memory;
package Dartmouth;

&MacPerl::LoadExternals("clipboard.XFCN"); # XCMD for clipboard processing
package main;

if ($ARGV[0] =~ "text clipping") {
	$fileref = FSpOpenResFile(@ARGV, 1);
	if (defined($fileref)) {
		$reshand = Get1Resource('TEXT', 256);
		if ($reshand) { $code = $reshand->get() } # get text clipping
	}
	CloseResFile $fileref;
} elsif ($ARGV[0]) { do $ARGV[0] }         # execute a dropped, previously
saved program file
} else { $code = &Dartmouth::Clipboard() } # get clipboard contents


if ($code) {
	print "$code\n\n-------------------------\n\n";
	eval($code);
} else {
	print "\a";
	&MacPerl::Quit(0); # don't quit after ending the script
}



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch