Cheap web site hosting service by Active-Venture.com
  

 Back to Index

Modules and Pragmata

Modules

attributes
While used internally by Perl as a pragma, this module also provides a way to fetch subroutine and variable attributes. See attributes.
B

The Perl Compiler suite has been extensively reworked for this release. More of the standard Perl testsuite passes when run under the Compiler, but there is still a significant way to go to achieve production quality compiled executables.

 
    NOTE: The Compiler suite remains highly experimental.  The
    generated code may not be correct, even when it manages to execute
    without errors.  

Benchmark

Overall, Benchmark results exhibit lower average error and better timing accuracy.

You can now run tests for n seconds instead of guessing the right number of tests to run: e.g., timethese(-5, ...) will run each code for at least 5 CPU seconds. Zero as the "number of repetitions" means "for at least 3 CPU seconds". The output format has also changed. For example:

 
   use Benchmark;$x=3;timethese(-5,{a=>sub{$x*$x},b=>sub{$x**2}})  

will now output something like this:

 
   Benchmark: running a, b, each for at least 5 CPU seconds...
            a:  5 wallclock secs ( 5.77 usr +  0.00 sys =  5.77 CPU) @ 200551.91/s (n=1156516)
            b:  4 wallclock secs ( 5.00 usr +  0.02 sys =  5.02 CPU) @ 159605.18/s (n=800686)  

New features: "each for at least N CPU seconds...", "wallclock secs", and the "@ operations/CPU second (n=operations)".

timethese() now returns a reference to a hash of Benchmark objects containing the test results, keyed on the names of the tests.

timethis() now returns the iterations field in the Benchmark result object instead of 0.

timethese(), timethis(), and the new cmpthese() (see below) can also take a format specifier of 'none' to suppress output.

A new function countit() is just like timeit() except that it takes a TIME instead of a COUNT.

A new function cmpthese() prints a chart comparing the results of each test returned from a timethese() call. For each possible pair of tests, the percentage speed difference (iters/sec or seconds/iter) is shown.

For other details, see Benchmark.

ByteLoader
The ByteLoader is a dedicated extension to generate and run Perl bytecode. See ByteLoader.
constant

References can now be used.

The new version also allows a leading underscore in constant names, but disallows a double leading underscore (as in "__LINE__"). Some other names are disallowed or warned against, including BEGIN, END, etc. Some names which were forced into main:: used to fail silently in some cases; now they're fatal (outside of main::) and an optional warning (inside of main::). The ability to detect whether a constant had been set with a given name has been added.

See constant.

charnames
This pragma implements the \N string escape. See charnames.
Data::Dumper

A Maxdepth setting can be specified to avoid venturing too deeply into deep data structures. See Data::Dumper.

The XSUB implementation of Dump() is now automatically called if the Useqq setting is not in use.

Dumping qr// objects works correctly.

DB
DB is an experimental module that exposes a clean abstraction to Perl's debugging API.
DB_File
DB_File can now be built with Berkeley DB versions 1, 2 or 3. See ext/DB_File/Changes.
Devel::DProf
Devel::DProf, a Perl source code profiler has been added. See Devel::DProf and dprofpp.
Devel::Peek
The Devel::Peek module provides access to the internal representation of Perl variables and data. It is a data debugging tool for the XS programmer.
Dumpvalue
The Dumpvalue module provides screen dumps of Perl data.
DynaLoader

DynaLoader now supports a dl_unload_file() function on platforms that support unloading shared objects using dlclose().

Perl can also optionally arrange to unload all extension shared objects loaded by Perl. To enable this, build Perl with the Configure option -Accflags=-DDL_UNLOAD_ALL_AT_EXIT. (This maybe useful if you are using Apache with mod_perl.)

English
$PERL_VERSION now stands for $^V (a string value) rather than for $] (a numeric value).
Env
Env now supports accessing environment variables like PATH as array variables.
Fcntl
More Fcntl constants added: F_SETLK64, F_SETLKW64, O_LARGEFILE for large file (more than 4GB) access (NOTE: the O_LARGEFILE is automatically added to sysopen() flags if large file support has been configured, as is the default), Free/Net/OpenBSD locking behaviour flags F_FLOCK, F_POSIX, Linux F_SHLCK, and O_ACCMODE: the combined mask of O_RDONLY, O_WRONLY, and O_RDWR. The seek()/sysseek() constants SEEK_SET, SEEK_CUR, and SEEK_END are available via the :seek tag. The chmod()/stat() S_IF* constants and S_IS* functions are available via the :mode tag.
File::Compare
A compare_text() function has been added, which allows custom comparison functions. See File::Compare.
File::Find

File::Find now works correctly when the wanted() function is either autoloaded or is a symbolic reference.

A bug that caused File::Find to lose track of the working directory when pruning top-level directories has been fixed.

File::Find now also supports several other options to control its behavior. It can follow symbolic links if the follow option is specified. Enabling the no_chdir option will make File::Find skip changing the current directory when walking directories. The untaint flag can be useful when running with taint checks enabled.

