<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">package CPAN::FTP::netrc;
use strict;

$CPAN::FTP::netrc::VERSION = $CPAN::FTP::netrc::VERSION = "1.01";

# package CPAN::FTP::netrc;
sub new {
    my($class) = @_;
    my $file = File::Spec-&gt;catfile($ENV{HOME},".netrc");

    my($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
       $atime,$mtime,$ctime,$blksize,$blocks)
        = stat($file);
    $mode ||= 0;
    my $protected = 0;

    my($fh,@machines,$hasdefault);
    $hasdefault = 0;
    $fh = FileHandle-&gt;new or die "Could not create a filehandle";

    if($fh-&gt;open($file)) {
        $protected = ($mode &amp; 077) == 0;
        local($/) = "";
      NETRC: while (&lt;$fh&gt;) {
            my(@tokens) = split " ", $_;
          TOKEN: while (@tokens) {
                my($t) = shift @tokens;
                if ($t eq "default") {
                    $hasdefault++;
                    last NETRC;
                }
                last TOKEN if $t eq "macdef";
                if ($t eq "machine") {
                    push @machines, shift @tokens;
                }
            }
        }
    } else {
        $file = $hasdefault = $protected = "";
    }

    bless {
        'mach' =&gt; [@machines],
        'netrc' =&gt; $file,
        'hasdefault' =&gt; $hasdefault,
        'protected' =&gt; $protected,
    }, $class;
}

# CPAN::FTP::netrc::hasdefault;
sub hasdefault { shift-&gt;{'hasdefault'} }
sub netrc      { shift-&gt;{'netrc'}      }
sub protected  { shift-&gt;{'protected'}  }
sub contains {
    my($self,$mach) = @_;
    for ( @{$self-&gt;{'mach'}} ) {
        return 1 if $_ eq $mach;
    }
    return 0;
}

1;
</pre></body></html>