* Chris Fuchs ([EMAIL PROTECTED]) wrote:
[...]
> Since we are on the subject and not having given much thought
> ... (and yes this probably should be another post) ... I've
> often come across neat quotes which I'd like to extract, should
> I be using a filter to do this and if so has anyone come out
> with anything robust enough to handle most the situations that
> I'd be likely to see?
I get quotes sent to me every day through a couple word-a-day lists, and
like to keep the ones that I like. Here's how I do it:
addquote.pl:
#!/usr/bin/perl
use strict;
use diagnostics;
# addquote.pl
# Mike Erickson <[EMAIL PROTECTED]>
my $quotefile = '/home/mee/errata/quidquotes';
open(QUOTES,">>$quotefile") || die "Couldn't open $quotefile: $!";
undef $/;
my $quote = <>;
print QUOTES "%\n$quote";
close(QUOTES);
__END__
in my .vimrc I have
vmap !addquote.pl<CR>q!<CR>
When I find a quote I like, I hit 'e' to edit the message, then go down,
V to visual-block select it, then hit ^G to add it to my fortune-file
(well, pre-strfile'd) list of quotes.
Then, I have a script to get a quote out of said list (if I don't feel
like going through fortune)
getquote.pl
#!/usr/bin/perl
use strict;
use diagnostics;
my $line;
$/ = qq(%\n);
rand($.) < 1 && ($line = $_) while <>;
print substr($line,0, length($line) -2);
__END__
yes, I know it's a nasty, dirty hack of a script, but it works!!
I'll attach them to save anyone the trouble of cutting and pasting.
hth,
me
getquote.pl
addquote.pl