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

[MacPerl-Modules] OK, Here is Something



Here is a simple script I have working that takes the contents of the
frontmost file in BBEdit, gets the file's name, and saves it to a backup
directory in a file of the same name.

#!perl -wl
use Mac::Glue;
use strict;

my $b    = new Mac::Glue "BBEdit";
my $path = 'Bourque:Desktop Folder:Tabs:T: petetemp:';
my $text = $b->get($b->p( window_text => document => 1 ))->get;
my $name = $b->get($b->p( name        => document => 1 ))->get;

open(F, "> $path$name") or die $!;
print F $text;
close F;

__END__

So, tell me what you dislike about the syntax, and how you would want to do it.

A couple of things I don't like:

  * Using $b->p() to specify that this is a property.  I would rather I could
    surmise that automatically, but I don't think I can.  I _could_ export
    functions named p() and o() or prop() and obj() that would simply mark
    the contents as objects, and then I could process them specially when
    they are returned.

    However, $b->o and $b->p do have their benefits, as I could do:

      my $doc  = $b->o(document => 1);
      my $text = $b->get($b->p( window_text => $doc ))->get;
      my $name = $b->get($b->p( name        => $doc ))->get;

    Perhaps both could be provided?  So it would look like:

      my $doc  = $b->obj(document => 1);
      my $text = $b->get(prop( window_text => $doc ))->get;
      my $name = $b->get(prop( name        => $doc ))->get;

  * Using ->get to get the actual data.  Right now, a Mac::AppleEvents::Simple
    object is returned, and ->get gets the data from that object.  I want to
    provide access to that object, though.  Perhaps an additional parameter
    could be passed to get it:

      my $object = $glue->event($obj, {param => 'foo', _retobj => 1});

    If that parameter is not specified (which could also be set for the
    object instance with $glue->RETOBJ(1) or something), then the data
    is returned.

So, thoughts?  Thanks,

--
Chris Nandor          mailto:pudge@pobox.com         http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10  1FF77F13 8180B6B6'])

==== Want to unsubscribe from this list?
==== Send mail with body "unsubscribe" to macperl-modules-request@macperl.org