##################################### # PLAY WITH THE PERLMONKS SITE (1). # ##################################### use LWP::Simple ; $|=1; my $node = '185131' ; my $url = "http://www.perlmonks.org/index.pl?node_id=$node" ; if ($node =~ /^http:\/\//) { $url = $node ;} print "Getting node $node...\n" ; print "$url\n" ; $html = get($url); my $lng = length($html) ; print "$lng bytes.\n\n" ; $html =~ s/\r\n?/\n/gs ; my (@codes) = ( $html =~ /<pre><tt><font.*?>(.*?)<\/font><\/tt><\/pre> +/gsi ); foreach my $code ( @codes ) { $code =~ s/\n<font.*?>\+<\/font>//gi ; $code = filter_from_html($code) ; print "# CODE #################################################\n" if ($#codes > 0) ; print "$code\n" ; } #################### # FILTER_FROM_HTML # #################### sub filter_from_html { my ( $code ) = @_ ; my %SYMBOLS_html = ( 'acute' => 'aeiouAEIOU#áéíóúÁÉÍÓÚ' , 'grave' => 'aeiouAEIOU#àèìòùÀÈÌÒÙ' , 'circ' => 'aeiouAEIOU#âêîôûÂÊÎÔÛ' , 'uml' => 'aeiouAEIOU#äëïöüÄËÏÖÜ' , 'tilde' => 'aoAO#ãõÃÕ' , 'cedil' => 'cC#çÇ' , 'lt' => '#<' , 'gt' => '#>' , 'quot' => '#"' , ) ; $code =~ s/&#(\d{1,3});/pack("C",$1)/eg; $code =~ s/&amp;?/&/gsi ; $code =~ s/&nbsp;?/ /gsi ; my ($start,$end,@letras1,@letras2,$max); foreach my $Key ( keys %SYMBOLS_html ) { ($start , $end) = split('#' , $SYMBOLS_html{$Key}) ; @letras1 = split('' , $start) ; @letras2 = split('' , $end) ; $max = $#letras1 ; if ($#letras2 > $max) { $max = $#letras2 ;} for(0..$max) { $code =~ s/\&$letras1[$_](?i:$Key);?/$letras2[$_]/g ; } } return( $code ) ; } ####### # END # #######

# Send your feedback!
#
# "The creativity is the expression of the liberty".

In reply to Playing with PerlMonks site (1) - Copy a CODE without the '+' by gmpassos

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.