Perl in a Nutshell phần 6 ppsx

72 380 0
Perl in a Nutshell phần 6 ppsx

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Chapter 8 Standard Modules 8.64 ExtUtils::testlib Used for testing a module after it's been built and before it's been installed, when you don't want to (or can't) run make test. Adding: use ExtUtils::testlib; to your test program causes the intermediate directories used by make to be added to @INC, allowing you to run the test. 8.63 ExtUtils::Packlist 8.65 Fatal [ Library Home | Perl in a Nutshell | Learning Perl | Learning Perl on Win32 | Programming Perl | Advanced Perl Programming | Perl Cookbook ] [Chapter 8] 8.64 ExtUtils::testlib http://www.crypto.nc1uw1aoi420d85w1sos.de/documents/oreilly/perl/perlnut/ch08_64.htm [2/7/2001 10:32:37 PM] Chapter 8 Standard Modules 8.65 Fatal Provides a way to replace functions that return false on failure with equivalents that die instead, so you can use the functions without having to test the return values explicitly. Fatal reports errors via die; you can trap them with $SIG{__DIE__} if you want to take some action before the program exits. You can use Fatal for both user-defined functions and Perl core operators except exec and system. import● 8.64 ExtUtils::testlib 8.66 Fcntl [ Library Home | Perl in a Nutshell | Learning Perl | Learning Perl on Win32 | Programming Perl | Advanced Perl Programming | Perl Cookbook ] [Chapter 8] 8.65 Fatal http://www.crypto.nc1uw1aoi420d85w1sos.de/documents/oreilly/perl/perlnut/ch08_65.htm [2/7/2001 10:32:38 PM] Chapter 8 Standard Modules 8.66 Fcntl A translation of the C fcntl.h program that uses h2xs (which builds a Perl extension from a C header file) and the C compiler to translate #define symbols and make them available as functions. Exports the following routines by default; each routine returns the value of the #define that is the same as the routine name: FD_CLOEXEC F_DUPFD F_GETFD F_GETFL F_GETLK F_RDLCK F_SETFD F_SETFL F_SETLK F_SETLKW F_UNLCK F_WRLCK O_APPEND O_CREAT O_EXCL O_NDELAY O_NOCTTY O_NONBLOCK O_RDONLY O_RDWR O_TRUNC O_WRONLY 8.65 Fatal 8.67 fields [ Library Home | Perl in a Nutshell | Learning Perl | Learning Perl on Win32 | Programming Perl | Advanced Perl Programming | Perl Cookbook ] [Chapter 8] 8.66 Fcntl http://www.crypto.nc1uw1aoi420d85w1sos.de/documents/oreilly/perl/perlnut/ch08_66.htm [2/7/2001 10:32:42 PM] Chapter 8 Standard Modules 8.67 fields Pragma that provides the ability to define class fields at compile time, by updating the %FIELDS hash in the calling package. The %FIELDS hash is set up at compile time as well; use the base pragma to copy fields from base classes, and then fields to add new fields. Lets you have objects with named fields that are as compact and fast as arrays to access. For more details, see the fields manpage and the pseudo-hash section of the perlref manpage. 8.66 Fcntl 8.68 File::Basename [ Library Home | Perl in a Nutshell | Learning Perl | Learning Perl on Win32 | Programming Perl | Advanced Perl Programming | Perl Cookbook ] [Chapter 8] 8.67 fields http://www.crypto.nc1uw1aoi420d85w1sos.de/documents/oreilly/perl/perlnut/ch08_67.htm [2/7/2001 10:32:44 PM] Chapter 8 Standard Modules 8.68 File::Basename Parses a file's path, returning its three component pieces: the path to the file, the file's basename, and the file's extension. For example, for: /usr/local/lib/perl5/SelectSaver.pm the path is /usr/local/lib/perl5, the basename is SelectSaver, and the extension is .pm. File::Basename exports the following functions: basename● dirname● fileparse● fileparse_set_fstype● 8.67 fields 8.69 File::CheckTree [ Library Home | Perl in a Nutshell | Learning Perl | Learning Perl on Win32 | Programming Perl | Advanced Perl Programming | Perl Cookbook ] [Chapter 8] 8.68 File::Basename http://www.crypto.nc1uw1aoi420d85w1sos.de/documents/oreilly/perl/perlnut/ch08_68.htm [2/7/2001 10:32:45 PM] Chapter 8 Standard Modules 8.69 File::CheckTree Runs file tests on a set of files. Exports one function, validate, which takes a single multi-line string as input. Each line of the string contains a filename plus a test to run on the file. The test can be followed with || die to make it a fatal error if it fails. The default is || warn. Prepending ! to the test reverses the sense of the test. You can group tests (e.g., -rwx); only the first failed test of the group produces a warning. For example: use File::CheckTree; $warnings += validate( q{ /vmunix -e || die /bin cd csh !-ug sh -ex /usr -d || warn "What happened to $file?\n" }); Available tests include all the standard Perl file-test operators except -t, -M, -A, and -C. Unless it dies, validate returns the number of warnings issued. 8.68 File::Basename 8.70 File::Compare [ Library Home | Perl in a Nutshell | Learning Perl | Learning Perl on Win32 | Programming Perl | Advanced Perl Programming | Perl Cookbook ] [Chapter 8] 8.69 File::CheckTree http://www.crypto.nc1uw1aoi420d85w1sos.de/documents/oreilly/perl/perlnut/ch08_69.htm [2/7/2001 10:32:46 PM] Chapter 8 Standard Modules 8.70 File::Compare Compares the contents of two sources, each of which can be a file or a filehandle. Returns 0 if the sources are equal, 1 if they are unequal, and -1 on error. File::Compare provides two functions: compare● cmp● 8.69 File::CheckTree 8.71 File::Copy [ Library Home | Perl in a Nutshell | Learning Perl | Learning Perl on Win32 | Programming Perl | Advanced Perl Programming | Perl Cookbook ] [Chapter 8] 8.70 File::Compare http://www.crypto.nc1uw1aoi420d85w1sos.de/documents/oreilly/perl/perlnut/ch08_70.htm [2/7/2001 10:32:48 PM] Chapter 8 Standard Modules 8.71 File::Copy Copies or moves files or filehandles from one location to another. Returns 1 on success, 0 on failure, or sets $! on error. copy● cp● move● mv● 8.70 File::Compare 8.72 File::DosGlob [ Library Home | Perl in a Nutshell | Learning Perl | Learning Perl on Win32 | Programming Perl | Advanced Perl Programming | Perl Cookbook ] [Chapter 8] 8.71 File::Copy http://www.crypto.nc1uw1aoi420d85w1sos.de/documents/oreilly/perl/perlnut/ch08_71.htm [2/7/2001 10:32:49 PM] Chapter 8 Standard Modules 8.72 File::DosGlob Provides a portable enhanced DOS-like globbing for the standard Perl distribution. DosGlob lets you use wildcards in directory paths, is case-insensitive, and accepts both backslashes and forward slashes (although you may have to double the backslashes). Can be run three ways: From a Perl script: require 5.004 use File::DosGlob 'glob'; @perlfiles = glob " \pe?l/*.p?"; print < \pe?l/*.p?>; ● With the perl command, on the command line: # from the command line (overrides only in main::) % perl -MFile::DosGlob=glob -e "print < /pe*/*p?>" ● With the perlglob.bat program on the DOS command line: % perlglob /pe*/*p? ● When invoked as a program from the command line, File::DosGlob prints null-separated filenames to STDOUT. 8.71 File::Copy 8.73 File::Find [ Library Home | Perl in a Nutshell | Learning Perl | Learning Perl on Win32 | Programming Perl | Advanced Perl Programming | Perl Cookbook ] [Chapter 8] 8.72 File::DosGlob http://www.crypto.nc1uw1aoi420d85w1sos.de/documents/oreilly/perl/perlnut/ch08_72.htm [2/7/2001 10:32:50 PM] Chapter 8 Standard Modules 8.73 File::Find Looks for files that match a particular expression. Exports two functions: find● finddepth● 8.72 File::DosGlob 8.74 File::Path [ Library Home | Perl in a Nutshell | Learning Perl | Learning Perl on Win32 | Programming Perl | Advanced Perl Programming | Perl Cookbook ] [Chapter 8] 8.73 File::Find http://www.crypto.nc1uw1aoi420d85w1sos.de/documents/oreilly/perl/perlnut/ch08_73.htm [2/7/2001 10:32:51 PM] [...]... can be safely called in an array context (but it still returns just one line) $fh->getlines Works like Perl' s construct when called in an array context to read all remaining lines in a file 8.82 FileCache 8.84 FindBin [ Library Home | Perl in a Nutshell | Learning Perl | Learning Perl on Win32 | Programming Perl | Advanced Perl Programming | Perl Cookbook ] http://www.crypto.nc1uw1aoi420d85w1sos.de/documents/oreilly /perl/ perlnut/ch08_83.htm... book Programming Perl or the perlfunc manpage for more detail): clearerr getc close gets eof seek fileno tell The next group of FileHandle methods correspond to Perl special variables (see Programming Perl or the perlvar manpage): autoflush format_page_number format_formfeed format_top_name format_line_break_characters input_line_number format_lines_left input_record_separator format_lines_per_page output_field_separator... for a filehandle getc Returns next character from input file print Prints a string or comma-separated list of strings printf Prints a formatted string http://www.crypto.nc1uw1aoi420d85w1sos.de/documents/oreilly /perl/ perlnut/ch08_92.htm (1 of 2) [2/7/2001 10:33:22 PM] [Chapter 8] 8.92 IO::Handle read Reads data from a filehandle stat Returns an array of status information for a file sysread Reads data... (default newline) input_line_number Current input line number for last filehandle accessed output_field_separator Output field separator for print output_record_separator Output record separator for print 8.91 IO::File 8.93 IO::Pipe [ Library Home | Perl in a Nutshell | Learning Perl | Learning Perl on Win32 | Programming Perl | Advanced Perl Programming | Perl Cookbook ] http://www.crypto.nc1uw1aoi420d85w1sos.de/documents/oreilly /perl/ perlnut/ch08_92.htm... format_lines_per_page Current page length (default 60 ) format_lines_left Number of lines left on page format_name Name of current report format format_top_name Name of current top-of-page format format_line_break_characters Current set of linebreak chars for a format format_formfeed Formfeed char used by formats (default \f) format_write Wrapper for write function input_record_separator Input record separator... of available functions is given in File::Spec::Unix; the functions are inherited by the other modules and overridden as necessary Subroutines should be called as class methods, rather than directly 8.74 File::Path 8. 76 File::Spec::Mac [ Library Home | Perl in a Nutshell | Learning Perl | Learning Perl on Win32 | Programming Perl | Advanced Perl Programming | Perl Cookbook ] http://www.crypto.nc1uw1aoi420d85w1sos.de/documents/oreilly /perl/ perlnut/ch08_75.htm... user to see what IO handles are ready for reading, writing, or have an error condition pending q new q add q bits q can_read q can_write q count q exists q handles q has_error q remove q select 8.94 IO::Seekable 8. 96 IO::Socket [ Library Home | Perl in a Nutshell | Learning Perl | Learning Perl on Win32 | Programming Perl | Advanced Perl Programming | Perl Cookbook ] http://www.crypto.nc1uw1aoi420d85w1sos.de/documents/oreilly /perl/ perlnut/ch08_95.htm... http://www.crypto.nc1uw1aoi420d85w1sos.de/documents/oreilly /perl/ perlnut/ch08_75.htm [2/7/2001 10:32:59 PM] [Chapter 8] 8. 76 File::Spec::Mac Chapter 8 Standard Modules 8. 76 File::Spec::Mac File::Spec for MacOS q canonpath q catdir q catfile q curdir q file_name_is_absolute q path q rootdir q updir 8.75 File::Spec 8.77 File::Spec::OS2 [ Library Home | Perl in a Nutshell | Learning Perl | Learning Perl on Win32 | Programming Perl | Advanced Perl Programming... http://www.crypto.nc1uw1aoi420d85w1sos.de/documents/oreilly /perl/ perlnut/ch08_83.htm (2 of 2) [2/7/2001 10:33:11 PM] [Chapter 8] 8.84 FindBin Chapter 8 Standard Modules 8.84 FindBin Finds the full path to a script's bin directory, letting you use relative paths to that directory without needing to know the actual location: use FindBin; use lib "$FindBin::Bin/ /lib"; or: use FindBin qw($Bin); use lib "$Bin/ /lib"; FindBin exports the following variables: $Bin... accepted Options that start with may have an argument appended, following a space or an equals sign (=): foo=bar foo bar Provides two functions: GetOptions and config q GetOptions q config 8.85 GDBM_File 8.87 Getopt::Std [ Library Home | Perl in a Nutshell | Learning Perl | Learning Perl on Win32 | Programming Perl | Advanced Perl Programming | Perl Cookbook ] http://www.crypto.nc1uw1aoi420d85w1sos.de/documents/oreilly /perl/ perlnut/ch08_ 86. htm . O_WRONLY 8 .65 Fatal 8 .67 fields [ Library Home | Perl in a Nutshell | Learning Perl | Learning Perl on Win32 | Programming Perl | Advanced Perl Programming | Perl Cookbook ] [Chapter 8] 8 .66 Fcntl http://www.crypto.nc1uw1aoi420d85w1sos.de/documents/oreilly /perl/ perlnut/ch08 _66 .htm. Library Home | Perl in a Nutshell | Learning Perl | Learning Perl on Win32 | Programming Perl | Advanced Perl Programming | Perl Cookbook ] [Chapter 8] 8 .65 Fatal http://www.crypto.nc1uw1aoi420d85w1sos.de/documents/oreilly /perl/ perlnut/ch08 _65 .htm. Fcntl 8 .68 File::Basename [ Library Home | Perl in a Nutshell | Learning Perl | Learning Perl on Win32 | Programming Perl | Advanced Perl Programming | Perl Cookbook ] [Chapter 8] 8 .67 fields http://www.crypto.nc1uw1aoi420d85w1sos.de/documents/oreilly /perl/ perlnut/ch08 _67 .htm

