Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: PerlMonks modules 2.0

by wmono (Friar)
on Feb 03, 2002 at 08:02 UTC ( #143040=note: print w/replies, xml ) Need Help??


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(); }

Replies are listed 'Best First'.
(tye)Re: PerlMonks modules 2.0
by tye (Sage) on Mar 10, 2002 at 06:24 UTC

    Actually, it isn't so much code...

    my $attr= qr/(\w+)="([^"]+)"/; my $attrs= /<message(\s+$attr)*>/; my %hash; while( $attrs =~ /$attr/g ) { $hash{$1}= $2; } $hash{user_id}...
    But {NULE} requested that I post it here.

            - tye (but my friends call me "Tye")

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://143040]
help
Chatterbox?
[thao4]: thao4
[hippo]: Indeed you are.
[thao4]: Hi all, I am new in perl. I need do somthing in perl: exemple: - search a patern "CADRE 1.1 CPU" in one file.txt - incremente +30 lines from the line with the patern found - replace the patern "Model Regle" by "Heath Rule A" in this new line (30 line
[marto]: good morning all
[hippo]: Welcome. Tell me, have you read perlintro? That's a great place to start.
[thao4]: I seach to do that since a week but I can't found the answer in google. Thank for your help

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (10)
As of 2018-02-21 09:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When it is dark outside I am happiest to see ...














    Results (276 votes). Check out past polls.

    Notices?