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

Re: [MacPerl] MacPerl & BBEdit



On Fri, Apr 28, 2000 at 10:59:37PM -0400, Jim Correia wrote:
> On 2:43 PM 4/28/00 Benjamin Sadaba <benjamin.sadaba@cnn.com> wrote:
> 
> > My question is very simple. Let's say I have 3 filters a.pl, b.pl and
> > 3.pl, and the three of them do something to whatever I have selected
> > on the front window of BBEdit.
> > 
> > How can I make a perl script that runs the 3 of them at the same time
> > and uses the BBEdit window as Input and Output?
> 
> You can't.  But you an write an applescript that fires the 3 perl
> filters in a row.

Alternatively, you could make a Perl script that executes 3 Perl scripts
that pass their input through variables rather than STDIN and STDOUT.


For example:
*** untested ***


main.pl:

#!perl

{ local $/; $text = <STDIN> }

do "a.pl";
do "b.pl";
do "3.pl";

print $text;


a.pl:

# capitalize "words"

$text =~ s/\b(\w)/\u$1/g;


b.pl:

# replace parens with square brackets

$text =~ tr/()/[]/;


3.pl:

# remove every third line

@lines = split /\n/, $text;

my $i;
$text = join "\n", grep { ++$i % 3 } @lines;



However, the AppleScript solution doesn't require you to modify the
filters; otherwise you could just put all the filters into a single script.

Ronald

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