Public Scratchpad | Download, Select Code To D/L |
for ww:
If you like, you may enter your location here. Whatever you enter here is displayed at the top of your home node with some other information about you. If you don't enter anything, your home node will show n/a for location.
Note: This field accepts HTML, but is not processed for PerlMonks markup; so, for example, shortcuts are not converted into links.
See also User's Bio (below) for other options related to Location.
Your bio can contain anything you want it to: Information about you, information about your grandmother, your favorite links, helpful tips for making tomato soup. You enter this information as HTML text. See Writeup Formatting Tips and Perl Monks Approved HTML tags for more information about what you can enter here.
Other sites which use HTML comments (<!-- location:latitude:DD.MM.SS,longitude:-DD.MM.SS -->) entered into your Bio to display information about Monks include:
These sites replace jcwren's Monk Maps and Big Monk Map, as described in Put yourself on the Monk Map, (jcwren) RE: Monks' Maps!, and More useless Monk Stats, but use HTML comments in exactly the same way to get your location. See PMplanet for formatting details.
For more information about PMplanet, please refer to PMplanet has a new home. Google Earth Monks is discussed in detail at Google Earth Monks.
$ finger coke@cmu.edu [cmu.edu] (Email addressed to 'coke@cmu.edu' will not be delivered to the following user because it only matches on a last name, not a computer login name.) name: Coke e-mail: coke@ece.cmu.edu [ Forwarding as "coke@ece.cmu.edu" ] [ece.cmu.edu] Login: coke Name: Coke Account Directory: /afs/ece/usr/coke Shell: /bin/true Last login Wed Jan 17 09:39 2007 (EST) on pts/0 from livia.ece.cmu.e No mail. No Plan.
#!/usr/bin/perl -w # # Hack to query and report from www.lexfn.com # # This code is free software; you can redistribute it and/or # modify it under the same terms as Perl itself. # # by rik - ora@rikrose.net # ###################### # support stage # ###################### use strict; use Getopt::Std qw(getopts); use LWP::Simple qw(get); use URI::Escape qw(uri_escape uri_unescape); use HTML::TokeParser; sub usage ( ) { print " usage: lexfn [options] word1 [word2] options available: -s Synonymous -a Antonym -b Birth Year -t Triggers -r Rhymes -d Death Year -g Generalizes -l Sounds like -T Bio Triggers -S Specialises -A Anagram of -k Also Known As -c Comprises -o Occupation of -p Part of -n Nationality or -x for all word1 is mandatory, but some searches require word2\n\n" } ###################### # parse stage # ###################### # grab arguments, and put them into %args hash, leaving nonarguments # in @ARGV for us to process later (where word1 and word2 would be) # if we don't have at least one argument, we die with our usage. my %args; getopts('stgScparlAonbdTkx', \%args); if (@ARGV > 2 || @ARGV == 0) { usage( ); exit 0; } # turn both our words into queries. $ARGV[0] =~ s/ /\+/g; $ARGV[1] ||= ""; if ($ARGV[1]) { $ARGV[1] =~ s/ /\+/g; } # begin our URL construction with the keywords. my $URL = "http://www.lexfn.com/l/lexfn-cuff.cgi?sWord=$ARGV[0]". "&tWord=$ARGV[1]&query=show&maxReach=2"; # now, let's figure out our command-line arguments. each # argument is associated with a relevant search at LexFN, # so we'll first create a mapping to and fro. my %keynames = ( s => 'ASYN', t => 'ATRG', g => 'AGEN', S => 'ASPC', c => 'ACOM', p => 'APAR', a => 'AANT', r => 'ARHY', l => 'ASIM', A => 'AANA', o => 'ABOX', n => 'ABNX', b => 'ABBX', d => 'ABDX', T => 'ABTR', k => 'ABAK' ); foreach my $key(keys %keynames) { $keynames{$key} = lc($keynames{$key}); $keynames{$key} = ucfirst($keynames{$key}); } # if we want everything all matches # then add them to our arguments hash, # in preparation for our URL. use Data::Dumper; #die Dumper(\%keynames); if (defined($args{'x'}) && $args{'x'} == 1) { foreach my $arg (qw/s t g l S c p a r l A o n b d T k/){ $args{$arg} = 1; # in preparation for URL. } delete $args{'x'}; # x means nothing to LexFN. } # build the URL from the flags we want. foreach my $arg (keys %args) { $URL .= '&' . $keynames{$arg} . '=on' i +f $args{$arg} == 1} ###################### # request stage # ###################### # and download it all for parsing. my %table = ( 'sounds like' => $args{l}, 'comprises' => $args{c}, 'rhymes with' => $args{r}, 'is more general than' => $args{g}, 'is a kind of' => $args{p}, 'is an anagram of' => $args{A}, 'triggers' => $args{t}, 'is a synonym of' => $args{s}, ); my $content = get($URL) or die $!; my %tags = (); foreach my $line(split /\n/, $content) { my ($tag) = $line =~ /ALT\=\"([\w ]+)\"/; next unless($tag); $tags{$tag} = $table{$tag}; } ###################### # extract stage # ###################### # with the data sucked down, pass it off to the parser. my $stream = HTML::TokeParser->new( \$content ) or die $!; # skip the form on the page, then it's the first <b> # after the form that we start extracting data from my $tag = $stream->get_tag("/form"); while ($tag = $stream->get_tag("b")) { my $line = ''; $line .= $stream->get_trimmed_text("/b") . " "; $tag = $stream->get_tag("img"); $line .= $tag->[1]{alt} . " "; my $ok = $tags{$tag->[1]{alt}} ? 1 : 0; $tag = $stream->get_tag("a"); $line .= $stream->get_trimmed_text("/a") . "\n"; print $line if($ok); } exit 0;
Resources:planetscape, Apr 24, 2006 at 09:45 UTC In the pedagogues' inbox, Scott7477 writes: "What subject would you most like to see a tutorial for posted to PM? Thx Scott"
Anyone have any preferences? I'd simply suggest he pick a subject he is competent in and comfortable with writing... Either that, or perhaps we should commission him to take on ww's earlier request:
ww says "though slightly OT, suggest a compilation re translation of M$Word to civilized files might be useful; cf: holli's node et seq in Re^2: "Demoronizer" in Best of the Best Users in Perlmonks site and those I mention below."Thoughts?
Clean up your Web pages with HTML TIDY
Charlie's Tidy Add-ons, including a Perl Wrapper
Demoronizer - A perl script to sanitize Microsoft's HTML
Demoronizer - Correct Moronic Microsoft HTML
Word HTML 2 Formatting Objects
WH2FO is a Java application that processes an HTML output, created with Word 2000, and transforms it into an XML content file and an XSL stylesheet file. From these files, a standard XSLT processor may be used to obtain a file containing only XSL-FO markup. You can also apply a stylesheet that converts the XML back into HTML discarding all the extra markup added by Word. Using an XSL-FO renderer, such as FOP, you can also render your document into PDF.
GrandFather's PerlMonks Editor - on CPAN: PMEdit-001.000104-1.pl
HTML::Parser has several example programs, such as hstrip.pl which might be helpful
OpenOffice.org - free office suite and MSOffice alternative
Use OpenOffice to save in HTML format. OpenOffice creates much cleaner HTML, and the resulting file may still be run through HTML Tidy or a script such as hstrip.pl.
Arachnophilia offsite
There may well be more resources out there, but this list should get you started. I suggest examining each alternative's usage, sample (short) input and output, and a breakdown of the pros and cons...
See also:
"Not yet organized" Stuff:
EOF