I just Super Searched and found eleven occurances occurences of me misspelling monastery. Sheesh! Even my 500th Post was tainted! ;)

For the record, these days when i need to spell monastery, i just remember that the a and the e are what get confused - so i simply use the fact that (sorting alpha-wise) a comes before e in this case: monastery.

UPDATE: here is the code as promised. It worked well for my needs, but tweaking will be necessary for your needs. I must admit that i screwed up and lost the content for 79578. I tried to get a copy from http://perlmonks.thepen.com but i was too late. What did i do wrong? I simply used this:

$agent->field('note_doctext');
instead of this:
$agent->field('note_doctext',$textarea);
Ouch!! Oh well, live and learn. Here is the complete code, and be careful!
use strict; use warnings; use XML::XPath; use XML::LibXML; use WWW::Mechanize; use HTTP::Cookies; use Data::Dumper; use constant URL => 'http://www.perlmonks.org'; my $user_name = ; my $user_id = ; my $password = ; my $search = 'onestary'; my $replace = 'onastery'; my $agent = login($user_name,$password); my $raw_results = raw_search_results($agent,$user_name,$search); my @link = get_links($raw_results); replace($agent,$_,$search,$replace) for @link; sub replace { my ($agent,$link,$search,$replace) = @_; $agent->get(URL . $link); print STDERR "got $link ..."; my $textarea = get_textarea($agent->{content}); warn "no textarea for $link" and return unless $textarea; $textarea =~ s/$search/$replace/g; $agent->form(2); $agent->field('note_doctext',$textarea); $agent->click('sexisgood'); print STDERR "done!\n"; } sub get_textarea { my $html = shift; my $dom = get_dom($html); my @node = $dom->findvalue(q|//textarea[@name='note_doctext']|); return $node[0]; } sub get_links { my $html = shift; my $dom = get_dom($html); my @link; for ($dom->findnodes(q|//table[@width='100%']/tr/td/a|)) { my $href = $_->getAttribute('href'); next unless $href; my ($id) = $href =~ /(\d+)$/; $id ||= 0; push @link, $href if $id > $user_id; } return @link; } sub get_dom { XML::LibXML->new->parse_html_string(shift) } sub raw_search_results { my ($agent,$author,$text) = @_; # Super Search is node 3989 $agent->get(URL . '/index.pl?node_id=3989'); $agent->form(2); $agent->field(@$_) for ( ['BIT', $text], # search text [qw(xa 0 1)], # include ... ['a', $author], # author ); $agent->click('go'); print STDERR "got search results ...\n"; return $agent->{content}; } sub login { my ($user,$pass) = @_; my $agent = WWW::Mechanize->new(); $agent->cookie_jar(HTTP::Cookies->new()); # Reviews is a fast loading page to login with $agent->get(URL . '/index.pl?node_id=21144'); $agent->form(2); $agent->field(@$_) for ( [qw(op login)], ['user', $user], ['passwd',$pass], ); $agent->click('login'); print STDERR "logged in ...\n"; return $agent; }

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

In reply to (jeffa) Re: Pity da foo who misspells Monastery by jeffa
in thread Pity da foo who misspells Monastery by benn

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.