use FileHandle;
use vars qw($VERSION);
-$VERSION = "2.10"; # $Id: //depot/libnet/Net/Netrc.pm#4$
+$VERSION = "2.12"; # $Id: //depot/libnet/Net/Netrc.pm#13 $
my %netrc = ();
{
my $host = shift;
my($home,$file);
-
+
if($^O eq "MacOS") {
$home = $ENV{HOME} || `pwd`;
chomp($home);
} else {
# Some OS's don't have `getpwuid', so we default to $ENV{HOME}
$home = eval { (getpwuid($>))[7] } || $ENV{HOME};
+ $home ||= $ENV{HOMEDRIVE} . ($ENV{HOMEPATH}||'') if defined $ENV{HOMEDRIVE};
$file = $home . "/.netrc";
}
$netrc{default} = undef;
# OS/2 and Win32 do not handle stat in a way compatable with this check :-(
- unless($^O eq 'os2' || $^O eq 'MSWin32' || $^O eq 'MacOS')
+ unless($^O eq 'os2'
+ || $^O eq 'MSWin32'
+ || $^O eq 'MacOS'
+ || $^O =~ /^cygwin/)
{
my @stat = stat($file);
s/^\s*//;
chomp;
- push(@tok, $+)
- while(length && s/^("([^"]*)"|(\S+))\s*//);
+
+ while(length && s/^("((?:[^"]+|\\.)*)"|((?:[^\\\s]+|\\.)*))\s*//) {
+ (my $tok = $+) =~ s/\\(.)/$1/g;
+ push(@tok, $tok);
+ }
TOKEN:
while(@tok)
=head1 SYNOPSIS
use Net::Netrc;
-
+
$mach = Net::Netrc->lookup('some.machine');
$login = $mach->login;
($login, $password, $account) = $mach->lpa;
If a matching entry cannot be found, and a default entry exists, then a
reference to the default entry is returned.
+If there is no matching entry found and there is no default defined, or
+no .netrc file is found, then C<undef> is returned.
+
=back
=head1 METHODS
This program is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
+=for html <hr>
+
+$Id: //depot/libnet/Net/Netrc.pm#13 $
+
=cut