Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

warnings are lexically scoped so, for that solution to work you'd need to modify JavaFan was spot on (below) - if you're interested, check the Parse::HTTP::UserAgent source code: in sub _numify you'll find the line my $rv = version->new("$v")->numify;.

Anyway, not being someone who likes to be beaten by zeros and ones, here's a workaround. Before the line:

my $ua = Parse::HTTP::UserAgent->new($useragent);


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

I ran a few tests with this and it seems to work fine. The test code and output is below (click on Read more...).

Test code:

#!perl use strict; use warnings; use Parse::HTTP::UserAgent; my @useragent_list = ( q{Mozilla/4.06+[en]+(WinNT;+I)}, q{Opera/9.80 (Windows NT 5.1; U; en) Presto/2.6.30 Version/10.61}, q{Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv: Geck +o/20091016 Firefox/3.5.4}, q{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}, ); for my $useragent (@useragent_list) { print q{UA: }, $useragent, qq{\n}; $useragent =~ s{ ( [+] ) [[] [^]]+ []] ( [+] ) }{$1$2}msx; my $ua = Parse::HTTP::UserAgent->new($useragent); print $ua->name, qq{\n}; print $ua->version, qq{\n}; print $ua->os, qq{\n}; }


$ 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: 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

-- Ken

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

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others romping around the Monastery: (6)
    As of 2018-06-21 03:36 GMT
    Find Nodes?
      Voting Booth?
      Should cpanminus be part of the standard Perl release?

      Results (117 votes). Check out past polls.