Tải bản đầy đủ - 0 (trang)
Appendix A. Perl Built-ins, Pragmas, Modules, and the Debugger

Appendix A. Perl Built-ins, Pragmas, Modules, and the Debugger

Tải bản đầy đủ - 0trang

socketfunction,isboundto

anaddress,andislistening

foraconnection.

NEWSOCKETisafilehandle

withthesamepropertiesas

GENERICSOCKET.Theaccept

functionattaches

GENERICSOCKETtothenewly

madeconnection.

Seeaccept(2).

alarm



alarm(SECONDS)

alarmSECONDS

SendsaSIGALARMsignalto

theprocessafteranumberof

SECONDS.

Seealarm(3).



atan2



atan2(X,Y)Returnsthe

arctangentofX/Yintherange

.



bind



bind(SOCKET,NAME)

Bindsanaddress,NAME,toan

alreadyopenedunnamed

socket,SOCKET.

Seebind(2).



binmode



binmode(FILEHANDLE)

binmodeFILEHANDLE

Foroperatingsystemsthat

distinguishbetweentextand

"binary"mode(notUNIX).

PreparestheFILEHANDLEfor



readinginbinarymode.

bless



bless(REFERENCE,CLASS)

blessREFERENCE

Tellstheobjectreferencedby

REFERENCEthatitisanobject

inapackage(CLASS)inthe

currentpackageifnoCLASS

isspecified.Returnsthe

reference.



caller



caller(EXPR)

callerEXPR

caller

Returnsanarraywith

informationaboutthe

subroutinecallstack,

includingthepackage,

filename,andlinenumber.

WithEXPR,anumber,the

functionseeksbackwardEXPR

stackframesbeforethe

currentone.



chdir



chdir(EXPR)

chdirEXPR

chdir

Changesthepresentworking

directorytoEXPR.IfEXPRis

omitted,changesdirectoryto

homedirectory.

Seechdir(2).



chmod



chmod(MODE,LIST)



chmodMODE,LIST

Changespermissionsofalist

offiles;firstargumentisthe

permissionMODEnumber

(octal);theremaining

argumentsarealistof

filenames.Returnsthe

numberoffileschanged.

Seechmod(2).

chomp



chomp(LIST)

chomp(VARIABLE)

chompVARIABLE

chomp

Chopsoffthelastcharacterof

astring,VARIABLE,orthelast

characterofeachitemina

LISTifthatcharacter

correspondstothecurrent

valueof$/,whichisby

defaultsettothenewline.

Unlikechop(seefollowing),it

returnsthenumberof

charactersdeleted.



chop



chop(LIST)

chop(VARIABLE)

chopVARIABLE

chop

Chopsoffthelastcharacterof

astring,VARIABLE,orthelast



characterofeachitemina

LISTandreturnsthechopped

value.Withoutanargument,

chopsthelastcharacteroff

$_.

chown



chown(LIST)

chownLIST

Changestheownerandgroup

IDsofalistoffiles.Firsttwo

elementsinthelistarethe

numericaluidandgid,

respectively.Therestofthe

listarethenamesoffiles.

Returnsthenumberoffiles

changed.

Seechown(2).



chr



chrNUMBERReturnsthe

ASCIIvalueforNUMBER;e.g.,

chr(66)returnsB.



chroot



chroot(FILENAME)

chrootFILENAME

Changesrootdirectoryforthe

currentprocesstoFILENAME,

whichisthestartingpointfor

pathnamesstartingwith/.

Mustbesuperusertodothis.

Seechroot(2).



close



close(FILEHANDLE)

closeFILEHANDLE

Closesthefile,socket,orpipe



associatedwithFILEHANDLE.

closedir



closedir(DIRHANDLE)

closedirDIRHANDLE

Closesadirectorystructure

openedbyopendir.

Seedirectory(3).



connect



connect(SOCKET,NAME)

Connectsaprocesswithone

thatiswaitingforanaccept

call.NAMEisapacked

networkaddress.

Seeconnect(2).



cos



cos(EXPR)

cosEXPR

ReturnsthecosineofEXPR(in

radians).



crypt



crypt(PLAINTEXT,SALT)

Thepasswordencryption

function,wherePLAINTEXTis

theuser'spasswordandSALT

isatwo-characterstring

consistingofcharactersinthe

set[a–zA–Z./].

Seecrypt(3).



dbmclose



dbmclose(%ASSOC_ARRAY)

dbmclose%ASSOC_ARRAY

Breaksthebindingbetweena

DBMfileandanassociative



array.UsefulonlywithNDBM,

anewerversionofDBM,if

supported.

Seeuntie.

Seedbm(3).

dbmopen



dbmopen(%ASSOC_ARRAY,

DBNAME,MODE)

BindsaDBMorNDBMfileto

anassociativearray.Beforea

databasecanbeaccessed,it

mustbeopenedbydbmopen.

Thefilesfile.dirandfile.pag

mustexist.DBNAMEisthe

nameofthefilewithoutthe

.dirand.pagextension.Ifthe

databasedoesnotexistand

permissionMODEisspecified,

thedatabaseiscreated.

Seetie.

Seedbminit(3).



defined



defined(EXPR)

definedEXPR

ReturnsaBooleanvalue1if

EXPRhasarealvalue.

ReturnsaBooleanvalue0if

EXPRdoesnothaveareal

value.EXPRmaybeascalar,

array,hash,orsubroutine.For

ahash,checksonlywhether

thevalue(notkey)isdefined.



delete



delete$ASSOC{KEY}Deletes



avaluefromanassociative

array.Ifsuccessful,returns

thedeletedvalue;otherwise,

returnsanundefinedvalue.If

avaluein%ENVisdeleted,

theenvironmentwillbe

modified.Theundeffunction

canalsobeusedandisfaster.

die



die(LIST)

dieLIST

die

PrintstheLISTtoSTDERRand

exitswiththevalueof$!,the

systemerrormessage

(errno).Wheninaneval

function,setsthe$@valueto

theerrormessage,andaborts

eval.IfthevalueofLISTdoes

notendinanewline,the

nameofthecurrentscript,

thelinenumber,anda

newlineareappendedtothe

message.



do



doBLOCK

doSUBROUTINE(LIST)

doEXPR

doBLOCKreturnsthevalueof

thelastcommandinthe

BLOCK.

doSUBROUTINE(LIST)callsa

SUBROUTINEthathasbeen



defined.

doEXPRusesEXPRasa

filenameandexecutesthe

contentsofthefileasaPerl

script.Usedprimarilyto

includesubroutinesfromthe

Perlsubroutinelibrary.

dump



dumpLABELCausesan

immediatebinaryimagecore

dump.Theundump

command,usedfor

undumpingacorefile,isnot

partofthePerl5.6.0

distribution.



each



each(%ASSOC_ARRAY)

each%ASSOC_ARRAY

Returnsatwo-elementarray,

thekeyandvalueforthenext

valueofanassociativearray,

inrandomorder.



eof



eof(FILEHANDLE)

eof()

eof

Returns1ifthenextreadon

FILEHANDLEindicatestheend

offile.IfFILEHANDLEis

omitted,itreturnstheendof

fileforthelastfileread.



eval



eval(EXPR)

evalEXPR



EvaluatesEXPRasaPerl

programinthecontextofthe

currentPerlscript.Oftenused

fortrappingotherwisefatal

errors.Syntaxerrorsor

runtimeerrorsorthose

comingfromthediefunction

arereturnedtothe$@

variable.The$@variableis

settoNULLifthereareno

errors.Thevaluereturnedis

thevalueofthelast

expressionevaluated.

exec



exec(LIST)

execLIST

Executesasystemcommand

LISTincontextofthecurrent

program.Neverreturns.If

LISTisscalar,checksforshell

metacharactersandpasses

themto/bin/sh.Otherwise,

argumentsarepassedtothe

Cfunctioncallexecvp.Does

notflushoutputbuffer.



exists



existsEXPRReturnsTRUEifa

specifiedkeyfroman

associativearrayexists,even

ifitscorrespondingvalueis

undefined.



exit



exit(INTEGER)

exitINTEGER

Exitswithscriptwithstatus

valueofINTEGER.IfINTEGER



isomitted,exitswith0,

meaningtheprogramexits

withsuccessfulstatus.A

nonzerostatusimpliesthat

somethingwentwronginthe

program.

exp



exp(EXPR)

expEXPR

Theexponentialfunction.

Returnsetothepowerof

EXPR.



fcntl



fcntl(FILEHANDLE,FUNCTION,

SCALAR)

Changespropertiesonan

openfile.Requires

sys/fcntl.ph.TheFUNCTION

canduplicateanexistingfile

descriptor,getorsetfile

descriptorflags,getorsetfile

statusflags,getorset

asynchronousI/Oownership,

andgetorsetrecordlocks.

SCALARisanintegerforflags.

Seefcntl(2).



fileno



fileno(FILEHANDLE)

filenoFILEHANDLE

Returnstheintegerfile

descriptorforFILEHANDLE.

DescriptorsstartwithSTDIN,

STDOUT,STDERR,0,1,and

2,respectively.Maynotbe

reliableinPerlscriptsifafile



isclosedandreopened.

Seeferror(3).

flock



flock(FILEHANDLE,

OPERATION)

Appliesorremovesadvisory

locksonfiles.OPERATION

specifiesanoperationona

lockforafile,sharedlocks,

exclusivelocks,or

nonblockinglocks.The

OPERATIONtoremoveafileis

unlock.

Seeflock(2).



fork



forkCreatesanew(child)

process.Thechildisacopyof

theparentprocess.Bothchild

andparentcontinueexecution

withtheinstruction

immediatelyfollowingthe

fork.Returns0tothechild

processandthepidofthe

childtotheparent.



format



formatNAME=pictureline

valuelist

...

.Declaresasetofpicture

linestodescribethelayoutof

correspondingvalues.The

writefunctionusesthe

specifiedformattosend

outputtoanamedfilehandle

representedbyNAME.If

NAMEisomitted,thedefault

isSTDOUT.



Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Appendix A. Perl Built-ins, Pragmas, Modules, and the Debugger

Tải bản đầy đủ ngay(0 tr)

×