📄 functions.pm
字号:
package Pod::Functions;use strict;=head1 NAMEPod::Functions - Group Perl's functions a la perlfunc.pod=head1 SYNOPSIS use Pod::Functions; my @misc_ops = @{ $Kinds{ 'Misc' } }; my $misc_dsc = $Type_Description{ 'Misc' };or perl /path/to/lib/Pod/Functions.pmThis will print a grouped list of Perl's functions, like the L<perlfunc/"Perl Functions by Category"> section.=head1 DESCRIPTIONIt exports the following variables:=over 4=item %KindsThis holds a hash-of-lists. Each list contains the functions in the categorythe key denotes.=item %TypeIn this hash each key represents a function and the value is the category.The category can be a comma separated list.=item %FlavorIn this hash each key represents a function and the value is a short description of that function.=item %Type_DescriptionIn this hash each key represents a category of functions and the value is a short description of that category.=item @Type_OrderThis list of categories is used to produce the same order as theL<perlfunc/"Perl Functions by Category"> section.=back=head1 CHANGES1.02 20020813 <abe@ztreet.demon.nl> de-typo in the SYNOPSIS section (thanks Mike Castle for noticing)1.01 20011229 <abe@ztreet.demon.nl> fixed some bugs that slipped in after 5.6.1 added the pod finished making it strict safe1.00 ?? first numbered version=cutour $VERSION = '1.03';require Exporter;our @ISA = qw(Exporter);our @EXPORT = qw(%Kinds %Type %Flavor %Type_Description @Type_Order);our(%Kinds, %Type, %Flavor);our %Type_Description = ( 'ARRAY' => 'Functions for real @ARRAYs', 'Binary' => 'Functions for fixed length data or records', 'File' => 'Functions for filehandles, files, or directories', 'Flow' => 'Keywords related to control flow of your perl program', 'HASH' => 'Functions for real %HASHes', 'I/O' => 'Input and output functions', 'LIST' => 'Functions for list data', 'Math' => 'Numeric functions', 'Misc' => 'Miscellaneous functions', 'Modules' => 'Keywords related to perl modules', 'Network' => 'Fetching network info', 'Objects' => 'Keywords related to classes and object-orientedness', 'Process' => 'Functions for processes and process groups', 'Regexp' => 'Regular expressions and pattern matching', 'Socket' => 'Low-level socket functions', 'String' => 'Functions for SCALARs or strings', 'SysV' => 'System V interprocess communication functions', 'Time' => 'Time-related functions', 'User' => 'Fetching user and group info', 'Namespace' => 'Keywords altering or affecting scoping of identifiers',);our @Type_Order = qw{ String Regexp Math ARRAY LIST HASH I/O Binary File Flow Namespace Misc Process Modules Objects Socket SysV User Network Time};while (<DATA>) { chomp; s/#.*//; next unless $_; my($name, $type, $text) = split " ", $_, 3; $Type{$name} = $type; $Flavor{$name} = $text; for my $t ( split /[,\s]+/, $type ) { push @{$Kinds{$t}}, $name; }}close DATA;my( $typedesc, $list );unless (caller) { foreach my $type ( @Type_Order ) { $list = join(", ", sort @{$Kinds{$type}}); $typedesc = $Type_Description{$type} . ":"; write; } }format = ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $typedesc ~~ ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $typedesc ~~ ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $list.1;__DATA__-X File a file test (-r, -x, etc)abs Math absolute value functionaccept Socket accept an incoming socket connectalarm Process schedule a SIGALRM atan2 Math arctangent of Y/X in the range -PI to PIbind Socket binds an address to a socketbinmode I/O prepare binary files for I/Obless Objects create an object caller Flow,Namespace get context of the current subroutine callchdir File change your current working directorychmod File changes the permissions on a list of fileschomp String remove a trailing record separator from a stringchop String remove the last character from a stringchown File change the owership on a list of fileschr String get character this number representschroot File make directory new root for path lookupsclose I/O close file (or pipe or socket) handleclosedir I/O close directory handleconnect Socket connect to a remote socketcontinue Flow optional trailing block in a while or foreach cos Math cosine functioncrypt String one-way passwd-style encryptiondbmclose Objects,I/O breaks binding on a tied dbm filedbmopen Objects,I/O create binding on a tied dbm filedefined Misc test whether a value, variable, or function is defineddelete HASH deletes a value from a hashdie I/O,Flow raise an exception or bail outdo Flow,Modules turn a BLOCK into a TERMdump Misc,Flow create an immediate core dumpeach HASH retrieve the next key/value pair from a hashendgrent User be done using group fileendhostent User be done using hosts fileendnetent User be done using networks fileendprotoent Network be done using protocols fileendpwent User be done using passwd fileendservent Network be done using services fileeof I/O test a filehandle for its endeval Flow,Misc catch exceptions or compile and run codeexec Process abandon this program to run anotherexists HASH test whether a hash key is presentexit Flow terminate this programexp Math raise I<e> to a powerfcntl File file control system callfileno I/O return file descriptor from filehandleflock I/O lock an entire file with an advisory lockfork Process create a new process just like this oneformat I/O declare a picture format with use by the write() functionformline Misc internal function used for formatsgetc I/O get the next character from the filehandlegetgrent User get next group record getgrgid User get group record given group user IDgetgrnam User get group record given group namegethostbyaddr Network get host record given its addressgethostbyname Network get host record given namegethostent Network get next hosts record getlogin User return who logged in at this ttygetnetbyaddr Network get network record given its addressgetnetbyname Network get networks record given namegetnetent Network get next networks record getpeername Socket find the other end of a socket connectiongetpgrp Process get process groupgetppid Process get parent process IDgetpriority Process get current nice valuegetprotobyname Network get protocol record given namegetprotobynumber Network get protocol record numeric protocolgetprotoent Network get next protocols recordgetpwent User get next passwd recordgetpwnam User get passwd record given user login namegetpwuid User get passwd record given user IDgetservbyname Network get services record given its namegetservbyport Network get services record given numeric portgetservent Network get next services record getsockname Socket retrieve the sockaddr for a given socketgetsockopt Socket get socket options on a given socketglob File expand filenames using wildcardsgmtime Time convert UNIX time into record or string using Greenwich timegoto Flow create spaghetti codegrep LIST locate elements in a list test true against a given criterionhex Math,String convert a string to a hexadecimal numberimport Modules,Namespace patch a module's namespace into your ownindex String find a substring within a stringint Math get the integer portion of a numberioctl File system-dependent device control system calljoin LIST join a list into a string using a separatorkeys HASH retrieve list of indices from a hashkill Process send a signal to a process or process grouplast Flow exit a block prematurelylc String return lower-case version of a stringlcfirst String return a string with just the next letter in lower caselength String return the number of bytes in a stringlink File create a hard link in the filesytemlisten Socket register your socket as a server local Misc,Namespace create a temporary value for a global variable (dynamic scoping)localtime Time convert UNIX time into record or string using local timelock Threads get a thread lock on a variable, subroutine, or methodlog Math retrieve the natural logarithm for a numberlstat File stat a symbolic linkm// Regexp match a string with a regular expression patternmap LIST apply a change to a list to get back a new list with the changesmkdir File create a directorymsgctl SysV SysV IPC message control operationsmsgget SysV get SysV IPC message queuemsgrcv SysV receive a SysV IPC message from a message queuemsgsnd SysV send a SysV IPC message to a message queuemy Misc,Namespace declare and assign a local variable (lexical scoping)next Flow iterate a block prematurelyno Modules unimport some module symbols or semantics at compile timepackage Modules,Objects,Namespace declare a separate global namespaceprototype Flow,Misc get the prototype (if any) of a subroutineoct String,Math convert a string to an octal numberopen File open a file, pipe, or descriptoropendir File open a directoryord String find a character's numeric representationour Misc,Namespace declare and assign a package variable (lexical scoping)pack Binary,String convert a list into a binary representationpipe Process open a pair of connected filehandlespop ARRAY remove the last element from an array and return itpos Regexp find or set the offset for the last/next m//g searchprint I/O output a list to a filehandleprintf I/O output a formatted list to a filehandlepush ARRAY append one or more elements to an arrayq/STRING/ String singly quote a stringqq/STRING/ String doubly quote a stringquotemeta Regexp quote regular expression magic charactersqw/STRING/ LIST quote a list of wordsqx/STRING/ Process backquote quote a stringqr/STRING/ Regexp Compile pattern rand Math retrieve the next pseudorandom number read I/O,Binary fixed-length buffered input from a filehandlereaddir I/O get a directory from a directory handlereadline I/O fetch a record from a filereadlink File determine where a symbolic link is pointingreadpipe Process execute a system command and collect standard outputrecv Socket receive a message over a Socketredo Flow start this loop iteration over againref Objects find out the type of thing being referencedrename File change a filenamerequire Modules load in external functions from a library at runtimereset Misc clear all variables of a given namereturn Flow get out of a function earlyreverse String,LIST flip a string or a listrewinddir I/O reset directory handlerindex String right-to-left substring searchrmdir File remove a directorys/// Regexp replace a pattern with a stringscalar Misc force a scalar contextseek I/O reposition file pointer for random-access I/Oseekdir I/O reposition directory pointer select I/O reset default output or do I/O multiplexingsemctl SysV SysV semaphore control operationssemget SysV get set of SysV semaphoressemop SysV SysV semaphore operationssend Socket send a message over a socketsetgrent User prepare group file for usesethostent Network prepare hosts file for usesetnetent Network prepare networks file for usesetpgrp Process set the process group of a processsetpriority Process set a process's nice valuesetprotoent Network prepare protocols file for usesetpwent User prepare passwd file for usesetservent Network prepare services file for usesetsockopt Socket set some socket optionsshift ARRAY remove the first element of an array, and return itshmctl SysV SysV shared memory operationsshmget SysV get SysV shared memory segment identifiershmread SysV read SysV shared memory shmwrite SysV write SysV shared memory shutdown Socket close down just half of a socket connectionsin Math return the sine of a numbersleep Process block for some number of secondssocket Socket create a socketsocketpair Socket create a pair of socketssort LIST sort a list of values splice ARRAY add or remove elements anywhere in an arraysplit Regexp split up a string using a regexp delimitersprintf String formatted print into a string sqrt Math square root functionsrand Math seed the random number generatorstat File get a file's status informationstudy Regexp optimize input data for repeated searchessub Flow declare a subroutine, possibly anonymouslysubstr String get or alter a portion of a stirngsymlink File create a symbolic link to a filesyscall I/O,Binary execute an arbitrary system callsysopen File open a file, pipe, or descriptorsysread I/O,Binary fixed-length unbuffered input from a filehandlesysseek I/O,Binary position I/O pointer on handle used with sysread and syswritesystem Process run a separate program syswrite I/O,Binary fixed-length unbuffered output to a filehandletell I/O get current seekpointer on a filehandletelldir I/O get current seekpointer on a directory handletie Objects bind a variable to an object class tied Objects get a reference to the object underlying a tied variabletime Time return number of seconds since 1970times Process,Time return elapsed time for self and child processestr/// String transliterate a stringtruncate I/O shorten a fileuc String return upper-case version of a stringucfirst String return a string with just the next letter in upper caseumask File set file creation mode maskundef Misc remove a variable or function definitionunlink File remove one link to a fileunpack Binary,LIST convert binary structure into normal perl variablesunshift ARRAY prepend more elements to the beginning of a listuntie Objects break a tie binding to a variableuse Modules,Namespace load a module and import its namespaceuse Objects load in a module at compile timeutime File set a file's last access and modify timesvalues HASH return a list of the values in a hashvec Binary test or set particular bits in a stringwait Process wait for any child process to diewaitpid Process wait for a particular child process to diewantarray Misc,Flow get void vs scalar vs list context of current subroutine callwarn I/O print debugging infowrite I/O print a picture recordy/// String transliterate a string
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -