Category: | PerlMonks Related Scripts |
Author/Contact Info | Soren / somian / Intrepid check here |
Description: | This is "pmnodecomp-blockquoter", and if you can say that 5 times and still chew salt-water taffy afterwards you get a prize. It's a helper for working in a Xterm shell and composing node text for posts here on Perlmonks. If you are replying to an existing node and wish to cite a brief part of what a previous poster has written, you may like to do so using a style that embraces the quote text in <blockquote> tags. This makes it visually stand out as being text attributable to another poster than yourself. Related Links:
A cryptographically signed copy of the latest release of the program may also be obtained at the site:
|
#!/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; } |