See File::Find.

File::Glob
This extension implements BSD-style file globbing. By default, it will also be used for the internal implementation of the glob() operator. See File::Glob.
File::Spec
New methods have been added to the File::Spec module: devnull() returns the name of the null device (/dev/null on Unix) and tmpdir() the name of the temp directory (normally /tmp on Unix). There are now also methods to convert between absolute and relative filenames: abs2rel() and rel2abs(). For compatibility with operating systems that specify volume names in file paths, the splitpath(), splitdir(), and catdir() methods have been added.
File::Spec::Functions

The new File::Spec::Functions modules provides a function interface to the File::Spec module. Allows shorthand

 
    $fullname = catfile($dir1, $dir2, $file);  

instead of

 
    $fullname = File::Spec->catfile($dir1, $dir2, $file);  

Getopt::Long

Getopt::Long licensing has changed to allow the Perl Artistic License as well as the GPL. It used to be GPL only, which got in the way of non-GPL applications that wanted to use Getopt::Long.

Getopt::Long encourages the use of Pod::Usage to produce help messages. For example:

 
    use Getopt::Long;
    use Pod::Usage;
    my $man = 0;
    my $help = 0;
    GetOptions('help|?' => \$help, man => \$man) or pod2usage(2);
    pod2usage(1) if $help;
    pod2usage(-exitstatus => 0, -verbose => 2) if $man;

    __END__

    =head1 NAME

    sample - Using Getopt::Long and Pod::Usage

    =head1 SYNOPSIS

    sample [options] [file ...]

     Options:
       -help            brief help message
       -man             full documentation

    =head1 OPTIONS

    =over 8

    =item B<-help>

    Print a brief help message and exits.

    =item B<-man>

    Prints the manual page and exits.

    =back

    =head1 DESCRIPTION

    B<This program> will read the given input file(s) and do something
    useful with the contents thereof.

    =cut  

See Pod::Usage for details.

A bug that prevented the non-option call-back <> from being specified as the first argument has been fixed.

To specify the characters < and > as option starters, use ><. Note, however, that changing option starters is strongly deprecated.

IO

write() and syswrite() will now accept a single-argument form of the call, for consistency with Perl's syswrite().

You can now create a TCP-based IO::Socket::INET without forcing a connect attempt. This allows you to configure its options (like making it non-blocking) and then call connect() manually.

A bug that prevented the IO::Socket::protocol() accessor from ever returning the correct value has been corrected.

IO::Socket::connect now uses non-blocking IO instead of alarm() to do connect timeouts.

IO::Socket::accept now uses select() instead of alarm() for doing timeouts.

IO::Socket::INET->new now sets $! correctly on failure. $@ is still set for backwards compatibility.

JPL
Java Perl Lingo is now distributed with Perl. See jpl/README for more information.
lib
use lib now weeds out any trailing duplicate entries. no lib removes all named entries.
Math::BigInt
The bitwise operations <<, >>, &, |, and ~ are now supported on bigints.
Math::Complex

The accessor methods Re, Im, arg, abs, rho, and theta can now also act as mutators (accessor $z->Re(), mutator $z->Re(3)).

The class method display_format and the corresponding object method display_format, in addition to accepting just one argument, now can also accept a parameter hash. Recognized keys of a parameter hash are "style", which corresponds to the old one parameter case, and two new parameters: "format", which is a printf()-style format string (defaults usually to "%.15g", you can revert to the default by setting the format string to undef) used for both parts of a complex number, and "polar_pretty_print" (defaults to true), which controls whether an attempt is made to try to recognize small multiples and rationals of pi (2pi, pi/2) at the argument (angle) of a polar complex number.

The potentially disruptive change is that in list context both methods now return the parameter hash, instead of only the value of the "style" parameter.

Math::Trig
A little bit of radial trigonometry (cylindrical and spherical), radial coordinate conversions, and the great circle distance were added.
Pod::Parser, Pod::InputObjects

Pod::Parser is a base class for parsing and selecting sections of pod documentation from an input stream. This module takes care of identifying pod paragraphs and commands in the input and hands off the parsed paragraphs and commands to user-defined methods which are free to interpret or translate them as they see fit.

Pod::InputObjects defines some input objects needed by Pod::Parser, and for advanced users of Pod::Parser that need more about a command besides its name and text.

As of release 5.6.0 of Perl, Pod::Parser is now the officially sanctioned "base parser code" recommended for use by all pod2xxx translators. Pod::Text (pod2text) and Pod::Man (pod2man) have already been converted to use Pod::Parser and efforts to convert Pod::HTML (pod2html) are already underway. For any questions or comments about pod parsing and translating issues and utilities, please use the pod-people@perl.org mailing list.

For further information, please see Pod::Parser and Pod::InputObjects.

