File: dump.pl

package info (click to toggle)
libparse-http-useragent-perl 0.43-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 668 kB
  • sloc: perl: 2,392; makefile: 7
file content (41 lines) | stat: -rw-r--r-- 831 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env perl -w
# (c) 2009 Burak Gursoy. Distributed under the Perl License.
# Enables internal pre-parsed structure dumper and then dumps
#    the parsed structure.
use strict;
use vars qw( $VERSION );
use warnings;
use lib qw( ../lib lib );
use Getopt::Long;

$VERSION = '0.11';

my $timediff;
BEGIN {
    *Parse::HTTP::UserAgent::DEBUG = sub () { 1 };
    eval {
        require Time::HiRes;
        Time::HiRes->import('time');
        $timediff = 1;
    };
}

GetOptions(\my %arg, qw(
    normalize
));

use Parse::HTTP::UserAgent;

my $opt = {};
$opt->{normalize} = ':all' if $arg{normalize};

my $str = shift || die "UserAgent?\n";

my $start = time;
my $ua    = Parse::HTTP::UserAgent->new( $str, $opt );
my $end   = time;

print $ua->dumper;
if ( $timediff ) {
    printf "\nTook %.5f seconds.\n", $end - $start;
}