Found in /usr/share/perl/5.38/pod/perlfaq5.pod How can I translate tildes (~) in a filename? Use the <> (glob()) operator, documented in perlfunc. Versions of Perl older than 5.6 require that you have a shell installed that groks tildes. Later versions of Perl have this feature built in. The File::KGlob module (available from CPAN) gives more portable glob functionality. Within Perl, you may use this directly: $filename =~ s{ ^ ~ # find a leading tilde ( # save this in $1 [^/] # a non-slash character * # repeated 0 or more times (0 means me) ) }{ $1 ? (getpwnam($1))[7] : ( $ENV{HOME} || $ENV{LOGDIR} ) }ex; How do I close a file descriptor by number? If, for some reason, you have a file descriptor instead of a filehandle (perhaps you used "POSIX::open"), you can use the close() function from the POSIX module: use POSIX (); POSIX::close( $fd ); This should rarely be necessary, as the Perl close() function is to be used for things that Perl opened itself, even if it was a dup of a numeric descriptor as with "MHCONTEXT" above. But if you really have to, you may be able to do this: require './sys/syscall.ph'; my $rc = syscall(SYS_close(), $fd + 0); # must force numeric die "can't sysclose $fd: $!" unless $rc == -1; Or, just use the fdopen(3S) feature of open(): { open my $fh, "<&=$fd" or die "Cannot reopen fd=$fd: $!"; close $fh; }
Generated by phpman v4.12.10 · Markdown · JSON Author: Che Dong Under GNU General Public License
2026-10-20 11:26 @216.73.217.130
CrawledBy Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)