Normal
  5   ˆl–ßi~”Êe¶¥	AãO\d*bÑ¿�þBGY²‰ç„ñi²ùÂƒtN‹ÁÀ¿  7   ˆl–Ãa¾”Ò~êq@µp,Üeµ1hß�þeyÇ–qÀFÜ�¼ÛA ?ŸÃ„q–ßÂÁÀ h    #!/usr/bin/perl -w

# ----------------------------------------------------------------------
# urifind - find URIs in a document and dump them to STDOUT.
# Copyright (C) 2003 darren chamberlain <darren@cpan.org>
# ----------------------------------------------------------------------

use strict;

our $VERSION = 20160806;

use File::Basename qw(basename);
use Getopt::Long qw(GetOptions);
use IO::File;
use URI::Find;
use URI::Find::Schemeless;

# What to do, and how
my $help = 0;
my $version = 0;
my $sort = 0;
my $reverse = 0;
my $unique = 0;
my $prefix = 0;
my $noprefix = 0;
my @pats = ();
my @schemes = ();
my $dump = 0;
my $schemeless = 0;

Getopt::Long::Configure(qw{no_ignore_case bundling});
GetOptions(
    's!'   => \$sort,
    'u!'   => \$unique,
    'p!'   => \$prefix,
    'n!'   => \$noprefix,
    'r!'   => \$reverse,
    'h!'   => \$help,
    'v!'   => \$version,
    'd!'   => sub { $dump = 1 },
    'D!'   => sub { $dump = 2 },
    'P=s@' => \@pats,
    'S=s@' => \@schemes,
    'schemeless!' => \$schemeless,
);

if ($help || $version) {
    my $prog = basename($0);

    if ($help) {
        print <<HELP;
$prog - find URIs in a document and dump them to STDOUT.

    $prog [OPTIONS] file1 [file2[, file3[, ...]]]

Options:

    -s          Sort results.
    -r          Reverse sort results (implies -s).
    -u          Return unique results only.
    -n          Don't include filename in output.
    -p          Include filename in output (0 by default, but 1 if
                multiple files are included on the command line).
    -P \$re      Print only lines matching regex '\$re' 
                (may be specified multiple times).
    -S \$scheme  Only this scheme (may be specified multiple times).
    -h          This help screen.
    -v          Display version and exit.
    -d          Dump compiled regexes and continue.
    -D          Dump compiled regexes and exit.

HELP
    }
    else {
        printf "$prog v.%.02f\n", $VERSION;
    }

    exit(0);
}

my (@uris, $count);
unshift @ARGV, \*STDIN unless @ARGV;

if (($prefix + $noprefix) > 1) {
    my $prog = basename $0;
    die "Can't specify -p and -n at the same time; try $prog -h\n";
}


# Print filename with matches?  -p / -n
# If there is more than one file, then show filenames by
# default, unless explicitly asked not to (-n)
if (@ARGV > 1) {
    $prefix = 1 unless $noprefix;
}
else {
    $prefix = 0 unless $prefix;
}

# Add schemes to the list of regexen
if (@schemes) {
    unshift @pats => sprintf '^(\b%s\b):' => join '\b|\b' => @schemes;
}

# If we are dumping (-d, -D), then dump.  Exit if -D.
if ($dump) {
    print STDERR "\$scheme = '" . (defined $pats[0] ? $pats[0] : '') . "'\n";
    print STDERR "\@pats = ('" . join("', '", @pats) . "')\n";
    exit if $dump == 2;
}

# Find the URIs
for my $argv (@ARGV) {
    my ($name, $fh, $data);

    $argv = \*STDIN if ($argv eq '-');

    if (ref $argv eq 'GLOB') {
        local $/;
        $data = <$argv>;
        $name = '<stdin>'
    }
    else {
        local $/;
        $fh = IO::File->new($argv) or die "Can't open $argv: $!";
        $data = <$fh>;
        $name = $argv;
    }

    my $class = $schemeless ? "URI::Find::Schemeless" : "URI::Find";
    my $finder = $class->new(sub { push @uris => [ $name, $_[0] ] });
    $finder->find(\$data);
}

# Apply patterns, in @pats
for my $pat (@pats) {
    @uris = grep { $_->[1] =~ /$pat/ } @uris;
}

# Remove redundant links
if ($unique) {
    my %unique;
    @uris = grep { ++$unique{$_->[1]} == 1 } @uris;
}

# Sort links, possibly in reverse
if ($sort || $reverse) {
    if ($reverse) {
        @uris = sort { $b->[1] cmp $a->[1] } @uris;
    }
    else {
        @uris = sort { $a->[1] cmp $b->[1] } @uris;
    }
}

# Flatten the arrayrefs
if ($prefix) {
    @uris = map { join ': ' => @$_ } @uris;
}
else {
    @uris = map { $_->[1] } @uris;
}

print map { "$_\n" } @uris;

exit 0;

__END__

=head1 NAME

urifind - find URIs in 