Net::Netrc(3perl)
β¨ Net::Netrc β¨
okay bestie, gather round, because this is the little module that reads your .netrc file so you don't have to hand over your passwords like a chump π it lives in the Perl Programmers Reference Guide and it is genuinely so useful, i'm obsessed.
π NAME
Net::Netrc β an OO interface to users' .netrc file. that's it, that's the vibe. object-oriented, lowkey iconic, no cap. π
πΈ SYNOPSIS
here's the whole vibe in four lines, literally:
use Net::Netrc;
$mach = Net::Netrc->lookup('some.machine');
$login = $mach->login;
($login, $password, $account) = $mach->lpa;
π¦ DESCRIPTION
so Net::Netrc is a class that gives you a super simple interface to the .netrc file β the same file the ftp program uses. yes, that ftp. the ancient one. it still eats, okay? π
Net::Netrc also implements security checks exactly like the ftp program does, and bestie, listen up because these matter:
- the
.netrcfile must be owned by the user, and - the ownership permissions should be such that only the owner has read and write access.
if those conditions are not met, a warning is output and the .netrc file is not read. periodt. π¨
The .netrc File
the .netrc file is where login and initialization info lives for the auto-login process. it resides in the user's home directory. these are the tokens it recognizes β and they can be separated by spaces, tabs, or new-lines, so go wild with your whitespace β¨
machinename β identifies a remote machine name. the auto-login process searches the.netrcfile for amachinetoken that matches the remote machine specified. once a match is made, the subsequent.netrctokens are processed, stopping when the end of file is reached or anothermachineor adefaulttoken is encountered. slay, that's the whole search algorithm π«Άdefaultβ this is the same asmachine nameexcept thatdefaultmatches any name. there can be only onedefaulttoken, and it must be after allmachinetokens. normally it's used like this:
default login anonymous password user@site
thereby giving the user automatic anonymous login to machines not specified in .netrc. iconic behaviour honestly π
loginname β identifies a user on the remote machine. if this token is present, the auto-login process will initiate a login using the specified name.passwordstring β supplies a password. if this token is present, the auto-login process will supply the specified string if the remote server requires a password as part of the login process. πaccountstring β supplies an additional account password. if this token is present, the auto-login process will supply the specified string if the remote server requires an additional account password.macdefname β defines a macro.Net::Netrconly parses this field to be compatible withftp. it does not do anything else with it, bestie, don't get your hopes up π
π§ Class Methods
the constructor for a Net::Netrc object is not called new, because it doesn't really create a new object. instead it's called lookup, becauseβ¦ that's essentially what it does. main character naming energy, honestly π
lookup($machine[, $login])β lookup and return a reference to the entry for$machine. if$loginis given then the entry returned will have the given login. if$loginis not given then the first entry in the.netrcfile for$machinewill be returned.
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 undef is returned. so always check for undef, bestie, i'm begging π
π Object Methods
login()β return the login id for the netrc entry β¨password()β return the password for the netrc entry πaccount()β return the account information for the netrc entry πlpa()β return a list of login, password and account information for the netrc entry. three for one, we love a bundle π
π EXPORTS
None.
as in zero. nothing. she exports nothing and she's not sorry. β
π KNOWN BUGS
see https://rt.cpan.org/Dist/Display.html?Status=Active&Queue=libnet β go file things there if something's cursed, bestie π
π SEE ALSO
Net::Cmd.
π©· AUTHOR
Graham Barr β Graham Barr <gbarr@pobox.com>.
Steve Hay β Steve Hay <shay@cpan.org> β is now maintaining libnet as of version 1.22_02. passing the torch, we love to see it π«Ά
π COPYRIGHT
Copyright (C) 1995-1998 Graham Barr. All rights reserved.
Copyright (C) 2013-2014, 2020 Steve Hay. All rights reserved.
π LICENCE
this module is free software; you can redistribute it and/or modify it under the same terms as Perl itself, i.e. under the terms of either the GNU General Public License or the Artistic License, as specified in the LICENCE file.
β VERSION
Version 3.15.
πΈ DATE
20 March 2023.
π¦ HISTORY
see the Changes file.
and that's the whole page, bestie π this one's from perl v5.44.0, dated 2026-10-17, and it's the Net::Netrc(3perl) man page β read it, love it, keep your .netrc chmod'd correctly or she simply will not read it. no cap. πβ¨
π¦ where this page comes from
- arch rolling: perl 5.44.0-1 Β· Artistic-1.0-Perl AND GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms