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

[MacPerl] copy & launch solved



Thanks to the list, I have been able to complete my MacPerl script
to randomize Eudora's signature and launch it.  Another AppleScript
expunged from my hard drive!  :-)  It's a short script and though
written in pidgin Perl, I thought it might be of some interest to
the list:

#!perl

MacPerl::Quit(2);
use Mac::Files;;
use Mac::MoreFiles;
use Mac::Launch;

$homedir = "Isis:Internet:Eudora Folder:Signature Folder:";
$sigdir = "Isis:System Folder:Preferences:Random Signatures:";
$copyname = "signature";
$targetfile = $homedir . $copyname;

#init r.n.g.
srand( time() ^ ($$ + ($$ << 15)) );

opendir BUNG, $sigdir or die "Can't read dir\n";
@filelist = readdir BUNG;
closedir BUNG;

$max = scalar(@filelist);
#print($max, " files in directory\n");
#print("I choose file number ", int(rand $max-1)+1, "\n");
$fileno = int(rand $max-2)+2;
$source = $sigdir . $filelist[$fileno];

# following just echoes a UNIX command for debugging purposes :-)
@args = ("cp", $source, $homedir);
print($args[0], " ",$args[1], " ", $args[2], "\n");

# this does the actual work of replacing the signature file
FSpDelete($targetfile);
$foo = FSpFileCopy($source, $homedir, $copyname, 0);
my @apps = 'CSOm';
LaunchApps([@apps]);

--
| Greg Dunn                       | Trust yourself; Trust Ivanova.   |
| GregDunn@aol.com                | Anyone else -- shoot 'em.        |
| gregdunn@indy.net               |              CDR Susan Ivanova   |
| http://members.aol.com/gregdunn |                                  |

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