#!/usr/bin/env perl
eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
if 0; # not running under some shell
# $Author$ Last modified: 14 Dec 2003 15:30:18
# Suggested name: "pmnodecomp-blockquoter" - shorten if wished.
# Or better yet make a symlink or alias.
use strict;
BEGIN {
use vars qw! $plugin !;
$plugin =
(eval { # Place your own home-brewed filter module below.
# This is only a suggestive example / default.
require PMntextFilter;
# import PMnTextFilter "quazzle wrench bangbar";
}) ? 'extern' : 'intern';
}
use warnings;
use vars qw! $DeBug $acq $outfm $rcnt $pictstr !,
qw! $amps $ltgt $sqbr !;
use subs qw! bbegin bendin newblk filtermeta !;
$DeBug = 0;
use constant rCNT => 66; # arbitrary length for output lines.
format EBLK =
</blockquote>
.
format BBLK =
<blockquote>
.
format NBLK =
<br><br>
.
if ($plugin eq 'extern')
{
$amps = sub { PMntextFilter::amps(@_) };
$ltgt = sub { PMntextFilter::ltgt(@_) };
$sqbr = sub { PMntextFilter::sqbr(@_) };
}
else
{
$amps = sub
{
my $amper = '&';
my $para = shift;
$para =~ s% \& %$amper%oxgm;
return $para;
};
$ltgt = sub
{
my ($lt,$gt) = ( '<','>' );
my $para = shift;
$para =~ s% \< %$lt%oxgm;
$para =~ s% \> %$gt%oxgm;
print STDERR "\n$acq\n" if $DeBug;
return $para;
};
$sqbr = sub
{
my ($sqbro,$sqbrc) =
( '[',']' );
my $para = shift;
$para =~ s% \[ %$sqbro%oxgm;
$para =~ s% \] %$sqbrc%oxgm;
print STDERR "\n$acq\n" if $DeBug;
return $para;
};
}
$pictstr = q[^] . q[<] x rCNT;
$outfm = qq[format STDOUT = ]
.qq[\n $pictstr\n]
. q[$acq] . qq[\n.\n];
eval $outfm;
die "Bad perl format!: $@" if $@;
my $splurt = sub { local $/ = qq[]; $acq = <STDIN> };
my $pc = 0;
bbegin;
while (&$splurt and $pc++ < 10000)
{
filtermeta $acq;
write while $acq;
newblk unless eof(STDIN);
}
bendin;
exit 0;
sub filtermeta
{ # Do what you want to here. Given is a minimal default.
$acq=&$amps($acq);
$acq=&$ltgt($acq);
$acq=&$sqbr($acq);
}
sub newblk
{
local $~ = "NBLK";
write;
}
sub bbegin
{
local $~ = "BBLK";
write;
}
sub bendin
{
local $~ = "EBLK";
write;
}
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|