#!/usr/bin/perl -w use strict; use WWW::Mechanize; use WWW::Mechanize::FormFiller; use URI::URL; my ($username, $old_passwd, $new_passwd) = @ARGV; my $agent = WWW::Mechanize->new( autocheck => 1 ); my $formfiller = WWW::Mechanize::FormFiller->new(); $agent->env_proxy(); print "Getting http://perlmonks.org/..."; $agent->get('http://perlmonks.org/'); print "done.\n"; $agent->form_number(1) if $agent->forms and scalar @{$agent->forms}; $agent->form_number(2); $agent->current_form->value('user', $username); $agent->current_form->value('passwd', $old_passwd); print "Logging in..."; $agent->submit(); print "done.\n"; #print $agent->content,"\n"; # click on the first /awwaiid/ link print "Going over to the user settings page (2 hops..."; $agent->follow_link('n' => 5); # scrach that... the SECOND /Edit/ link $agent->follow_link('n' => 38); print "done.\n"; $agent->form_number(2); $agent->current_form->value('user_passwd1', $new_passwd); $agent->current_form->value('user_passwd2', $new_passwd); print "Changing password..."; $agent->submit(); print "done.\n"; # look for Passwords updated. to confirm that it worked if($agent->content =~ /Passwords updated\./) { print "It worked!\n"; } else { print "It might not have worked!\n"; }