Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Random Darwin Award in plain text

by willyyam (Priest)
on Mar 29, 2006 at 16:35 UTC ( [id://540001]=note: print w/replies, xml ) Need Help??


in reply to Random Darwin Award in plain text

I quite like this, thank you. I find that not all entries have a trailing newline, so I added this to the code before the print statement: $content = $content . "\n";

Is there a way to run fmt -72 or something similar on this text block to have it break the lines neatly?

Replies are listed 'Best First'.
Re^2: Random Darwin Award in plain text
by codeacrobat (Chaplain) on Mar 29, 2006 at 23:15 UTC
    Ah good idea. About the formatting:
    perl darwin.pl | fmt -72
    would do it.

    A perl only solution could use Text::Wrap:
    #!/usr/bin/perl -w use strict; use WWW::Mechanize; use Data::Dumper; use Text::Wrap qw(wrap); my $agent = WWW::Mechanize->new( autocheck => 1 ); $agent->get('http://cgi.darwinawards.com/cgi/random.pl'); my $content = $agent->content( format => "text" ); my $cr = chr 169; $content =~ s/.*\d\d\s+Urban Legend//s; $content =~ s/.*\d\d\s+Personal Account//s; $content =~ s/.*Reader Submission\s+Pending Acceptance//s; $content =~ s/\s*DarwinAwards\.com\s*$cr.*//s; $content =~ s/.*?\([^\)]*?\d{2}[^\)]*\) //s; $content =~ s/.*Darwin\s?Award\s?Nominee//si; $content =~ s/.*Confirmed \S+\s?by Darwin//si; $content =~ s/.*Honorable Mentions//s; $content =~ s/submitted by.*//si; $content =~ s/109876543210.*//s; $content =~ s/^\s+//; print wrap("\t", "", "$content\n");

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://540001]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (2)
As of 2024-04-25 20:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found