NAME

Duadua - Detect User-Agent, do up again!

SYNOPSIS

    use Duadua;

    my $ua = 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)';

    my $d = Duadua->new($ua);
    $d->is_bot
        and say $d->name; # Googlebot

Or call as a function to parse immediately

    my $d = Duadua->parse($ua);
    $d->is_bot
        and say $d->name; # Googlebot

And it's able to accept an object like HTTP::Headers instead of user-agent string.

    use HTTP::Headers;
    use Duadua;

    my $headers = HTTP::Headers->new(
        'User_Agent' => 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)'
    );

    my $d = Duadua->new($headers);
    $d->is_bot
        and say $d->name; # Googlebot

NOTE that an object class should be HTTP::Headers[::*], and it should have a method `header` to get specific HTTP-Header.

If you would like to parse many times, then you can use reparse method. It's fast.

    my $d = Duadua->new;
    for my $ua (@ua_list) {
        my $result = $d->reparse($ua);
        $result->is_bot
            and say $result->name;
    }

If you need to get version info, then you should set true value to version option like below.

    use Duadua;

    my $ua = 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)';
    my $d = Duadua->new($ua, { version => 1 });
    say $d->version; # 2.1

DESCRIPTION

Duadua is a User-Agent detector.

METHODS

new($user_agent_string, $options_hash)

constructor

Constructor options

version => 1 or 0

If you set the true value to version, then you can get version string. (By default, don't get version)

skip => ['ParserClass']

If you set the array to skip, then you can skip detect logic by specific classes.

NOTE that ParserClass is case sensitive, and it might be going to change results.

parse

Parses User-Agent string

reparse($ua)

Parses User-Agent string by same instance without new

GETTERS

ua

Returns raw User-Agent string

name

Gets User-Agent name

is_bot

Returns true value if the User-Agent is bot.

is_ios

Returns true value if the User-Agent is iOS.

is_android

Returns true value if the User-Agent is Android.

is_linux

Returns true value if the User-Agent is Linux.

is_windows

Returns true value if the User-Agent is Windows.

is_chromeos

Returns true value if the User-Agent is ChromeOS.

opt_version

Returns version option value. If it's true value, then parse to get User Agent version also.

version

Returns version from user agent string

parsers

The list of User Agent Parser

REPOSITORY

Duadua is hosted on github: http://github.com/bayashi/Duadua

I appreciate any feedback :D

AUTHOR

Dai Okabayashi <bayashi@cpan.org>

LICENSE

Duadua is free software; you can redistribute it and/or modify it under the terms of the Artistic License 2.0. (Note that, unlike the Artistic License 1.0, version 2.0 is GPL compatible by itself, hence there is no benefit to having an Artistic 2.0 / GPL disjunction.) See the file LICENSE for details.