I'd like to write a text filter that takes the contents of the front
document, parses it for errors in proprietary code and print a report
while leaving the original file untouched and preferablely in an
unchanged state.
I manage a group of people, so I want this to be run with a minimal
effort. I've started with the following Text Filter. When I don't
specifically write output back to the original document it's contents
disappear. If I write back it changes the state. Is there a way to do
this where I get the input from the selection but don't have to write
back to it?
Thanks
#!/usr/bin/perl -w
use strict;
my $path_to_report = qq~$ENV{HOME}/report.txt~ ;
my $front_document;
while(<>){
$front_document .= $_;
}
undef $/; # Set input so that it slurps in whole file as one big
string as opposed to line by line
my $file_working_copy = $front_document;
##########################################
$file_working_copy =~ s!foo!bar!ig; # i.e. do stuff
##########################################
print $front_document;# Put content back on page. Do I have to do
this?
open REPORT, qq~>$path_to_report~ ;
print REPORT $file_working_copy;
`open $path_to_report` ; # shell command opens result of lint tool
--
You received this message because you are subscribed to the
"BBEdit Talk" discussion group on Google Groups.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
<http://groups.google.com/group/bbedit?hl=en>
If you have a feature request or would like to report a problem,
please email "[email protected]" rather than posting to the group.
Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>