Ngày đăng: 12/08/2014, 21:21

Từ khóa liên quan

Mục lục

  • www.crypto.nc1uw1aoi420d85w1sos.de

    • [Chapter 8] 8.64 ExtUtils::testlib

    • [Chapter 8] 8.65 Fatal

    • [Chapter 8] 8.66 Fcntl

    • [Chapter 8] 8.67 fields

    • [Chapter 8] 8.68 File::Basename

    • [Chapter 8] 8.69 File::CheckTree

    • [Chapter 8] 8.70 File::Compare

    • [Chapter 8] 8.71 File::Copy

    • [Chapter 8] 8.72 File::DosGlob

    • [Chapter 8] 8.73 File::Find

    • [Chapter 8] 8.74 File::Path

    • [Chapter 8] 8.75 File::Spec

    • [Chapter 8] 8.76 File::Spec::Mac

    • [Chapter 8] 8.77 File::Spec::OS2

    • [Chapter 8] 8.78 File::Spec::Unix

    • [Chapter 8] 8.79 File::Spec::VMS

    • [Chapter 8] 8.80 File::Spec::Win32

    • [Chapter 8] 8.81 File::stat

    • [Chapter 8] 8.82 FileCache

    • [Chapter 8] 8.83 FileHandle

Tài liệu cùng người dùng

Tài liệu liên quan