For my tests, I used the problem string you posted then added three more from browsers I had handy on my PC. I notice that the Firefox one you've now posted has "+" characters in every position that mine has spaces (ignoring a few minor variations in version numbers). I took mine directly from the browsers; it occurred to me that may yours are perhaps URL-encoded (while you can represent a space as hex %20, it can also just be converted to a plus-sign).

So, I added your latest problem string to my existing test list and changed:

$useragent =~ s{ ( [+] ) [[] [^]]+ []] ( [+] ) }{$1$2}msx;

to just:

$useragent =~ y{+}{ };

And it all worked! :-)

$ ver_overload_prob.pl UA: Mozilla/4.06+[en]+(WinNT;+I) Netscape 4.060 Windows NT UA: Opera/9.80 (Windows NT 5.1; U; en) Presto/2.6.30 Version/10.61 Opera 10.610 Windows XP UA: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.1.4) Gecko/ +20091016 Firefox/3.5.4 Firefox 3.005004 Windows XP UA: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.28 + (KHTML, like Gecko) Version/3.2.2 Safari/525.28.1 Safari 3.002002 Windows XP UA: Mozilla/5.0+(Windows;+U;+Windows+NT+5.1;+en-US;+rv:1.9.1.15)+Gecko +/20101026+Firefox/3.5.15+(.NET+CLR+3.5.30729) Firefox 3.005015 Windows XP

So, give that a go - it might be the solution.

If not, you can redirect STDERR (see open - example code is about halfway down the page) but you'll lose every error message by doing that and I really wouldn't recommend it.

In the _numify() routine (referenced in my last post) pluses are actually removed (see final alternation item):

$v =~ s{ pre | rel | alpha | beta | \-stable | gold | [ab]\d+ | a\-XXXX | \+ }{}xmsig;

So, if my solution works, you might want to post a bug report with the fix being:

$v =~ y{+}{ }; $v =~ s{ pre | rel | alpha | beta | \-stable | gold | [ab]\d+ | a\-XXXX }{}xmsig;

-- Ken


In reply to Re^5: Need to turn off prints from module by kcott
in thread Need to turn off prints from module by Mushka

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.