At the risk of upsetting the keepers of the "Thou shalt not parse web pages with regular expressions" commandment (who are almost always correct), here is a fragile solution that works, for the sample input you provided and for the web page complete:

use strict; use warnings; use utf8; use feature qw/unicode_strings say/; my $doc = do{ local $/ = undef; <DATA>; }; say GetEmailLink($doc) // 'Unable to parse document.'; sub GetEmailLink { my $document = shift; my %component = fetch_obscured_email($document); return unless keys %component; # Detect and pass along failure to pa +rse. my $link = q(); for( my $i = 0; $i != @{$component{cypher}}; ++$i ) { my $linkChar = $component{cypher}[$i] - $component{key}[$i % @{$co +mponent{key}}]; $link .= chr($linkChar); } return $link; }; sub fetch_obscured_email { my $data = shift; $data =~ m/ SetEmailLink\s*\(\s* # Function name and opening paren +(anchor). [^,]*, # Unwanted first parameter. \s* \[ \s* ( [^]]+ ) \s* \] \s*, # Wanted second parameter. [^,]*, # Unwanted third parameter. \s* \[ \s* ( [^]]+ ) \s* \] \s* # Wanted fourth parameter. \s*\) # Closing paren. /x or return; # Condition: Failure to parse. my( $text_param, $key_param ) = ( $1, $2 ); tr/0-9,//dc for $text_param, $key_param; # Keep only what we need +. return( cypher => [ split /,/, $text_param ], key => [ split /,/, $key_param ] ); } __DATA__ <script type="text/javascript"> //<![CDATA[ jQuery(function () { SetEmailLink('phmain_1_phrightcontent_0_lnkEmail', [113,104,125,164,11 +8,187,87,149,128,146,184,114,53,138,161,112,176,146,143,76,160,188,11 +2,114,121,154,113,190,132,80,112,152], [], [4,7,20,56,2,76,29,34,12,4 +5,83]); });//]]> </script>

Dave


In reply to Re^5: Email - jquery by davido
in thread Email - jquery by bib

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.