http://qs1969.pair.com?node_id=143040


in reply to PerlMonks modules 2.0

It seems that these modules have stopped working, possibly due to the Perlmonks Server Move. I've patched it up hurridly, and it seems to work. Probably the Correct Solution is to change everything over to using the XML modules, but not only do I not have the time (or knowledge), but this isn't my code, so I'll stick to minimal patching. (Hope you don't mind this much, ZZamboni.)

Update: tye has much better code on tye's scratchpad.

diff -ru ./PerlMonks/Chat.pm.orig ./PerlMonks/Chat.pm --- ./PerlMonks/Chat.pm.orig Fri Oct 27 15:47:21 2000 +++ ./PerlMonks/Chat.pm Sat Feb 2 23:37:50 2002 @@ -58,7 +58,7 @@ # Get general chat messages if ($c=$self->getpage(CHAT_URL)) { $c=~s/[\r\n\t]//g; - my @msgs=($c=~/message\s+author="([^\"]+)"[^>]+>\s*(.*?)\s*<\/mes +sage>/g); + my @msgs=($c=~/message[^>]*\s+author="([^\"]+)"[^>]+>\s*(.*?)\s*< +\/message>/g); if (@msgs) { while (@msgs) { my ($author, $msg)=(shift(@msgs),shift(@msgs)); @@ -91,7 +91,8 @@ if ($self->{cookie_jar}) { if ($c=$self->getpage(PRIVATE_URL)) { $c=~s/[\r\n\t]//g; - my @msgs=($c=~/message\s+message_id="(\d+)"\s+author="([^\"]+)" +[^>]+>\s*(.*?)\s*<\/message>/g); + my @msgs=($c=~/message[^<]+message_id="(\d+)"[^>]+author="([^\" +]+)"[^>]+>\s*(.*?)\s*<\/message>/g) || + private_swap_order($c=~/message[^<]+author="([^\"]+)"[^>]+ +message_id="(\d+)"[^>]+>\s*(.*?)\s*<\/message>/g); while (@msgs) { my ($mid, $author, $msg)=(shift(@msgs),shift(@msgs),shift(@msg +s)); # Remove html tags @@ -276,6 +278,18 @@ my $substmode=shift; $self->getnewlines(undef,$substmode); return @{$self->{cache_msg}}; +} + + +sub private_swap_order { + my @out; + while (@_) { + my $one = shift; + my $two = shift; + my $three = shift; + push @out, ($two, $one, $three); + } + return @out; } 1; diff -ru ./PerlMonks/Users.pm.orig ./PerlMonks/Users.pm --- ./PerlMonks/Users.pm.orig Mon Sep 4 13:44:10 2000 +++ ./PerlMonks/Users.pm Sat Feb 2 23:39:42 2002 @@ -63,7 +63,8 @@ my $self=shift; if ( (time() - $self->{cache_users_ts}) > USERS_REFRESH) { if (my $c=$self->getpage(USERS_URL)) { - my %users=($c=~/user\s+username="([^\"]+)"\s+user_id="(\d+)"/g) +; + my %users=($c=~/user\s+username="([^\"]+)"\s+user_id="(\d+)"/g) + || + reverse($c=~/user\s+user_id="(\d+)"\s+username="([^\"]+)"/g +); $self->{cache_users}=\%users; $self->{cache_users_ts}=time(); }