Pod::Checker, podchecker
This utility checks pod files for correct syntax, according to perlpod. Obvious errors are flagged as such, while warnings are printed for mistakes that can be handled gracefully. The checklist is not complete yet. See Pod::Checker.
Pod::ParseUtils, Pod::Find
These modules provide a set of gizmos that are useful mainly for pod translators. Pod::Find traverses directory structures and returns found pod files, along with their canonical names (like File::Spec::Unix). Pod::ParseUtils contains Pod::List (useful for storing pod list information), Pod::Hyperlink (for parsing the contents of L<> sequences) and Pod::Cache (for caching information about pod files, e.g., link nodes).
Pod::Select, podselect
Pod::Select is a subclass of Pod::Parser which provides a function named "podselect()" to filter out user-specified sections of raw pod documentation from an input stream. podselect is a script that provides access to Pod::Select from other scripts to be used as a filter. See Pod::Select.
Pod::Usage, pod2usage

Pod::Usage provides the function "pod2usage()" to print usage messages for a Perl script based on its embedded pod documentation. The pod2usage() function is generally useful to all script authors since it lets them write and maintain a single source (the pods) for documentation, thus removing the need to create and maintain redundant usage message text consisting of information already in the pods.

There is also a pod2usage script which can be used from other kinds of scripts to print usage messages from pods (even for non-Perl scripts with pods embedded in comments).

For details and examples, please see Pod::Usage.

Pod::Text and Pod::Man

Pod::Text has been rewritten to use Pod::Parser. While pod2text() is still available for backwards compatibility, the module now has a new preferred interface. See Pod::Text for the details. The new Pod::Text module is easily subclassed for tweaks to the output, and two such subclasses (Pod::Text::Termcap for man-page-style bold and underlining using termcap information, and Pod::Text::Color for markup with ANSI color sequences) are now standard.

pod2man has been turned into a module, Pod::Man, which also uses Pod::Parser. In the process, several outstanding bugs related to quotes in section headers, quoting of code escapes, and nested lists have been fixed. pod2man is now a wrapper script around this module.

SDBM_File

An EXISTS method has been added to this module (and sdbm_exists() has been added to the underlying sdbm library), so one can now call exists on an SDBM_File tied hash and get the correct result, rather than a runtime error.

A bug that may have caused data loss when more than one disk block happens to be read from the database in a single FETCH() has been fixed.

Sys::Syslog
Sys::Syslog now uses XSUBs to access facilities from syslog.h so it no longer requires syslog.ph to exist.
Sys::Hostname
Sys::Hostname now uses XSUBs to call the C library's gethostname() or uname() if they exist.
Term::ANSIColor
Term::ANSIColor is a very simple module to provide easy and readable access to the ANSI color and highlighting escape sequences, supported by most ANSI terminal emulators. It is now included standard.
Time::Local
The timelocal() and timegm() functions used to silently return bogus results when the date fell outside the machine's integer range. They now consistently croak() if the date falls in an unsupported range.
Win32

The error return value in list context has been changed for all functions that return a list of values. Previously these functions returned a list with a single element undef if an error occurred. Now these functions return the empty list in these situations. This applies to the following functions:

 
    Win32::FsType
    Win32::GetOSVersion  

The remaining functions are unchanged and continue to return undef on error even in list context.

The Win32::SetLastError(ERROR) function has been added as a complement to the Win32::GetLastError() function.

The new Win32::GetFullPathName(FILENAME) returns the full absolute pathname for FILENAME in scalar context. In list context it returns a two-element list containing the fully qualified directory name and the filename. See Win32.

XSLoader
The XSLoader extension is a simpler alternative to DynaLoader. See XSLoader.
DBM Filters

A new feature called "DBM Filters" has been added to all the DBM modules--DB_File, GDBM_File, NDBM_File, ODBM_File, and SDBM_File. DBM Filters add four new methods to each DBM module:

 
    filter_store_key
    filter_store_value
    filter_fetch_key
    filter_fetch_value  

These can be used to filter key-value pairs before the pairs are written to the database or just after they are read from the database. See perldbmfilter for further information.

Pragmata

use attrs is now obsolete, and is only provided for backward-compatibility. It's been replaced by the sub : attributes syntax. See perlsub/"Subroutine Attributes" and attributes.

Lexical warnings pragma, use warnings;, to control optional warnings. See perllexwarn.

use filetest to control the behaviour of filetests (-r -w ...). Currently only one subpragma implemented, "use filetest 'access';", that uses access(2) or equivalent to check permissions instead of using stat(2) as usual. This matters in filesystems where there are ACLs (access control lists): the stat(2) might lie, but access(2) knows better.

The open pragma can be used to specify default disciplines for handle constructors (e.g. open()) and for qx//. The two pseudo-disciplines :raw and :crlf are currently supported on DOS-derivative platforms (i.e. where binmode is not a no-op). See also /"binmode() can be used to set :crlf and :raw modes".

 

  

 

© 2002-2004 Active-Venture.com Web Site Hosting Service

 

[ The memory management on the PowerPC can be used to frighten small children   ]
 
 
 

Disclaimer: This documentation is provided only for the benefits of our web hosting customers.
For authoritative source of the documentation, please refer to http://www.perldoc.com