📄 perl56delta.pod
字号:
C<^_>, which may be used by user programs and are guaranteed not toacquire special meaning in any future version of Perl.=head2 New variable $^C reflects C<-c> switchC<$^C> has a boolean value that reflects whether perl is being runin compile-only mode (i.e. via the C<-c> switch). SinceBEGIN blocks are executed under such conditions, this variableenables perl code to determine whether actions that make senseonly during normal running are warranted. See L<perlvar>.=head2 New variable $^V contains Perl version as a stringC<$^V> contains the Perl version number as a string composed ofcharacters whose ordinals match the version numbers, i.e. v5.6.0.This may be used in string comparisons.See C<Support for strings represented as a vector of ordinals> for anexample.=head2 Optional Y2K warningsIf Perl is built with the cpp macro C<PERL_Y2KWARN> defined,it emits optional warnings when concatenating the number 19with another number.This behavior must be specifically enabled when running Configure.See F<INSTALL> and F<README.Y2K>.=head2 Arrays now always interpolate into double-quoted stringsIn double-quoted strings, arrays now interpolate, no matter what. Thebehavior in earlier versions of perl 5 was that arrays would interpolateinto strings if the array had been mentioned before the string wascompiled, and otherwise Perl would raise a fatal compile-time error.In versions 5.000 through 5.003, the error was Literal @example now requires backslashIn versions 5.004_01 through 5.6.0, the error was In string, @example now must be written as \@exampleThe idea here was to get people into the habit of writingC<"fred\@example.com"> when they wanted a literal C<@> sign, just asthey have always written C<"Give me back my \$5"> when they wanted aliteral C<$> sign.Starting with 5.6.1, when Perl now sees an C<@> sign in adouble-quoted string, it I<always> attempts to interpolate an array,regardless of whether or not the array has been used or declaredalready. The fatal error has been downgraded to an optional warning: Possible unintended interpolation of @example in stringThis warns you that C<"fred@example.com"> is going to turn intoC<fred.com> if you don't backslash the C<@>.See http://www.plover.com/~mjd/perl/at-error.html for more detailsabout the history here.=head2 @- and @+ provide starting/ending offsets of regex matchesThe new magic variables @- and @+ provide the starting and endingoffsets, respectively, of $&, $1, $2, etc. See L<perlvar> fordetails.=head1 Modules and Pragmata=head2 Modules=over 4=item attributesWhile used internally by Perl as a pragma, this module alsoprovides a way to fetch subroutine and variable attributes.See L<attributes>.=item BThe Perl Compiler suite has been extensively reworked for thisrelease. More of the standard Perl test suite passes when rununder the Compiler, but there is still a significant way togo 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.=item BenchmarkOverall, Benchmark results exhibit lower average error and better timingaccuracy. You can now run tests for I<n> seconds instead of guessing the rightnumber 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 alsochanged. 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 containingthe test results, keyed on the names of the tests.timethis() now returns the iterations field in the Benchmark result objectinstead of 0.timethese(), timethis(), and the new cmpthese() (see below) can also takea format specifier of 'none' to suppress output.A new function countit() is just like timeit() except that it takes aTIME instead of a COUNT.A new function cmpthese() prints a chart comparing the results of each testreturned from a timethese() call. For each possible pair of tests, thepercentage speed difference (iters/sec or seconds/iter) is shown.For other details, see L<Benchmark>.=item ByteLoaderThe ByteLoader is a dedicated extension to generate and runPerl bytecode. See L<ByteLoader>.=item constantReferences can now be used.The new version also allows a leading underscore in constant names, butdisallows a double leading underscore (as in "__LINE__"). Some other namesare disallowed or warned against, including BEGIN, END, etc. Some nameswhich were forced into main:: used to fail silently in some cases; now they'refatal (outside of main::) and an optional warning (inside of main::).The ability to detect whether a constant had been set with a given name hasbeen added.See L<constant>.=item charnamesThis pragma implements the C<\N> string escape. See L<charnames>.=item Data::DumperA C<Maxdepth> setting can be specified to avoid venturingtoo deeply into deep data structures. See L<Data::Dumper>.The XSUB implementation of Dump() is now automatically called if theC<Useqq> setting is not in use.Dumping C<qr//> objects works correctly.=item DBC<DB> is an experimental module that exposes a clean abstractionto Perl's debugging API.=item DB_FileDB_File can now be built with Berkeley DB versions 1, 2 or 3.See C<ext/DB_File/Changes>.=item Devel::DProfDevel::DProf, a Perl source code profiler has been added. SeeL<Devel::DProf> and L<dprofpp>.=item Devel::PeekThe Devel::Peek module provides access to the internal representationof Perl variables and data. It is a data debugging tool for the XS programmer.=item DumpvalueThe Dumpvalue module provides screen dumps of Perl data.=item DynaLoaderDynaLoader now supports a dl_unload_file() function on platforms thatsupport unloading shared objects using dlclose().Perl can also optionally arrange to unload all extension shared objectsloaded by Perl. To enable this, build Perl with the Configure optionC<-Accflags=-DDL_UNLOAD_ALL_AT_EXIT>. (This maybe useful if you areusing Apache with mod_perl.)=item English$PERL_VERSION now stands for C<$^V> (a string value) rather than for C<$]>(a numeric value).=item EnvEnv now supports accessing environment variables like PATH as arrayvariables.=item FcntlMore Fcntl constants added: F_SETLK64, F_SETLKW64, O_LARGEFILE forlarge file (more than 4GB) access (NOTE: the O_LARGEFILE isautomatically added to sysopen() flags if large file support has beenconfigured, as is the default), Free/Net/OpenBSD locking behaviourflags F_FLOCK, F_POSIX, Linux F_SHLCK, and O_ACCMODE: the combinedmask of O_RDONLY, O_WRONLY, and O_RDWR. The seek()/sysseek()constants SEEK_SET, SEEK_CUR, and SEEK_END are available via theC<:seek> tag. The chmod()/stat() S_IF* constants and S_IS* functionsare available via the C<:mode> tag.=item File::CompareA compare_text() function has been added, which allows customcomparison functions. See L<File::Compare>.=item File::FindFile::Find now works correctly when the wanted() function is eitherautoloaded or is a symbolic reference.A bug that caused File::Find to lose track of the working directorywhen pruning top-level directories has been fixed.File::Find now also supports several other options to control itsbehavior. It can follow symbolic links if the C<follow> option isspecified. Enabling the C<no_chdir> option will make File::Find skipchanging the current directory when walking directories. The C<untaint>flag can be useful when running with taint checks enabled.See L<File::Find>.=item File::GlobThis extension implements BSD-style file globbing. By default,it will also be used for the internal implementation of the glob()operator. See L<File::Glob>.=item File::SpecNew methods have been added to the File::Spec module: devnull() returnsthe name of the null device (/dev/null on Unix) and tmpdir() the name ofthe temp directory (normally /tmp on Unix). There are now also methodsto convert between absolute and relative filenames: abs2rel() andrel2abs(). For compatibility with operating systems that specify volumenames in file paths, the splitpath(), splitdir(), and catdir() methodshave been added.=item File::Spec::FunctionsThe new File::Spec::Functions modules provides a function interfaceto the File::Spec module. Allows shorthand $fullname = catfile($dir1, $dir2, $file);instead of $fullname = File::Spec->catfile($dir1, $dir2, $file);=item Getopt::LongGetopt::Long licensing has changed to allow the Perl Artistic Licenseas well as the GPL. It used to be GPL only, which got in the way ofnon-GPL applications that wanted to use Getopt::Long.Getopt::Long encourages the use of Pod::Usage to produce helpmessages. 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. =cutSee L<Pod::Usage> for details.A bug that prevented the non-option call-back <> from beingspecified 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. =item IOwrite() and syswrite() will now accept a single-argumentform of the call, for consistency with Perl's syswrite().You can now create a TCP-based IO::Socket::INET without forcinga 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() accessorfrom 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 doingtimeouts.IO::Socket::INET->new now sets $! correctly on failure. $@ isstill set for backwards compatibility.=item JPLJava Perl Lingo is now distributed with Perl. See jpl/READMEfor more information.=item libC<use lib> now weeds out any trailing duplicate entries.C<no lib> removes all named entries.=item Math::BigIntThe bitwise operations C<<< << >>>, C<<< >> >>>, C<&>, C<|>,and C<~> are now supported on bigints.=item Math::ComplexThe accessor methods Re, Im, arg, abs, rho, and theta can now alsoact as mutators (accessor $z->Re(), mutator $z->Re(3)).
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -