![]() |
Perl's File Functions![]() ![]() ![]() ![]() ![]()
binmode(FILE HANDLE) - This function puts FILE HANDLE into a binary mode. chdir(DIR NAME) - Causes your program to use DIR NAME as the current directory. It will return true if the change was successful, false if not. chmod(MODE, FILE LIST) - This UNIX based function changes the permissions for a list of files. A count of the number of files whose permissions was changed is returned. There is no DOS equivalent for this function. chown(UID, GID, FILE LIST) - This UNIX based function changes the owner and group for a list of files. A count of the number of files whose ownership was changed is returned. There is no DOS equivalent for this function. close(FILE HANDLE) - Closes the connection between your program and the file opened with FILE_HANDLE. closedir(DIR HANDLE) - Closes the connection between your program and the directory opened with DIR HANDLE. eof(FILE HANDLE) - Returns true if the next read on FILE HANDLE will result in hitting the end of the file or if the file is not open. If FILE HANDLE is not specified the status of the last file read is returned. All input functions return the undefined value when the end of file is reached, so you'lI almost never need to use eof(). fcntl (FILE HANDLE - Implements the fcntl() function which lets FUNCTION, SCALAR) - you perform various file control operations. Its use is beyond the scope of this book. fileno(FILE HANDLE) - Returns the file descriptor for the specified FILE HANDLE. flock(FILEHANDLE, OPERATION) - This function will place a lock on a file so that multiple users or programs can't simultaneously use it. getc(FILE_HANDLE) - Reads the next character from FILE HANDLE. If FILE HANDLE is not specified, a character will be read from STD I N. glob(EXPRESSION) - Returns a list of files that match the specification of EXPRESSION, which can contain wildcards. ioctl(FILE_HANDLE, FUNCTION, SCALAR) - Implements the ioctl() function which lets you perform various file control operations. link(OLD_FILE_NAME, NEVV_FILE_NAME) - This UNIX based function creates a new file name that is linked to the old file name. It returns true for success and false for failure. There is no DOS equivalent for this function. Istat(FILE_HANDLE_OR FILE NAME) - Returns file statistics in a 13 element array. Istat() is identical to stat() except that it can also return information about symbolic links. mkdir(DIR NAME, MODE) - Creates a directory named DIR NAME If you try to create a subdirectory, the parent must already exist. This function returns false if the directory can't be created. The special variable $! is assigned the error message. open(FILE_HANDLE, EXPRESSION) - Creates a link between FILE HANDLE and a file specified by EXPRESSION. opendir(DIR_HANDLE, DIR NAME) - Creates a link between DIR_HANDLE and the directory specified by DIR NAME. opendir() returns true if successful, false otherwise. print FILE HANDLE (LIST) - Sends a list of strings to FILE HANDLE. If FILE HANDLE is not specified, then STDOUT is used. printf FILE HANDLE (FORMAT, LIST) - Sends a list of strings in a format specified by FORMAT to FILE_HANDLE. If FILE HANDLE is not specified, then STDOUT is used. read(FILE_HANDLE, BUFFER, LENGTH,LENGTH OFFSET) - Reads bytes from FILE HANDLE starting at OFFSET position in the file into the scalar variable called BUFFER. It returns the number of bytes read or the undefined value. readdir(DIR_HANDLE) - Returns the next directory entry from DIR_HANDLE when used in a scalar context. If used in an array context, all of the file entries in DIR_HANDLE will be returned in a list. If there are no more entries to return, the undefined value or a null list will be returned depending on the context. readlink(EXPRESSION) - This UNIX based function returns that value of a symbolic link. If an error occurs, the undefined value is returned and the special variable $! is assigned the error message. The $_ special variable is used if EXPRESSION is not specified. rename(OLD_FILE_NAME) NEW_FILE_NAME) - Changes the name of a file. You can use this function to change the directory where a file resides, but not the disk drive or volume. rewinddir(DIR_HANDLE) - Resets DIR_HANDLE so that the next readdir() starts at the beginning of the directory. rmdir(DIR_NAME) - Deletes an empty directory. If the directory can be deleted it returns false and $! is assigned the error message. seek(FILE_HANDLE, POSITION, WHENCE) - Moves to POSITION in the file connected toFILE HANDLE. The WHEncE parameter determines if POSITION is an offset from the beginning of the file (WHENCE=O), the current position in the file (WHENCE=1), or the end of the file (WHENCE=2). readdir(DIR_HANDLE, POSITION) - Sets the current position for readdir(). POSITION must be a value returned by the telldir() function. select(FILE_HANDLE) - Sets the default FILE HANDLE for the write() and, print() functions. It returns the currently selected file handle so that you may restore it if needed. sprintf(FORMAT, LIST) - Returns a string whose format is specified by FORMAT. stat(FILE HANDLE_OR FILE NAME) - Returns file statistics in a 13 element array. symlink(OLD FILE NAME, NEW FILE NAME) - This UNIX based function creates a new file name symbolically linked to the old file name. It returns false if the NEW FILE NAME cannot be created. sysread(FILE HANDLE, BUFFER, LENGTH, OFFSET) - Reads LENGTH bytes from FILE HANDLE starting at OFFSET position in the file into the scalar variable called BUFFER. It returns the number of bytes read or the undefined value. syswrite(FILE HANDLE, BUFFER, LENGTH, OFFSET) - Writes LENGTH bytes from FILE HANDLE starting at OFFSET position in the file into the scalar variable called BUFFER. It returns the number of bytes written or the undefined value. tell(FILE_HANDLE) - Returns the current file position for FILE HANDLE. If FILE HANDLE is not specified, the file position for the last file read is returned. telldir(DIR_HANDLE) - Returns the current position for DIR HANDLE. The return value may be passed to seekdiro to access a particular location in a directory. truncate(FILE HANDLE, LENGTH) - Truncates the file opened on FILE HANDLE to be LENGTH bytes long, unlink(FILE_LIST) - Deletes a list of files. If FILE LIST is not specified, then $ will be used. It returns the number of files successfully deleted. Therefore, it returns false or 0 if no files were deleted. write(FILE HANDLE) - Writes a formatted record to FILE HANDLE. UNIX based implementations of Perl have several database functions available to them. For example, dbmopen() and dbmclose().
|
|
PERL Perl Program Data Types Types of Variables Operator Types Functions String Functions Array Functions Expressions Statement Blocks The if Statement Unless Statement While Loops Until Loop For Loop Foreach Loop Jump Keywords Subroutines Perl References Die Function Exit Function Localtime Function Standard Files File Test Operators File Functions Opening Files Reading into Hash Printing Revisited Globbing Splitting a Record into Fields Perl's Special Variables Regular Expression Simple True-False Searches Inexact Matches in Regular Expressions Matching Any Character Characters with Class Special Locations Quantifiers Greedy Matching Modifiers Localtime Function Subsituations Letter for Letter Translations Generating A Simple Report Defining a Report Template Specifying the Picture Line Specifying the Argument Line Adding a Header Writing the ReportDomain Names Home Importance of a domain name How does a web domain name work? Domain name syntax Choosing a domain name Domain Transfer Domain Parking IP AddressWeb Design HTML DHTML XML JAVASCRIPT VBSCRIPT PHOTOSHOPWeb Hosting Web Server Web Server Software Microsoft Internet Information Server Web hosting ISP Shared web hosting Virtual web hosting Dedicated web hosting Web hosting colocation Managed web hostingE Commerce Principles of E-Commerce E-Banking Electronic Payment System E-Security Credit Cards Smart Cards
The Mailbox POP Server SMTP Server IMAP Protocol |
| Home | Web Hosting | Web Design | Sitemap |
| Copyright (C) 2007. Web Domain design hosting. All rights reserved. |