Net::Netrc(3pm)
π Net::Netrc β the OO interface to your netrc file, bestie β¨
okay so real quick: this is a page from the Perl Programmers Reference Guide (yes, the fancy one π). Let's get into it.
πΈ NAME πΈ
Net::Netrc β an OO interface to users' netrc file ποΈβ¨
π¦ SYNOPSIS π¦
use Net::Netrc;
$mach = Net::Netrc->lookup('some.machine');
$login = $mach->login;
($login, $password, $account) = $mach->lpa;
likeβ¦ that's it. that's the whole vibe. π«Ά
π DESCRIPTION π
Net::Netrc is a class that implements a simple interface to the .netrc file β the same one the ftp program uses. iconic behavior honestly π
And get this: Net::Netrc also implements security checks, just like the ftp program does. There are two of them, so listen up π₯:
- the
.netrcfile must be owned by the user, and - the ownership permissions have to be set so that only the owner has read and write access.
π¨ if those conditions are not met, a warning gets output and the .netrc file is not read. no cap, it just refuses. π
π The .netrc File π
The .netrc file holds all the login and initialization info that the auto-login process uses. It lives in the user's home directory. π
These are the tokens it recognizes β and they can be separated by spaces, tabs, or new-lines, so like, format it however, she's flexible β¨:
machine nameβ identifies a remote machine name. The auto-login process searches the.netrcfile for amachinetoken matching the remote machine you specified. Once a match happens, the subsequent.netrctokens get processed, and it stops when it hits end of file, anothermachinetoken, or adefaulttoken. πdefaultβ same deal asmachine name, exceptdefaultmatches any name. There can be only onedefaulttoken, and it must come after all themachinetokens. Normally it's used like this:
default login anonymous password user@site
which gives you automatic anonymous login to machines that aren't specified in .netrc π«Ά
login nameβ identifies a user on the remote machine. If this token is present, the auto-login process will initiate a login using the specified name.password stringβ 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 πaccount stringβ 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.macdef nameβ defines a macro.Net::Netrconly parses this field to be compatible withftp. that's literally all she does with it, don't @ me π
β Class Methods β
okay so 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 π
π lookup($machine[, $login])
Lookup and return a reference to the entry for $machine. If $login is given, then the entry returned will have the given login. If $login is not given, then the first entry in the .netrc file for $machine gets returned. π―
If a matching entry can't be found, and a default entry exists, then a reference to the default entry is returned.
If there's no matching entry found and there's no default defined, or no .netrc file is found, then undef is returned. π
π 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. all three at once, she's efficient π
π§ EXPORTS π§
None. nothing. zero. nada. don't come looking π«
π KNOWN BUGS π
See https://rt.cpan.org/Dist/Display.html?Status=Active&Queue=libnet.
π₯ SEE ALSO π₯
Net::Cmd.
π AUTHOR π
Graham Barr <gbarr@pobox.com <mailto:gbarr@pobox.com>>.
Steve Hay <shay@cpan.org <mailto:shay@cpan.org>> is now maintaining libnet as of version 1.22_02. the torch has been passed π«Ά
π 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 fromperl v5.42.3, dated2026-11-03β so go forth, read your.netrc, keep those perms tight, and slay π π
π¦ where this page comes from
- alpine 3.24: perl-doc 5.42.3-r0 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms