At 8:32 AM -0700 3/5/2002, I wrote:
>At 4:01 PM +0100 3/5/2002, Axel Rose wrote:
>>I tried to integrate perltidy as a BBEdit Perl Filter without success.
>>Does anybody know how to access the file path a filter works on?
>>($ARGV is empty, $ARGV[0] refers to "...:Cleanup at Startup:myfile.pl�")
>
>BBEdit filters operate on STDIN. I usually set -n or -p and leverage
>the implicit loop structure. That's what I did for working with
>Text::Autoformat. (I bring the whole file into a variable with -n
>and the process it with printing in the END{} block.)
>
>A simple wrapper may provide the necessary framework to accomplish
>what you're looking for.
Not sure why Perl::Tidy isn't happy with STDIN coming from BBEdit. It
might have to do with the 'getline' implementation, but I think not.
Perl::Tidy::perltidy seemed to be reading from an empty filehandle
based on the results I managed to get into a log file. You might check
on the BBEdit list, http://www.barebones.com/support/lists.html to
see what the issue is. I know perltidy has been mentioned before.
After installing IO::Scalar, something like this worked for me. YMMV.
#!/usr/bin/perl -wn
use Perl::Tidy;
BEGIN { my $input_string = ""; my $output_string = ""; }
$input_string .= $_;
END {
Perl::Tidy::perltidy(
source => \$input_string,
destination => \$output_string
);
print "$output_string\n";
}
__END__
--
Charles Albrecht Euonymic Solutions
[EMAIL PROTECTED] P.O. Box 300623
C>303.619.7596 F>978.334.3061 Denver, Colorado 80203-0623
http://www.euonymic.net/~charlesa/cv/