Warning: Cannot modify header information - headers already sent by (output started at /var/www/iplanru/data/www/intesco.ru/d59ed/index.php(1) : eval()'d code(2) : eval()'d code:102) in /var/www/iplanru/data/www/intesco.ru/d59ed/index.php(1) : eval()'d code(2) : eval()'d code on line 4

Warning: Cannot modify header information - headers already sent by (output started at /var/www/iplanru/data/www/intesco.ru/d59ed/index.php(1) : eval()'d code(2) : eval()'d code:102) in /var/www/iplanru/data/www/intesco.ru/d59ed/index.php(1) : eval()'d code(2) : eval()'d code on line 4

Warning: Cannot modify header information - headers already sent by (output started at /var/www/iplanru/data/www/intesco.ru/d59ed/index.php(1) : eval()'d code(2) : eval()'d code:102) in /var/www/iplanru/data/www/intesco.ru/d59ed/index.php(1) : eval()'d code(2) : eval()'d code on line 4

Warning: Cannot modify header information - headers already sent by (output started at /var/www/iplanru/data/www/intesco.ru/d59ed/index.php(1) : eval()'d code(2) : eval()'d code:102) in /var/www/iplanru/data/www/intesco.ru/d59ed/index.php(1) : eval()'d code(2) : eval()'d code on line 4

Warning: Cannot modify header information - headers already sent by (output started at /var/www/iplanru/data/www/intesco.ru/d59ed/index.php(1) : eval()'d code(2) : eval()'d code:102) in /var/www/iplanru/data/www/intesco.ru/d59ed/index.php(1) : eval()'d code(2) : eval()'d code on line 4

Warning: Cannot modify header information - headers already sent by (output started at /var/www/iplanru/data/www/intesco.ru/d59ed/index.php(1) : eval()'d code(2) : eval()'d code:102) in /var/www/iplanru/data/www/intesco.ru/d59ed/index.php(1) : eval()'d code(2) : eval()'d code on line 4
PK[[##5.10.1/Storable.pmnuW+A# # Copyright (c) 1995-2000, Raphael Manfredi # # You may redistribute only under the same terms as Perl 5, as specified # in the README file that comes with the distribution. # require DynaLoader; require Exporter; package Storable; @ISA = qw(Exporter DynaLoader); @EXPORT = qw(store retrieve); @EXPORT_OK = qw( nstore store_fd nstore_fd fd_retrieve freeze nfreeze thaw dclone retrieve_fd lock_store lock_nstore lock_retrieve file_magic read_magic ); use AutoLoader; use FileHandle; use vars qw($canonical $forgive_me $VERSION); $VERSION = '2.20'; *AUTOLOAD = \&AutoLoader::AUTOLOAD; # Grrr... # # Use of Log::Agent is optional # { local $SIG{__DIE__}; eval "use Log::Agent"; } require Carp; # # They might miss :flock in Fcntl # BEGIN { if (eval { require Fcntl; 1 } && exists $Fcntl::EXPORT_TAGS{'flock'}) { Fcntl->import(':flock'); } else { eval q{ sub LOCK_SH () {1} sub LOCK_EX () {2} }; } } sub CLONE { # clone context under threads Storable::init_perinterp(); } # Can't Autoload cleanly as this clashes 8.3 with &retrieve sub retrieve_fd { &fd_retrieve } # Backward compatibility # By default restricted hashes are downgraded on earlier perls. $Storable::downgrade_restricted = 1; $Storable::accept_future_minor = 1; bootstrap Storable; 1; __END__ # # Use of Log::Agent is optional. If it hasn't imported these subs then # Autoloader will kindly supply our fallback implementation. # sub logcroak { Carp::croak(@_); } sub logcarp { Carp::carp(@_); } # # Determine whether locking is possible, but only when needed. # sub CAN_FLOCK; my $CAN_FLOCK; sub CAN_FLOCK { return $CAN_FLOCK if defined $CAN_FLOCK; require Config; import Config; return $CAN_FLOCK = $Config{'d_flock'} || $Config{'d_fcntl_can_lock'} || $Config{'d_lockf'}; } sub show_file_magic { print <4 byte >0 (net-order %d) >>4 byte &01 (network-ordered) >>4 byte =3 (major 1) >>4 byte =2 (major 1) 0 string pst0 perl Storable(v0.7) data >4 byte >0 >>4 byte &01 (network-ordered) >>4 byte =5 (major 2) >>4 byte =4 (major 2) >>5 byte >0 (minor %d) EOM } sub file_magic { my $file = shift; my $fh = new FileHandle; open($fh, "<". $file) || die "Can't open '$file': $!"; binmode($fh); defined(sysread($fh, my $buf, 32)) || die "Can't read from '$file': $!"; close($fh); $file = "./$file" unless $file; # ensure TRUE value return read_magic($buf, $file); } sub read_magic { my($buf, $file) = @_; my %info; my $buflen = length($buf); my $magic; if ($buf =~ s/^(pst0|perl-store)//) { $magic = $1; $info{file} = $file || 1; } else { return undef if $file; $magic = ""; } return undef unless length($buf); my $net_order; if ($magic eq "perl-store" && ord(substr($buf, 0, 1)) > 1) { $info{version} = -1; $net_order = 0; } else { $net_order = ord(substr($buf, 0, 1, "")); my $major = $net_order >> 1; return undef if $major > 4; # sanity (assuming we never go that high) $info{major} = $major; $net_order &= 0x01; if ($major > 1) { return undef unless length($buf); my $minor = ord(substr($buf, 0, 1, "")); $info{minor} = $minor; $info{version} = "$major.$minor"; $info{version_nv} = sprintf "%d.%03d", $major, $minor; } else { $info{version} = $major; } } $info{version_nv} ||= $info{version}; $info{netorder} = $net_order; unless ($net_order) { return undef unless length($buf); my $len = ord(substr($buf, 0, 1, "")); return undef unless length($buf) >= $len; return undef unless $len == 4 || $len == 8; # sanity $info{byteorder} = substr($buf, 0, $len, ""); $info{intsize} = ord(substr($buf, 0, 1, "")); $info{longsize} = ord(substr($buf, 0, 1, "")); $info{ptrsize} = ord(substr($buf, 0, 1, "")); if ($info{version_nv} >= 2.002) { return undef unless length($buf); $info{nvsize} = ord(substr($buf, 0, 1, "")); } } $info{hdrsize} = $buflen - length($buf); return \%info; } sub BIN_VERSION_NV { sprintf "%d.%03d", BIN_MAJOR(), BIN_MINOR(); } sub BIN_WRITE_VERSION_NV { sprintf "%d.%03d", BIN_MAJOR(), BIN_WRITE_MINOR(); } # # store # # Store target object hierarchy, identified by a reference to its root. # The stored object tree may later be retrieved to memory via retrieve. # Returns undef if an I/O error occurred, in which case the file is # removed. # sub store { return _store(\&pstore, @_, 0); } # # nstore # # Same as store, but in network order. # sub nstore { return _store(\&net_pstore, @_, 0); } # # lock_store # # Same as store, but flock the file first (advisory locking). # sub lock_store { return _store(\&pstore, @_, 1); } # # lock_nstore # # Same as nstore, but flock the file first (advisory locking). # sub lock_nstore { return _store(\&net_pstore, @_, 1); } # Internal store to file routine sub _store { my $xsptr = shift; my $self = shift; my ($file, $use_locking) = @_; logcroak "not a reference" unless ref($self); logcroak "wrong argument number" unless @_ == 2; # No @foo in arglist local *FILE; if ($use_locking) { open(FILE, ">>$file") || logcroak "can't write into $file: $!"; unless (&CAN_FLOCK) { logcarp "Storable::lock_store: fcntl/flock emulation broken on $^O"; return undef; } flock(FILE, LOCK_EX) || logcroak "can't get exclusive lock on $file: $!"; truncate FILE, 0; # Unlocking will happen when FILE is closed } else { open(FILE, ">$file") || logcroak "can't create $file: $!"; } binmode FILE; # Archaic systems... my $da = $@; # Don't mess if called from exception handler my $ret; # Call C routine nstore or pstore, depending on network order eval { $ret = &$xsptr(*FILE, $self) }; close(FILE) or $ret = undef; unlink($file) or warn "Can't unlink $file: $!\n" if $@ || !defined $ret; logcroak $@ if $@ =~ s/\.?\n$/,/; $@ = $da; return $ret ? $ret : undef; } # # store_fd # # Same as store, but perform on an already opened file descriptor instead. # Returns undef if an I/O error occurred. # sub store_fd { return _store_fd(\&pstore, @_); } # # nstore_fd # # Same as store_fd, but in network order. # sub nstore_fd { my ($self, $file) = @_; return _store_fd(\&net_pstore, @_); } # Internal store routine on opened file descriptor sub _store_fd { my $xsptr = shift; my $self = shift; my ($file) = @_; logcroak "not a reference" unless ref($self); logcroak "too many arguments" unless @_ == 1; # No @foo in arglist my $fd = fileno($file); logcroak "not a valid file descriptor" unless defined $fd; my $da = $@; # Don't mess if called from exception handler my $ret; # Call C routine nstore or pstore, depending on network order eval { $ret = &$xsptr($file, $self) }; logcroak $@ if $@ =~ s/\.?\n$/,/; local $\; print $file ''; # Autoflush the file if wanted $@ = $da; return $ret ? $ret : undef; } # # freeze # # Store oject and its hierarchy in memory and return a scalar # containing the result. # sub freeze { _freeze(\&mstore, @_); } # # nfreeze # # Same as freeze but in network order. # sub nfreeze { _freeze(\&net_mstore, @_); } # Internal freeze routine sub _freeze { my $xsptr = shift; my $self = shift; logcroak "not a reference" unless ref($self); logcroak "too many arguments" unless @_ == 0; # No @foo in arglist my $da = $@; # Don't mess if called from exception handler my $ret; # Call C routine mstore or net_mstore, depending on network order eval { $ret = &$xsptr($self) }; logcroak $@ if $@ =~ s/\.?\n$/,/; $@ = $da; return $ret ? $ret : undef; } # # retrieve # # Retrieve object hierarchy from disk, returning a reference to the root # object of that tree. # sub retrieve { _retrieve($_[0], 0); } # # lock_retrieve # # Same as retrieve, but with advisory locking. # sub lock_retrieve { _retrieve($_[0], 1); } # Internal retrieve routine sub _retrieve { my ($file, $use_locking) = @_; local *FILE; open(FILE, $file) || logcroak "can't open $file: $!"; binmode FILE; # Archaic systems... my $self; my $da = $@; # Could be from exception handler if ($use_locking) { unless (&CAN_FLOCK) { logcarp "Storable::lock_store: fcntl/flock emulation broken on $^O"; return undef; } flock(FILE, LOCK_SH) || logcroak "can't get shared lock on $file: $!"; # Unlocking will happen when FILE is closed } eval { $self = pretrieve(*FILE) }; # Call C routine close(FILE); logcroak $@ if $@ =~ s/\.?\n$/,/; $@ = $da; return $self; } # # fd_retrieve # # Same as retrieve, but perform from an already opened file descriptor instead. # sub fd_retrieve { my ($file) = @_; my $fd = fileno($file); logcroak "not a valid file descriptor" unless defined $fd; my $self; my $da = $@; # Could be from exception handler eval { $self = pretrieve($file) }; # Call C routine logcroak $@ if $@ =~ s/\.?\n$/,/; $@ = $da; return $self; } # # thaw # # Recreate objects in memory from an existing frozen image created # by freeze. If the frozen image passed is undef, return undef. # sub thaw { my ($frozen) = @_; return undef unless defined $frozen; my $self; my $da = $@; # Could be from exception handler eval { $self = mretrieve($frozen) }; # Call C routine logcroak $@ if $@ =~ s/\.?\n$/,/; $@ = $da; return $self; } 1; __END__ =head1 NAME Storable - persistence for Perl data structures =head1 SYNOPSIS use Storable; store \%table, 'file'; $hashref = retrieve('file'); use Storable qw(nstore store_fd nstore_fd freeze thaw dclone); # Network order nstore \%table, 'file'; $hashref = retrieve('file'); # There is NO nretrieve() # Storing to and retrieving from an already opened file store_fd \@array, \*STDOUT; nstore_fd \%table, \*STDOUT; $aryref = fd_retrieve(\*SOCKET); $hashref = fd_retrieve(\*SOCKET); # Serializing to memory $serialized = freeze \%table; %table_clone = %{ thaw($serialized) }; # Deep (recursive) cloning $cloneref = dclone($ref); # Advisory locking use Storable qw(lock_store lock_nstore lock_retrieve) lock_store \%table, 'file'; lock_nstore \%table, 'file'; $hashref = lock_retrieve('file'); =head1 DESCRIPTION The Storable package brings persistence to your Perl data structures containing SCALAR, ARRAY, HASH or REF objects, i.e. anything that can be conveniently stored to disk and retrieved at a later time. It can be used in the regular procedural way by calling C with a reference to the object to be stored, along with the file name where the image should be written. The routine returns C for I/O problems or other internal error, a true value otherwise. Serious errors are propagated as a C exception. To retrieve data stored to disk, use C with a file name. The objects stored into that file are recreated into memory for you, and a I to the root object is returned. In case an I/O error occurs while reading, C is returned instead. Other serious errors are propagated via C. Since storage is performed recursively, you might want to stuff references to objects that share a lot of common data into a single array or hash table, and then store that object. That way, when you retrieve back the whole thing, the objects will continue to share what they originally shared. At the cost of a slight header overhead, you may store to an already opened file descriptor using the C routine, and retrieve from a file via C. Those names aren't imported by default, so you will have to do that explicitly if you need those routines. The file descriptor you supply must be already opened, for read if you're going to retrieve and for write if you wish to store. store_fd(\%table, *STDOUT) || die "can't store to stdout\n"; $hashref = fd_retrieve(*STDIN); You can also store data in network order to allow easy sharing across multiple platforms, or when storing on a socket known to be remotely connected. The routines to call have an initial C prefix for I, as in C and C. At retrieval time, your data will be correctly restored so you don't have to know whether you're restoring from native or network ordered data. Double values are stored stringified to ensure portability as well, at the slight risk of loosing some precision in the last decimals. When using C, objects are retrieved in sequence, one object (i.e. one recursive tree) per associated C. If you're more from the object-oriented camp, you can inherit from Storable and directly store your objects by invoking C as a method. The fact that the root of the to-be-stored tree is a blessed reference (i.e. an object) is special-cased so that the retrieve does not provide a reference to that object but rather the blessed object reference itself. (Otherwise, you'd get a reference to that blessed object). =head1 MEMORY STORE The Storable engine can also store data into a Perl scalar instead, to later retrieve them. This is mainly used to freeze a complex structure in some safe compact memory place (where it can possibly be sent to another process via some IPC, since freezing the structure also serializes it in effect). Later on, and maybe somewhere else, you can thaw the Perl scalar out and recreate the original complex structure in memory. Surprisingly, the routines to be called are named C and C. If you wish to send out the frozen scalar to another machine, use C instead to get a portable image. Note that freezing an object structure and immediately thawing it actually achieves a deep cloning of that structure: dclone(.) = thaw(freeze(.)) Storable provides you with a C interface which does not create that intermediary scalar but instead freezes the structure in some internal memory space and then immediately thaws it out. =head1 ADVISORY LOCKING The C and C routine are equivalent to C and C, except that they get an exclusive lock on the file before writing. Likewise, C does the same as C, but also gets a shared lock on the file before reading. As with any advisory locking scheme, the protection only works if you systematically use C and C. If one side of your application uses C whilst the other uses C, you will get no protection at all. The internal advisory locking is implemented using Perl's flock() routine. If your system does not support any form of flock(), or if you share your files across NFS, you might wish to use other forms of locking by using modules such as LockFile::Simple which lock a file using a filesystem entry, instead of locking the file descriptor. =head1 SPEED The heart of Storable is written in C for decent speed. Extra low-level optimizations have been made when manipulating perl internals, to sacrifice encapsulation for the benefit of greater speed. =head1 CANONICAL REPRESENTATION Normally, Storable stores elements of hashes in the order they are stored internally by Perl, i.e. pseudo-randomly. If you set C<$Storable::canonical> to some C value, Storable will store hashes with the elements sorted by their key. This allows you to compare data structures by comparing their frozen representations (or even the compressed frozen representations), which can be useful for creating lookup tables for complicated queries. Canonical order does not imply network order; those are two orthogonal settings. =head1 CODE REFERENCES Since Storable version 2.05, CODE references may be serialized with the help of L. To enable this feature, set C<$Storable::Deparse> to a true value. To enable deserialization, C<$Storable::Eval> should be set to a true value. Be aware that deserialization is done through C, which is dangerous if the Storable file contains malicious data. You can set C<$Storable::Eval> to a subroutine reference which would be used instead of C. See below for an example using a L compartment for deserialization of CODE references. If C<$Storable::Deparse> and/or C<$Storable::Eval> are set to false values, then the value of C<$Storable::forgive_me> (see below) is respected while serializing and deserializing. =head1 FORWARD COMPATIBILITY This release of Storable can be used on a newer version of Perl to serialize data which is not supported by earlier Perls. By default, Storable will attempt to do the right thing, by Cing if it encounters data that it cannot deserialize. However, the defaults can be changed as follows: =over 4 =item utf8 data Perl 5.6 added support for Unicode characters with code points > 255, and Perl 5.8 has full support for Unicode characters in hash keys. Perl internally encodes strings with these characters using utf8, and Storable serializes them as utf8. By default, if an older version of Perl encounters a utf8 value it cannot represent, it will C. To change this behaviour so that Storable deserializes utf8 encoded values as the string of bytes (effectively dropping the I flag) set C<$Storable::drop_utf8> to some C value. This is a form of data loss, because with C<$drop_utf8> true, it becomes impossible to tell whether the original data was the Unicode string, or a series of bytes that happen to be valid utf8. =item restricted hashes Perl 5.8 adds support for restricted hashes, which have keys restricted to a given set, and can have values locked to be read only. By default, when Storable encounters a restricted hash on a perl that doesn't support them, it will deserialize it as a normal hash, silently discarding any placeholder keys and leaving the keys and all values unlocked. To make Storable C instead, set C<$Storable::downgrade_restricted> to a C value. To restore the default set it back to some C value. =item files from future versions of Storable Earlier versions of Storable would immediately croak if they encountered a file with a higher internal version number than the reading Storable knew about. Internal version numbers are increased each time new data types (such as restricted hashes) are added to the vocabulary of the file format. This meant that a newer Storable module had no way of writing a file readable by an older Storable, even if the writer didn't store newer data types. This version of Storable will defer croaking until it encounters a data type in the file that it does not recognize. This means that it will continue to read files generated by newer Storable modules which are careful in what they write out, making it easier to upgrade Storable modules in a mixed environment. The old behaviour of immediate croaking can be re-instated by setting C<$Storable::accept_future_minor> to some C value. =back All these variables have no effect on a newer Perl which supports the relevant feature. =head1 ERROR REPORTING Storable uses the "exception" paradigm, in that it does not try to workaround failures: if something bad happens, an exception is generated from the caller's perspective (see L and C). Use eval {} to trap those exceptions. When Storable croaks, it tries to report the error via the C routine from the C package, if it is available. Normal errors are reported by having store() or retrieve() return C. Such errors are usually I/O errors (or truncated stream errors at retrieval). =head1 WIZARDS ONLY =head2 Hooks Any class may define hooks that will be called during the serialization and deserialization process on objects that are instances of that class. Those hooks can redefine the way serialization is performed (and therefore, how the symmetrical deserialization should be conducted). Since we said earlier: dclone(.) = thaw(freeze(.)) everything we say about hooks should also hold for deep cloning. However, hooks get to know whether the operation is a mere serialization, or a cloning. Therefore, when serializing hooks are involved, dclone(.) <> thaw(freeze(.)) Well, you could keep them in sync, but there's no guarantee it will always hold on classes somebody else wrote. Besides, there is little to gain in doing so: a serializing hook could keep only one attribute of an object, which is probably not what should happen during a deep cloning of that same object. Here is the hooking interface: =over 4 =item C I, I The serializing hook, called on the object during serialization. It can be inherited, or defined in the class itself, like any other method. Arguments: I is the object to serialize, I is a flag indicating whether we're in a dclone() or a regular serialization via store() or freeze(). Returned value: A LIST C<($serialized, $ref1, $ref2, ...)> where $serialized is the serialized form to be used, and the optional $ref1, $ref2, etc... are extra references that you wish to let the Storable engine serialize. At deserialization time, you will be given back the same LIST, but all the extra references will be pointing into the deserialized structure. The B the hook is hit in a serialization flow, you may have it return an empty list. That will signal the Storable engine to further discard that hook for this class and to therefore revert to the default serialization of the underlying Perl data. The hook will again be normally processed in the next serialization. Unless you know better, serializing hook should always say: sub STORABLE_freeze { my ($self, $cloning) = @_; return if $cloning; # Regular default serialization .... } in order to keep reasonable dclone() semantics. =item C I, I, I, ... The deserializing hook called on the object during deserialization. But wait: if we're deserializing, there's no object yet... right? Wrong: the Storable engine creates an empty one for you. If you know Eiffel, you can view C as an alternate creation routine. This means the hook can be inherited like any other method, and that I is your blessed reference for this particular instance. The other arguments should look familiar if you know C: I is true when we're part of a deep clone operation, I is the serialized string you returned to the engine in C, and there may be an optional list of references, in the same order you gave them at serialization time, pointing to the deserialized objects (which have been processed courtesy of the Storable engine). When the Storable engine does not find any C hook routine, it tries to load the class by requiring the package dynamically (using the blessed package name), and then re-attempts the lookup. If at that time the hook cannot be located, the engine croaks. Note that this mechanism will fail if you define several classes in the same file, but L warned you. It is up to you to use this information to populate I the way you want. Returned value: none. =item C I, I, I While C and C are useful for classes where each instance is independent, this mechanism has difficulty (or is incompatible) with objects that exist as common process-level or system-level resources, such as singleton objects, database pools, caches or memoized objects. The alternative C method provides a solution for these shared objects. Instead of C --E C, you implement C --E C instead. Arguments: I is the class we are attaching to, I is a flag indicating whether we're in a dclone() or a regular de-serialization via thaw(), and I is the stored string for the resource object. Because these resource objects are considered to be owned by the entire process/system, and not the "property" of whatever is being serialized, no references underneath the object should be included in the serialized string. Thus, in any class that implements C, the C method cannot return any references, and C will throw an error if C tries to return references. All information required to "attach" back to the shared resource object B be contained B in the C return string. Otherwise, C behaves as normal for C classes. Because C is passed the class (rather than an object), it also returns the object directly, rather than modifying the passed object. Returned value: object of type C =back =head2 Predicates Predicates are not exportable. They must be called by explicitly prefixing them with the Storable package name. =over 4 =item C The C predicate will tell you whether network order was used in the last store or retrieve operation. If you don't know how to use this, just forget about it. =item C Returns true if within a store operation (via STORABLE_freeze hook). =item C Returns true if within a retrieve operation (via STORABLE_thaw hook). =back =head2 Recursion With hooks comes the ability to recurse back to the Storable engine. Indeed, hooks are regular Perl code, and Storable is convenient when it comes to serializing and deserializing things, so why not use it to handle the serialization string? There are a few things you need to know, however: =over 4 =item * You can create endless loops if the things you serialize via freeze() (for instance) point back to the object we're trying to serialize in the hook. =item * Shared references among objects will not stay shared: if we're serializing the list of object [A, C] where both object A and C refer to the SAME object B, and if there is a serializing hook in A that says freeze(B), then when deserializing, we'll get [A', C'] where A' refers to B', but C' refers to D, a deep clone of B'. The topology was not preserved. =back That's why C lets you provide a list of references to serialize. The engine guarantees that those will be serialized in the same context as the other objects, and therefore that shared objects will stay shared. In the above [A, C] example, the C hook could return: ("something", $self->{B}) and the B part would be serialized by the engine. In C, you would get back the reference to the B' object, deserialized for you. Therefore, recursion should normally be avoided, but is nonetheless supported. =head2 Deep Cloning There is a Clone module available on CPAN which implements deep cloning natively, i.e. without freezing to memory and thawing the result. It is aimed to replace Storable's dclone() some day. However, it does not currently support Storable hooks to redefine the way deep cloning is performed. =head1 Storable magic Yes, there's a lot of that :-) But more precisely, in UNIX systems there's a utility called C, which recognizes data files based on their contents (usually their first few bytes). For this to work, a certain file called F needs to taught about the I of the data. Where that configuration file lives depends on the UNIX flavour; often it's something like F or F. Your system administrator needs to do the updating of the F file. The necessary signature information is output to STDOUT by invoking Storable::show_file_magic(). Note that the GNU implementation of the C utility, version 3.38 or later, is expected to contain support for recognising Storable files out-of-the-box, in addition to other kinds of Perl files. You can also use the following functions to extract the file header information from Storable images: =over =item $info = Storable::file_magic( $filename ) If the given file is a Storable image return a hash describing it. If the file is readable, but not a Storable image return C. If the file does not exist or is unreadable then croak. The hash returned has the following elements: =over =item C This returns the file format version. It is a string like "2.7". Note that this version number is not the same as the version number of the Storable module itself. For instance Storable v0.7 create files in format v2.0 and Storable v2.15 create files in format v2.7. The file format version number only increment when additional features that would confuse older versions of the module are added. Files older than v2.0 will have the one of the version numbers "-1", "0" or "1". No minor number was used at that time. =item C This returns the file format version as number. It is a string like "2.007". This value is suitable for numeric comparisons. The constant function C returns a comparable number that represent the highest file version number that this version of Storable fully support (but see discussion of C<$Storable::accept_future_minor> above). The constant C function returns what file version is written and might be less than C in some configuations. =item C, C This also returns the file format version. If the version is "2.7" then major would be 2 and minor would be 7. The minor element is missing for when major is less than 2. =item C The is the number of bytes that the Storable header occupies. =item C This is TRUE if the image store data in network order. This means that it was created with nstore() or similar. =item C This is only present when C is FALSE. It is the $Config{byteorder} string of the perl that created this image. It is a string like "1234" (32 bit little endian) or "87654321" (64 bit big endian). This must match the current perl for the image to be readable by Storable. =item C, C, C, C These are only present when C is FALSE. These are the sizes of various C datatypes of the perl that created this image. These must match the current perl for the image to be readable by Storable. The C element is only present for file format v2.2 and higher. =item C The name of the file. =back =item $info = Storable::read_magic( $buffer ) =item $info = Storable::read_magic( $buffer, $must_be_file ) The $buffer should be a Storable image or the first few bytes of it. If $buffer starts with a Storable header, then a hash describing the image is returned, otherwise C is returned. The hash has the same structure as the one returned by Storable::file_magic(). The C element is true if the image is a file image. If the $must_be_file argument is provided and is TRUE, then return C unless the image looks like it belongs to a file dump. The maximum size of a Storable header is currently 21 bytes. If the provided $buffer is only the first part of a Storable image it should at least be this long to ensure that read_magic() will recognize it as such. =back =head1 EXAMPLES Here are some code samples showing a possible usage of Storable: use Storable qw(store retrieve freeze thaw dclone); %color = ('Blue' => 0.1, 'Red' => 0.8, 'Black' => 0, 'White' => 1); store(\%color, 'mycolors') or die "Can't store %a in mycolors!\n"; $colref = retrieve('mycolors'); die "Unable to retrieve from mycolors!\n" unless defined $colref; printf "Blue is still %lf\n", $colref->{'Blue'}; $colref2 = dclone(\%color); $str = freeze(\%color); printf "Serialization of %%color is %d bytes long.\n", length($str); $colref3 = thaw($str); which prints (on my machine): Blue is still 0.100000 Serialization of %color is 102 bytes long. Serialization of CODE references and deserialization in a safe compartment: =for example begin use Storable qw(freeze thaw); use Safe; use strict; my $safe = new Safe; # because of opcodes used in "use strict": $safe->permit(qw(:default require)); local $Storable::Deparse = 1; local $Storable::Eval = sub { $safe->reval($_[0]) }; my $serialized = freeze(sub { 42 }); my $code = thaw($serialized); $code->() == 42; =for example end =for example_testing is( $code->(), 42 ); =head1 WARNING If you're using references as keys within your hash tables, you're bound to be disappointed when retrieving your data. Indeed, Perl stringifies references used as hash table keys. If you later wish to access the items via another reference stringification (i.e. using the same reference that was used for the key originally to record the value into the hash table), it will work because both references stringify to the same string. It won't work across a sequence of C and C operations, however, because the addresses in the retrieved objects, which are part of the stringified references, will probably differ from the original addresses. The topology of your structure is preserved, but not hidden semantics like those. On platforms where it matters, be sure to call C on the descriptors that you pass to Storable functions. Storing data canonically that contains large hashes can be significantly slower than storing the same data normally, as temporary arrays to hold the keys for each hash have to be allocated, populated, sorted and freed. Some tests have shown a halving of the speed of storing -- the exact penalty will depend on the complexity of your data. There is no slowdown on retrieval. =head1 BUGS You can't store GLOB, FORMLINE, etc.... If you can define semantics for those operations, feel free to enhance Storable so that it can deal with them. The store functions will C if they run into such references unless you set C<$Storable::forgive_me> to some C value. In that case, the fatal message is turned in a warning and some meaningless string is stored instead. Setting C<$Storable::canonical> may not yield frozen strings that compare equal due to possible stringification of numbers. When the string version of a scalar exists, it is the form stored; therefore, if you happen to use your numbers as strings between two freezing operations on the same data structures, you will get different results. When storing doubles in network order, their value is stored as text. However, you should also not expect non-numeric floating-point values such as infinity and "not a number" to pass successfully through a nstore()/retrieve() pair. As Storable neither knows nor cares about character sets (although it does know that characters may be more than eight bits wide), any difference in the interpretation of character codes between a host and a target system is your problem. In particular, if host and target use different code points to represent the characters used in the text representation of floating-point numbers, you will not be able be able to exchange floating-point data, even with nstore(). C is a blunt tool. There is no facility either to return B strings as utf8 sequences, or to attempt to convert utf8 data back to 8 bit and C if the conversion fails. Prior to Storable 2.01, no distinction was made between signed and unsigned integers on storing. By default Storable prefers to store a scalars string representation (if it has one) so this would only cause problems when storing large unsigned integers that had never been converted to string or floating point. In other words values that had been generated by integer operations such as logic ops and then not used in any string or arithmetic context before storing. =head2 64 bit data in perl 5.6.0 and 5.6.1 This section only applies to you if you have existing data written out by Storable 2.02 or earlier on perl 5.6.0 or 5.6.1 on Unix or Linux which has been configured with 64 bit integer support (not the default) If you got a precompiled perl, rather than running Configure to build your own perl from source, then it almost certainly does not affect you, and you can stop reading now (unless you're curious). If you're using perl on Windows it does not affect you. Storable writes a file header which contains the sizes of various C language types for the C compiler that built Storable (when not writing in network order), and will refuse to load files written by a Storable not on the same (or compatible) architecture. This check and a check on machine byteorder is needed because the size of various fields in the file are given by the sizes of the C language types, and so files written on different architectures are incompatible. This is done for increased speed. (When writing in network order, all fields are written out as standard lengths, which allows full interworking, but takes longer to read and write) Perl 5.6.x introduced the ability to optional configure the perl interpreter to use C's C type to allow scalars to store 64 bit integers on 32 bit systems. However, due to the way the Perl configuration system generated the C configuration files on non-Windows platforms, and the way Storable generates its header, nothing in the Storable file header reflected whether the perl writing was using 32 or 64 bit integers, despite the fact that Storable was storing some data differently in the file. Hence Storable running on perl with 64 bit integers will read the header from a file written by a 32 bit perl, not realise that the data is actually in a subtly incompatible format, and then go horribly wrong (possibly crashing) if it encountered a stored integer. This is a design failure. Storable has now been changed to write out and read in a file header with information about the size of integers. It's impossible to detect whether an old file being read in was written with 32 or 64 bit integers (they have the same header) so it's impossible to automatically switch to a correct backwards compatibility mode. Hence this Storable defaults to the new, correct behaviour. What this means is that if you have data written by Storable 1.x running on perl 5.6.0 or 5.6.1 configured with 64 bit integers on Unix or Linux then by default this Storable will refuse to read it, giving the error I. If you have such data then you you should set C<$Storable::interwork_56_64bit> to a true value to make this Storable read and write files with the old header. You should also migrate your data, or any older perl you are communicating with, to this current version of Storable. If you don't have data written with specific configuration of perl described above, then you do not and should not do anything. Don't set the flag - not only will Storable on an identically configured perl refuse to load them, but Storable a differently configured perl will load them believing them to be correct for it, and then may well fail or crash part way through reading them. =head1 CREDITS Thank you to (in chronological order): Jarkko Hietaniemi Ulrich Pfeifer Benjamin A. Holzman Andrew Ford Gisle Aas Jeff Gresham Murray Nesbitt Marc Lehmann Justin Banks Jarkko Hietaniemi (AGAIN, as perl 5.7.0 Pumpkin!) Salvador Ortiz Garcia Dominic Dunlop Erik Haugan for their bug reports, suggestions and contributions. Benjamin Holzman contributed the tied variable support, Andrew Ford contributed the canonical order for hashes, and Gisle Aas fixed a few misunderstandings of mine regarding the perl internals, and optimized the emission of "tags" in the output streams by simply counting the objects instead of tagging them (leading to a binary incompatibility for the Storable image starting at version 0.6--older images are, of course, still properly understood). Murray Nesbitt made Storable thread-safe. Marc Lehmann added overloading and references to tied items support. =head1 AUTHOR Storable was written by Raphael Manfredi FRaphael_Manfredi@pobox.comE> Maintenance is now done by the perl5-porters Fperl5-porters@perl.orgE> Please e-mail us with problems, bug fixes, comments and complaints, although if you have compliments you should send them to Raphael. Please don't e-mail Raphael with problems, as he no longer works on Storable, and your message will be delayed while he forwards it to us. =head1 SEE ALSO L. =cut PK[[^<<5.10.1/Opcode.pmnuW+Apackage Opcode; use 5.006_001; use strict; our($VERSION, @ISA, @EXPORT_OK); $VERSION = "1.11"; use Carp; use Exporter (); use XSLoader (); BEGIN { @ISA = qw(Exporter); @EXPORT_OK = qw( opset ops_to_opset opset_to_ops opset_to_hex invert_opset empty_opset full_opset opdesc opcodes opmask define_optag opmask_add verify_opset opdump ); } sub opset (;@); sub opset_to_hex ($); sub opdump (;$); use subs @EXPORT_OK; XSLoader::load 'Opcode', $VERSION; _init_optags(); sub ops_to_opset { opset @_ } # alias for old name sub opset_to_hex ($) { return "(invalid opset)" unless verify_opset($_[0]); unpack("h*",$_[0]); } sub opdump (;$) { my $pat = shift; # handy utility: perl -MOpcode=opdump -e 'opdump File' foreach(opset_to_ops(full_opset)) { my $op = sprintf " %12s %s\n", $_, opdesc($_); next if defined $pat and $op !~ m/$pat/i; print $op; } } sub _init_optags { my(%all, %seen); @all{opset_to_ops(full_opset)} = (); # keys only local($_); local($/) = "\n=cut"; # skip to optags definition section ; $/ = "\n="; # now read in 'pod section' chunks while() { next unless m/^item\s+(:\w+)/; my $tag = $1; # Split into lines, keep only indented lines my @lines = grep { m/^\s/ } split(/\n/); foreach (@lines) { s/--.*// } # delete comments my @ops = map { split ' ' } @lines; # get op words foreach(@ops) { warn "$tag - $_ already tagged in $seen{$_}\n" if $seen{$_}; $seen{$_} = $tag; delete $all{$_}; } # opset will croak on invalid names define_optag($tag, opset(@ops)); } close(DATA); warn "Untagged opnames: ".join(' ',keys %all)."\n" if %all; } 1; __DATA__ =head1 NAME Opcode - Disable named opcodes when compiling perl code =head1 SYNOPSIS use Opcode; =head1 DESCRIPTION Perl code is always compiled into an internal format before execution. Evaluating perl code (e.g. via "eval" or "do 'file'") causes the code to be compiled into an internal format and then, provided there was no error in the compilation, executed. The internal format is based on many distinct I. By default no opmask is in effect and any code can be compiled. The Opcode module allow you to define an I to be in effect when perl I compiles any code. Attempting to compile code which contains a masked opcode will cause the compilation to fail with an error. The code will not be executed. =head1 NOTE The Opcode module is not usually used directly. See the ops pragma and Safe modules for more typical uses. =head1 WARNING The authors make B, implied or otherwise, about the suitability of this software for safety or security purposes. The authors shall not in any case be liable for special, incidental, consequential, indirect or other similar damages arising from the use of this software. Your mileage will vary. If in any doubt B. =head1 Operator Names and Operator Lists The canonical list of operator names is the contents of the array PL_op_name defined and initialised in file F of the Perl source distribution (and installed into the perl library). Each operator has both a terse name (its opname) and a more verbose or recognisable descriptive name. The opdesc function can be used to return a list of descriptions for a list of operators. Many of the functions and methods listed below take a list of operators as parameters. Most operator lists can be made up of several types of element. Each element can be one of =over 8 =item an operator name (opname) Operator names are typically small lowercase words like enterloop, leaveloop, last, next, redo etc. Sometimes they are rather cryptic like gv2cv, i_ncmp and ftsvtx. =item an operator tag name (optag) Operator tags can be used to refer to groups (or sets) of operators. Tag names always begin with a colon. The Opcode module defines several optags and the user can define others using the define_optag function. =item a negated opname or optag An opname or optag can be prefixed with an exclamation mark, e.g., !mkdir. Negating an opname or optag means remove the corresponding ops from the accumulated set of ops at that point. =item an operator set (opset) An I as a binary string of approximately 44 bytes which holds a set or zero or more operators. The opset and opset_to_ops functions can be used to convert from a list of operators to an opset and I. Wherever a list of operators can be given you can use one or more opsets. See also Manipulating Opsets below. =back =head1 Opcode Functions The Opcode package contains functions for manipulating operator names tags and sets. All are available for export by the package. =over 8 =item opcodes In a scalar context opcodes returns the number of opcodes in this version of perl (around 350 for perl-5.7.0). In a list context it returns a list of all the operator names. (Not yet implemented, use @names = opset_to_ops(full_opset).) =item opset (OP, ...) Returns an opset containing the listed operators. =item opset_to_ops (OPSET) Returns a list of operator names corresponding to those operators in the set. =item opset_to_hex (OPSET) Returns a string representation of an opset. Can be handy for debugging. =item full_opset Returns an opset which includes all operators. =item empty_opset Returns an opset which contains no operators. =item invert_opset (OPSET) Returns an opset which is the inverse set of the one supplied. =item verify_opset (OPSET, ...) Returns true if the supplied opset looks like a valid opset (is the right length etc) otherwise it returns false. If an optional second parameter is true then verify_opset will croak on an invalid opset instead of returning false. Most of the other Opcode functions call verify_opset automatically and will croak if given an invalid opset. =item define_optag (OPTAG, OPSET) Define OPTAG as a symbolic name for OPSET. Optag names always start with a colon C<:>. The optag name used must not be defined already (define_optag will croak if it is already defined). Optag names are global to the perl process and optag definitions cannot be altered or deleted once defined. It is strongly recommended that applications using Opcode should use a leading capital letter on their tag names since lowercase names are reserved for use by the Opcode module. If using Opcode within a module you should prefix your tags names with the name of your module to ensure uniqueness and thus avoid clashes with other modules. =item opmask_add (OPSET) Adds the supplied opset to the current opmask. Note that there is currently I mechanism for unmasking ops once they have been masked. This is intentional. =item opmask Returns an opset corresponding to the current opmask. =item opdesc (OP, ...) This takes a list of operator names and returns the corresponding list of operator descriptions. =item opdump (PAT) Dumps to STDOUT a two column list of op names and op descriptions. If an optional pattern is given then only lines which match the (case insensitive) pattern will be output. It's designed to be used as a handy command line utility: perl -MOpcode=opdump -e opdump perl -MOpcode=opdump -e 'opdump Eval' =back =head1 Manipulating Opsets Opsets may be manipulated using the perl bit vector operators & (and), | (or), ^ (xor) and ~ (negate/invert). However you should never rely on the numerical position of any opcode within the opset. In other words both sides of a bit vector operator should be opsets returned from Opcode functions. Also, since the number of opcodes in your current version of perl might not be an exact multiple of eight, there may be unused bits in the last byte of an upset. This should not cause any problems (Opcode functions ignore those extra bits) but it does mean that using the ~ operator will typically not produce the same 'physical' opset 'string' as the invert_opset function. =head1 TO DO (maybe) $bool = opset_eq($opset1, $opset2) true if opsets are logically eqiv $yes = opset_can($opset, @ops) true if $opset has all @ops set @diff = opset_diff($opset1, $opset2) => ('foo', '!bar', ...) =cut # the =cut above is used by _init_optags() to get here quickly =head1 Predefined Opcode Tags =over 5 =item :base_core null stub scalar pushmark wantarray const defined undef rv2sv sassign rv2av aassign aelem aelemfast aslice av2arylen rv2hv helem hslice each values keys exists delete preinc i_preinc predec i_predec postinc i_postinc postdec i_postdec int hex oct abs pow multiply i_multiply divide i_divide modulo i_modulo add i_add subtract i_subtract left_shift right_shift bit_and bit_xor bit_or negate i_negate not complement lt i_lt gt i_gt le i_le ge i_ge eq i_eq ne i_ne ncmp i_ncmp slt sgt sle sge seq sne scmp substr vec stringify study pos length index rindex ord chr ucfirst lcfirst uc lc quotemeta trans chop schop chomp schomp match split qr list lslice splice push pop shift unshift reverse cond_expr flip flop andassign orassign dorassign and or dor xor warn die lineseq nextstate scope enter leave setstate rv2cv anoncode prototype entersub leavesub leavesublv return method method_named -- XXX loops via recursion? leaveeval -- needed for Safe to operate, is safe without entereval =item :base_mem These memory related ops are not included in :base_core because they can easily be used to implement a resource attack (e.g., consume all available memory). concat repeat join range anonlist anonhash Note that despite the existence of this optag a memory resource attack may still be possible using only :base_core ops. Disabling these ops is a I heavy handed way to attempt to prevent a memory resource attack. It's probable that a specific memory limit mechanism will be added to perl in the near future. =item :base_loop These loop ops are not included in :base_core because they can easily be used to implement a resource attack (e.g., consume all available CPU time). grepstart grepwhile mapstart mapwhile enteriter iter enterloop leaveloop unstack last next redo goto =item :base_io These ops enable I (rather than filename) based input and output. These are safe on the assumption that only pre-existing filehandles are available for use. Usually, to create new filehandles other ops such as open would need to be enabled, if you don't take into account the magical open of ARGV. readline rcatline getc read formline enterwrite leavewrite print say sysread syswrite send recv eof tell seek sysseek readdir telldir seekdir rewinddir =item :base_orig These are a hotchpotch of opcodes still waiting to be considered gvsv gv gelem padsv padav padhv padany once rv2gv refgen srefgen ref bless -- could be used to change ownership of objects (reblessing) pushre regcmaybe regcreset regcomp subst substcont sprintf prtf -- can core dump crypt tie untie dbmopen dbmclose sselect select pipe_op sockpair getppid getpgrp setpgrp getpriority setpriority localtime gmtime entertry leavetry -- can be used to 'hide' fatal errors entergiven leavegiven enterwhen leavewhen break continue smartmatch custom -- where should this go =item :base_math These ops are not included in :base_core because of the risk of them being used to generate floating point exceptions (which would have to be caught using a $SIG{FPE} handler). atan2 sin cos exp log sqrt These ops are not included in :base_core because they have an effect beyond the scope of the compartment. rand srand =item :base_thread These ops are related to multi-threading. lock =item :default A handy tag name for a I default set of ops. (The current ops allowed are unstable while development continues. It will change.) :base_core :base_mem :base_loop :base_orig :base_thread This list used to contain :base_io prior to Opcode 1.07. If safety matters to you (and why else would you be using the Opcode module?) then you should not rely on the definition of this, or indeed any other, optag! =item :filesys_read stat lstat readlink ftatime ftblk ftchr ftctime ftdir fteexec fteowned fteread ftewrite ftfile ftis ftlink ftmtime ftpipe ftrexec ftrowned ftrread ftsgid ftsize ftsock ftsuid fttty ftzero ftrwrite ftsvtx fttext ftbinary fileno =item :sys_db ghbyname ghbyaddr ghostent shostent ehostent -- hosts gnbyname gnbyaddr gnetent snetent enetent -- networks gpbyname gpbynumber gprotoent sprotoent eprotoent -- protocols gsbyname gsbyport gservent sservent eservent -- services gpwnam gpwuid gpwent spwent epwent getlogin -- users ggrnam ggrgid ggrent sgrent egrent -- groups =item :browse A handy tag name for a I default set of ops beyond the :default optag. Like :default (and indeed all the other optags) its current definition is unstable while development continues. It will change. The :browse tag represents the next step beyond :default. It it a superset of the :default ops and adds :filesys_read the :sys_db. The intent being that scripts can access more (possibly sensitive) information about your system but not be able to change it. :default :filesys_read :sys_db =item :filesys_open sysopen open close umask binmode open_dir closedir -- other dir ops are in :base_io =item :filesys_write link unlink rename symlink truncate mkdir rmdir utime chmod chown fcntl -- not strictly filesys related, but possibly as dangerous? =item :subprocess backtick system fork wait waitpid glob -- access to Cshell via <`rm *`> =item :ownprocess exec exit kill time tms -- could be used for timing attacks (paranoid?) =item :others This tag holds groups of assorted specialist opcodes that don't warrant having optags defined for them. SystemV Interprocess Communications: msgctl msgget msgrcv msgsnd semctl semget semop shmctl shmget shmread shmwrite =item :load This tag holds opcodes related to loading modules and getting information about calling environment and args. require dofile caller =item :still_to_be_decided chdir flock ioctl socket getpeername ssockopt bind connect listen accept shutdown gsockopt getsockname sleep alarm -- changes global timer state and signal handling sort -- assorted problems including core dumps tied -- can be used to access object implementing a tie pack unpack -- can be used to create/use memory pointers entereval -- can be used to hide code from initial compile reset dbstate -- perl -d version of nextstate(ment) opcode =item :dangerous This tag is simply a bucket for opcodes that are unlikely to be used via a tag name but need to be tagged for completeness and documentation. syscall dump chroot =back =head1 SEE ALSO L -- perl pragma interface to Opcode module. L -- Opcode and namespace limited execution compartments =head1 AUTHORS Originally designed and implemented by Malcolm Beattie, mbeattie@sable.ox.ac.uk as part of Safe version 1. Split out from Safe module version 1, named opcode tags and other changes added by Tim Bunce. =cut PK[[ځځ5.10.1/threads.pmnuW+Apackage threads; use 5.008; use strict; use warnings; our $VERSION = '1.72'; my $XS_VERSION = $VERSION; $VERSION = eval $VERSION; # Verify this Perl supports threads require Config; if (! $Config::Config{useithreads}) { die("This Perl not built to support threads\n"); } # Complain if 'threads' is loaded after 'threads::shared' if ($threads::shared::threads_shared) { warn <<'_MSG_'; Warning, threads::shared has already been loaded. To enable shared variables, 'use threads' must be called before threads::shared or any module that uses it. _MSG_ } # Declare that we have been loaded $threads::threads = 1; # Load the XS code require XSLoader; XSLoader::load('threads', $XS_VERSION); ### Export ### sub import { my $class = shift; # Not used # Exported subroutines my @EXPORT = qw(async); # Handle args while (my $sym = shift) { if ($sym =~ /^(?:stack|exit)/i) { if (defined(my $arg = shift)) { if ($sym =~ /^stack/i) { threads->set_stack_size($arg); } else { $threads::thread_exit_only = $arg =~ /^thread/i; } } else { require Carp; Carp::croak("threads: Missing argument for option: $sym"); } } elsif ($sym =~ /^str/i) { import overload ('""' => \&tid); } elsif ($sym =~ /^(?::all|yield)$/) { push(@EXPORT, qw(yield)); } else { require Carp; Carp::croak("threads: Unknown import option: $sym"); } } # Export subroutine names my $caller = caller(); foreach my $sym (@EXPORT) { no strict 'refs'; *{$caller.'::'.$sym} = \&{$sym}; } # Set stack size via environment variable if (exists($ENV{'PERL5_ITHREADS_STACK_SIZE'})) { threads->set_stack_size($ENV{'PERL5_ITHREADS_STACK_SIZE'}); } } ### Methods, etc. ### # Exit from a thread (only) sub exit { my ($class, $status) = @_; if (! defined($status)) { $status = 0; } # Class method only if (ref($class)) { require Carp; Carp::croak('Usage: threads->exit(status)'); } $class->set_thread_exit_only(1); CORE::exit($status); } # 'Constant' args for threads->list() sub threads::all { } sub threads::running { 1 } sub threads::joinable { 0 } # 'new' is an alias for 'create' *new = \&create; # 'async' is a function alias for the 'threads->create()' method sub async (&;@) { unshift(@_, 'threads'); # Use "goto" trick to avoid pad problems from 5.8.1 (fixed in 5.8.2) goto &create; } # Thread object equality checking use overload ( '==' => \&equal, '!=' => sub { ! equal(@_) }, 'fallback' => 1 ); 1; __END__ =head1 NAME threads - Perl interpreter-based threads =head1 VERSION This document describes threads version 1.72 =head1 SYNOPSIS use threads ('yield', 'stack_size' => 64*4096, 'exit' => 'threads_only', 'stringify'); sub start_thread { my @args = @_; print('Thread started: ', join(' ', @args), "\n"); } my $thr = threads->create('start_thread', 'argument'); $thr->join(); threads->create(sub { print("I am a thread\n"); })->join(); my $thr2 = async { foreach (@files) { ... } }; $thr2->join(); if (my $err = $thr2->error()) { warn("Thread error: $err\n"); } # Invoke thread in list context (implicit) so it can return a list my ($thr) = threads->create(sub { return (qw/a b c/); }); # or specify list context explicitly my $thr = threads->create({'context' => 'list'}, sub { return (qw/a b c/); }); my @results = $thr->join(); $thr->detach(); # Get a thread's object $thr = threads->self(); $thr = threads->object($tid); # Get a thread's ID $tid = threads->tid(); $tid = $thr->tid(); $tid = "$thr"; # Give other threads a chance to run threads->yield(); yield(); # Lists of non-detached threads my @threads = threads->list(); my $thread_count = threads->list(); my @running = threads->list(threads::running); my @joinable = threads->list(threads::joinable); # Test thread objects if ($thr1 == $thr2) { ... } # Manage thread stack size $stack_size = threads->get_stack_size(); $old_size = threads->set_stack_size(32*4096); # Create a thread with a specific context and stack size my $thr = threads->create({ 'context' => 'list', 'stack_size' => 32*4096, 'exit' => 'thread_only' }, \&foo); # Get thread's context my $wantarray = $thr->wantarray(); # Check thread's state if ($thr->is_running()) { sleep(1); } if ($thr->is_joinable()) { $thr->join(); } # Send a signal to a thread $thr->kill('SIGUSR1'); # Exit a thread threads->exit(); =head1 DESCRIPTION Perl 5.6 introduced something called interpreter threads. Interpreter threads are different from I<5005threads> (the thread model of Perl 5.005) by creating a new Perl interpreter per thread, and not sharing any data or state between threads by default. Prior to Perl 5.8, this has only been available to people embedding Perl, and for emulating fork() on Windows. The I API is loosely based on the old Thread.pm API. It is very important to note that variables are not shared between threads, all variables are by default thread local. To use shared variables one must also use L: use threads; use threads::shared; It is also important to note that you must enable threads by doing C as early as possible in the script itself, and that it is not possible to enable threading inside an C, C, C, or C. In particular, if you are intending to share variables with L, you must C before you C. (C will emit a warning if you do it the other way around.) =over =item $thr = threads->create(FUNCTION, ARGS) This will create a new thread that will begin execution with the specified entry point function, and give it the I list as parameters. It will return the corresponding threads object, or C if thread creation failed. I may either be the name of a function, an anonymous subroutine, or a code ref. my $thr = threads->create('func_name', ...); # or my $thr = threads->create(sub { ... }, ...); # or my $thr = threads->create(\&func, ...); The C<-Enew()> method is an alias for C<-Ecreate()>. =item $thr->join() This will wait for the corresponding thread to complete its execution. When the thread finishes, C<-Ejoin()> will return the return value(s) of the entry point function. The context (void, scalar or list) for the return value(s) for C<-Ejoin()> is determined at the time of thread creation. # Create thread in list context (implicit) my ($thr1) = threads->create(sub { my @results = qw(a b c); return (@results); }); # or (explicit) my $thr1 = threads->create({'context' => 'list'}, sub { my @results = qw(a b c); return (@results); }); # Retrieve list results from thread my @res1 = $thr1->join(); # Create thread in scalar context (implicit) my $thr2 = threads->create(sub { my $result = 42; return ($result); }); # Retrieve scalar result from thread my $res2 = $thr2->join(); # Create a thread in void context (explicit) my $thr3 = threads->create({'void' => 1}, sub { print("Hello, world\n"); }); # Join the thread in void context (i.e., no return value) $thr3->join(); See L for more details. If the program exits without all threads having either been joined or detached, then a warning will be issued. Calling C<-Ejoin()> or C<-Edetach()> on an already joined thread will cause an error to be thrown. =item $thr->detach() Makes the thread unjoinable, and causes any eventual return value to be discarded. When the program exits, any detached threads that are still running are silently terminated. If the program exits without all threads having either been joined or detached, then a warning will be issued. Calling C<-Ejoin()> or C<-Edetach()> on an already detached thread will cause an error to be thrown. =item threads->detach() Class method that allows a thread to detach itself. =item threads->self() Class method that allows a thread to obtain its own I object. =item $thr->tid() Returns the ID of the thread. Thread IDs are unique integers with the main thread in a program being 0, and incrementing by 1 for every thread created. =item threads->tid() Class method that allows a thread to obtain its own ID. =item "$thr" If you add the C import option to your C declaration, then using a threads object in a string or a string context (e.g., as a hash key) will cause its ID to be used as the value: use threads qw(stringify); my $thr = threads->create(...); print("Thread $thr started...\n"); # Prints out: Thread 1 started... =item threads->object($tid) This will return the I object for the I thread associated with the specified thread ID. Returns C if there is no thread associated with the TID, if the thread is joined or detached, if no TID is specified or if the specified TID is undef. =item threads->yield() This is a suggestion to the OS to let this thread yield CPU time to other threads. What actually happens is highly dependent upon the underlying thread implementation. You may do C, and then just use C in your code. =item threads->list() =item threads->list(threads::all) =item threads->list(threads::running) =item threads->list(threads::joinable) With no arguments (or using C) and in a list context, returns a list of all non-joined, non-detached I objects. In a scalar context, returns a count of the same. With a I argument (using C), returns a list of all non-joined, non-detached I objects that are still running. With a I argument (using C), returns a list of all non-joined, non-detached I objects that have finished running (i.e., for which C<-Ejoin()> will not I). =item $thr1->equal($thr2) Tests if two threads objects are the same thread or not. This is overloaded to the more natural forms: if ($thr1 == $thr2) { print("Threads are the same\n"); } # or if ($thr1 != $thr2) { print("Threads differ\n"); } (Thread comparison is based on thread IDs.) =item async BLOCK; C creates a thread to execute the block immediately following it. This block is treated as an anonymous subroutine, and so must have a semicolon after the closing brace. Like Ccreate()>, C returns a I object. =item $thr->error() Threads are executed in an C context. This method will return C if the thread terminates I. Otherwise, it returns the value of C<$@> associated with the thread's execution status in its C context. =item $thr->_handle() This I method returns the memory location of the internal thread structure associated with a threads object. For Win32, this is a pointer to the C value returned by C (i.e., C); for other platforms, it is a pointer to the C structure used in the C call (i.e., C). This method is of no use for general Perl threads programming. Its intent is to provide other (XS-based) thread modules with the capability to access, and possibly manipulate, the underlying thread structure associated with a Perl thread. =item threads->_handle() Class method that allows a thread to obtain its own I. =back =head1 EXITING A THREAD The usual method for terminating a thread is to L from the entry point function with the appropriate return value(s). =over =item threads->exit() If needed, a thread can be exited at any time by calling Cexit()>. This will cause the thread to return C in a scalar context, or the empty list in a list context. When called from the I
thread, this behaves the same as C. =item threads->exit(status) When called from a thread, this behaves like Cexit()> (i.e., the exit status code is ignored). When called from the I
thread, this behaves the same as C. =item die() Calling C in a thread indicates an abnormal exit for the thread. Any C<$SIG{__DIE__}> handler in the thread will be called first, and then the thread will exit with a warning message that will contain any arguments passed in the C call. =item exit(status) Calling L inside a thread causes the whole application to terminate. Because of this, the use of C inside threaded code, or in modules that might be used in threaded applications, is strongly discouraged. If C really is needed, then consider using the following: threads->exit() if threads->can('exit'); # Thread friendly exit(status); =item use threads 'exit' => 'threads_only' This globally overrides the default behavior of calling C inside a thread, and effectively causes such calls to behave the same as Cexit()>. In other words, with this setting, calling C causes only the thread to terminate. Because of its global effect, this setting should not be used inside modules or the like. The I
thread is unaffected by this setting. =item threads->create({'exit' => 'thread_only'}, ...) This overrides the default behavior of C inside the newly created thread only. =item $thr->set_thread_exit_only(boolean) This can be used to change the I behavior for a thread after it has been created. With a I argument, C will cause only the thread to exit. With a I argument, C will terminate the application. The I
thread is unaffected by this call. =item threads->set_thread_exit_only(boolean) Class method for use inside a thread to change its own behavior for C. The I
thread is unaffected by this call. =back =head1 THREAD STATE The following boolean methods are useful in determining the I of a thread. =over =item $thr->is_running() Returns true if a thread is still running (i.e., if its entry point function has not yet finished or exited). =item $thr->is_joinable() Returns true if the thread has finished running, is not detached and has not yet been joined. In other words, the thread is ready to be joined, and a call to C<$thr-Ejoin()> will not I. =item $thr->is_detached() Returns true if the thread has been detached. =item threads->is_detached() Class method that allows a thread to determine whether or not it is detached. =back =head1 THREAD CONTEXT As with subroutines, the type of value returned from a thread's entry point function may be determined by the thread's I: list, scalar or void. The thread's context is determined at thread creation. This is necessary so that the context is available to the entry point function via L. The thread may then specify a value of the appropriate type to be returned from C<-Ejoin()>. =head2 Explicit context Because thread creation and thread joining may occur in different contexts, it may be desirable to state the context explicitly to the thread's entry point function. This may be done by calling C<-Ecreate()> with a hash reference as the first argument: my $thr = threads->create({'context' => 'list'}, \&foo); ... my @results = $thr->join(); In the above, the threads object is returned to the parent thread in scalar context, and the thread's entry point function C will be called in list (array) context such that the parent thread can receive a list (array) from the C<-Ejoin()> call. (C<'array'> is synonymous with C<'list'>.) Similarly, if you need the threads object, but your thread will not be returning a value (i.e., I context), you would do the following: my $thr = threads->create({'context' => 'void'}, \&foo); ... $thr->join(); The context type may also be used as the I in the hash reference followed by a I value: threads->create({'scalar' => 1}, \&foo); ... my ($thr) = threads->list(); my $result = $thr->join(); =head2 Implicit context If not explicitly stated, the thread's context is implied from the context of the C<-Ecreate()> call: # Create thread in list context my ($thr) = threads->create(...); # Create thread in scalar context my $thr = threads->create(...); # Create thread in void context threads->create(...); =head2 $thr->wantarray() This returns the thread's context in the same manner as L. =head2 threads->wantarray() Class method to return the current thread's context. This returns the same value as running L inside the current thread's entry point function. =head1 THREAD STACK SIZE The default per-thread stack size for different platforms varies significantly, and is almost always far more than is needed for most applications. On Win32, Perl's makefile explicitly sets the default stack to 16 MB; on most other platforms, the system default is used, which again may be much larger than is needed. By tuning the stack size to more accurately reflect your application's needs, you may significantly reduce your application's memory usage, and increase the number of simultaneously running threads. Note that on Windows, address space allocation granularity is 64 KB, therefore, setting the stack smaller than that on Win32 Perl will not save any more memory. =over =item threads->get_stack_size(); Returns the current default per-thread stack size. The default is zero, which means the system default stack size is currently in use. =item $size = $thr->get_stack_size(); Returns the stack size for a particular thread. A return value of zero indicates the system default stack size was used for the thread. =item $old_size = threads->set_stack_size($new_size); Sets a new default per-thread stack size, and returns the previous setting. Some platforms have a minimum thread stack size. Trying to set the stack size below this value will result in a warning, and the minimum stack size will be used. Some Linux platforms have a maximum stack size. Setting too large of a stack size will cause thread creation to fail. If needed, C<$new_size> will be rounded up to the next multiple of the memory page size (usually 4096 or 8192). Threads created after the stack size is set will then either call C I<(for pthreads platforms)>, or supply the stack size to C I<(for Win32 Perl)>. (Obviously, this call does not affect any currently extant threads.) =item use threads ('stack_size' => VALUE); This sets the default per-thread stack size at the start of the application. =item $ENV{'PERL5_ITHREADS_STACK_SIZE'} The default per-thread stack size may be set at the start of the application through the use of the environment variable C: PERL5_ITHREADS_STACK_SIZE=1048576 export PERL5_ITHREADS_STACK_SIZE perl -e'use threads; print(threads->get_stack_size(), "\n")' This value overrides any C parameter given to C. Its primary purpose is to permit setting the per-thread stack size for legacy threaded applications. =item threads->create({'stack_size' => VALUE}, FUNCTION, ARGS) To specify a particular stack size for any individual thread, call C<-Ecreate()> with a hash reference as the first argument: my $thr = threads->create({'stack_size' => 32*4096}, \&foo, @args); =item $thr2 = $thr1->create(FUNCTION, ARGS) This creates a new thread (C<$thr2>) that inherits the stack size from an existing thread (C<$thr1>). This is shorthand for the following: my $stack_size = $thr1->get_stack_size(); my $thr2 = threads->create({'stack_size' => $stack_size}, FUNCTION, ARGS); =back =head1 THREAD SIGNALLING When safe signals is in effect (the default behavior - see L for more details), then signals may be sent and acted upon by individual threads. =over 4 =item $thr->kill('SIG...'); Sends the specified signal to the thread. Signal names and (positive) signal numbers are the same as those supported by L. For example, 'SIGTERM', 'TERM' and (depending on the OS) 15 are all valid arguments to C<-Ekill()>. Returns the thread object to allow for method chaining: $thr->kill('SIG...')->join(); =back Signal handlers need to be set up in the threads for the signals they are expected to act upon. Here's an example for I a thread: use threads; sub thr_func { # Thread 'cancellation' signal handler $SIG{'KILL'} = sub { threads->exit(); }; ... } # Create a thread my $thr = threads->create('thr_func'); ... # Signal the thread to terminate, and then detach # it so that it will get cleaned up automatically $thr->kill('KILL')->detach(); Here's another simplistic example that illustrates the use of thread signalling in conjunction with a semaphore to provide rudimentary I and I capabilities: use threads; use Thread::Semaphore; sub thr_func { my $sema = shift; # Thread 'suspend/resume' signal handler $SIG{'STOP'} = sub { $sema->down(); # Thread suspended $sema->up(); # Thread resumes }; ... } # Create a semaphore and pass it to a thread my $sema = Thread::Semaphore->new(); my $thr = threads->create('thr_func', $sema); # Suspend the thread $sema->down(); $thr->kill('STOP'); ... # Allow the thread to continue $sema->up(); CAVEAT: The thread signalling capability provided by this module does not actually send signals via the OS. It I signals at the Perl-level such that signal handlers are called in the appropriate thread. For example, sending C<$thr-Ekill('STOP')> does not actually suspend a thread (or the whole process), but does cause a C<$SIG{'STOP'}> handler to be called in that thread (as illustrated above). As such, signals that would normally not be appropriate to use in the C command (e.g., C) are okay to use with the C<-Ekill()> method (again, as illustrated above). Correspondingly, sending a signal to a thread does not disrupt the operation the thread is currently working on: The signal will be acted upon after the current operation has completed. For instance, if the thread is I on an I/O call, sending it a signal will not cause the I/O call to be interrupted such that the signal is acted up immediately. Sending a signal to a terminated thread is ignored. =head1 WARNINGS =over 4 =item Perl exited with active threads: If the program exits without all threads having either been joined or detached, then this warning will be issued. NOTE: If the I
thread exits, then this warning cannot be suppressed using C as suggested below. =item Thread creation failed: pthread_create returned # See the appropriate I page for C to determine the actual cause for the failure. =item Thread # terminated abnormally: ... A thread terminated in some manner other than just returning from its entry point function, or by using Cexit()>. For example, the thread may have terminated because of an error, or by using C. =item Using minimum thread stack size of # Some platforms have a minimum thread stack size. Trying to set the stack size below this value will result in the above warning, and the stack size will be set to the minimum. =item Thread creation failed: pthread_attr_setstacksize(I) returned 22 The specified I exceeds the system's maximum stack size. Use a smaller value for the stack size. =back If needed, thread warnings can be suppressed by using: no warnings 'threads'; in the appropriate scope. =head1 ERRORS =over 4 =item This Perl not built to support threads The particular copy of Perl that you're trying to use was not built using the C configuration option. Having threads support requires all of Perl and all of the XS modules in the Perl installation to be rebuilt; it is not just a question of adding the L module (i.e., threaded and non-threaded Perls are binary incompatible.) =item Cannot change stack size of an existing thread The stack size of currently extant threads cannot be changed, therefore, the following results in the above error: $thr->set_stack_size($size); =item Cannot signal threads without safe signals Safe signals must be in effect to use the C<-Ekill()> signalling method. See L for more details. =item Unrecognized signal name: ... The particular copy of Perl that you're trying to use does not support the specified signal being used in a C<-Ekill()> call. =back =head1 BUGS AND LIMITATIONS Before you consider posting a bug report, please consult, and possibly post a message to the discussion forum to see if what you've encountered is a known problem. =over =item Thread-safe modules See L when creating modules that may be used in threaded applications, especially if those modules use non-Perl data, or XS code. =item Using non-thread-safe modules Unfortunately, you may encounter Perl modules that are not I. For example, they may crash the Perl interpreter during execution, or may dump core on termination. Depending on the module and the requirements of your application, it may be possible to work around such difficulties. If the module will only be used inside a thread, you can try loading the module from inside the thread entry point function using C (and C if needed): sub thr_func { require Unsafe::Module # Unsafe::Module->import(...); .... } If the module is needed inside the I
thread, try modifying your application so that the module is loaded (again using C and C<-Eimport()>) after any threads are started, and in such a way that no other threads are started afterwards. If the above does not work, or is not adequate for your application, then file a bug report on L against the problematic module. =item Current working directory On all platforms except MSWin32, the setting for the current working directory is shared among all threads such that changing it in one thread (e.g., using C) will affect all the threads in the application. On MSWin32, each thread maintains its own the current working directory setting. =item Environment variables Currently, on all platforms except MSWin32, all I calls (e.g., using C or back-ticks) made from threads use the environment variable settings from the I
thread. In other words, changes made to C<%ENV> in a thread will not be visible in I calls made by that thread. To work around this, set environment variables as part of the I call. For example: my $msg = 'hello'; system("FOO=$msg; echo \$FOO"); # Outputs 'hello' to STDOUT On MSWin32, each thread maintains its own set of environment variables. =item Parent-child threads On some platforms, it might not be possible to destroy I threads while there are still existing I threads. =item Creating threads inside special blocks Creating threads inside C, C or C blocks should not be relied upon. Depending on the Perl version and the application code, results may range from success, to (apparently harmless) warnings of leaked scalar, or all the way up to crashing of the Perl interpreter. =item Unsafe signals Since Perl 5.8.0, signals have been made safer in Perl by postponing their handling until the interpreter is in a I state. See L and L for more details. Safe signals is the default behavior, and the old, immediate, unsafe signalling behavior is only in effect in the following situations: =over 4 =item * Perl has been built with C (see C). =item * The environment variable C is set to C (see L). =item * The module L is used. =back If unsafe signals is in effect, then signal handling is not thread-safe, and the C<-Ekill()> signalling method cannot be used. =item Returning closures from threads Returning closures from threads should not be relied upon. Depending of the Perl version and the application code, results may range from success, to (apparently harmless) warnings of leaked scalar, or all the way up to crashing of the Perl interpreter. =item Returning objects from threads Returning objects from threads does not work. Depending on the classes involved, you may be able to work around this by returning a serialized version of the object (e.g., using L or L), and then reconstituting it in the joining thread. If you're using Perl 5.10.0 or later, and if the class supports L, you can pass them via L. =item END blocks in threads It is possible to add L to threads by using L or L with the appropriate code. These C blocks will then be executed when the thread's interpreter is destroyed (i.e., either during a C<-Ejoin()> call, or at program termination). However, calling any L methods in such an C block will most likely I (e.g., the application may hang, or generate an error) due to mutexes that are needed to control functionality within the L module. For this reason, the use of C blocks in threads is B discouraged. =item Perl Bugs and the CPAN Version of L Support for threads extends beyond the code in this module (i.e., F and F), and into the Perl interpreter itself. Older versions of Perl contain bugs that may manifest themselves despite using the latest version of L from CPAN. There is no workaround for this other than upgrading to the latest version of Perl. Even with the latest version of Perl, it is known that certain constructs with threads may result in warning messages concerning leaked scalars or unreferenced scalars. However, such warnings are harmless, and may safely be ignored. You can search for L related bug reports at L. If needed submit any new bugs, problems, patches, etc. to: L =back =head1 REQUIREMENTS Perl 5.8.0 or later =head1 SEE ALSO L Discussion Forum on CPAN: L Annotated POD for L: L Source repository: L L, L L and L Perl threads mailing list: L Stack size discussion: L =head1 AUTHOR Artur Bergman Esky AT crucially DOT netE CPAN version produced by Jerry D. Hedden =head1 LICENSE threads is released under the same license as Perl. =head1 ACKNOWLEDGEMENTS Richard Soderberg Eperl AT crystalflame DOT netE - Helping me out tons, trying to find reasons for races and other weird bugs! Simon Cozens Esimon AT brecon DOT co DOT ukE - Being there to answer zillions of annoying questions Rocco Caputo Etroc AT netrus DOT netE Vipul Ved Prakash Email AT vipul DOT netE - Helping with debugging Dean Arnold Edarnold AT presicient DOT comE - Stack size API =cut PK[[> 5.10.1/SDBM_File.pmnuW+Apackage SDBM_File; use strict; use warnings; require Tie::Hash; use XSLoader (); our @ISA = qw(Tie::Hash); our $VERSION = "1.06"; XSLoader::load 'SDBM_File', $VERSION; 1; __END__ =head1 NAME SDBM_File - Tied access to sdbm files =head1 SYNOPSIS use Fcntl; # For O_RDWR, O_CREAT, etc. use SDBM_File; tie(%h, 'SDBM_File', 'filename', O_RDWR|O_CREAT, 0666) or die "Couldn't tie SDBM file 'filename': $!; aborting"; # Now read and change the hash $h{newkey} = newvalue; print $h{oldkey}; ... untie %h; =head1 DESCRIPTION C establishes a connection between a Perl hash variable and a file in SDBM_File format;. You can manipulate the data in the file just as if it were in a Perl hash, but when your program exits, the data will remain in the file, to be used the next time your program runs. Use C with the Perl built-in C function to establish the connection between the variable and the file. The arguments to C should be: =over 4 =item 1. The hash variable you want to tie. =item 2. The string C<"SDBM_File">. (Ths tells Perl to use the C package to perform the functions of the hash.) =item 3. The name of the file you want to tie to the hash. =item 4. Flags. Use one of: =over 2 =item C Read-only access to the data in the file. =item C Write-only access to the data in the file. =item C Both read and write access. =back If you want to create the file if it does not exist, add C to any of these, as in the example. If you omit C and the file does not already exist, the C call will fail. =item 5. The default permissions to use if a new file is created. The actual permissions will be modified by the user's umask, so you should probably use 0666 here. (See L.) =back =head1 DIAGNOSTICS On failure, the C call returns an undefined value and probably sets C<$!> to contain the reason the file could not be tied. =head2 C This warning is emitted when you try to store a key or a value that is too long. It means that the change was not recorded in the database. See BUGS AND WARNINGS below. =head1 BUGS AND WARNINGS There are a number of limits on the size of the data that you can store in the SDBM file. The most important is that the length of a key, plus the length of its associated value, may not exceed 1008 bytes. See L, L, L =cut PK[[,{5.10.1/Data/Dumper.pmnuW+A# # Data/Dumper.pm # # convert perl data structures into perl syntax suitable for both printing # and eval # # Documentation at the __END__ # package Data::Dumper; $VERSION = '2.124'; # Don't forget to set version and release date in POD! #$| = 1; use 5.006_001; require Exporter; require overload; use Carp; BEGIN { @ISA = qw(Exporter); @EXPORT = qw(Dumper); @EXPORT_OK = qw(DumperX); # if run under miniperl, or otherwise lacking dynamic loading, # XSLoader should be attempted to load, or the pure perl flag # toggled on load failure. eval { require XSLoader; }; $Useperl = 1 if $@; } XSLoader::load( 'Data::Dumper' ) unless $Useperl; # module vars and their defaults $Indent = 2 unless defined $Indent; $Purity = 0 unless defined $Purity; $Pad = "" unless defined $Pad; $Varname = "VAR" unless defined $Varname; $Useqq = 0 unless defined $Useqq; $Terse = 0 unless defined $Terse; $Freezer = "" unless defined $Freezer; $Toaster = "" unless defined $Toaster; $Deepcopy = 0 unless defined $Deepcopy; $Quotekeys = 1 unless defined $Quotekeys; $Bless = "bless" unless defined $Bless; #$Expdepth = 0 unless defined $Expdepth; $Maxdepth = 0 unless defined $Maxdepth; $Pair = ' => ' unless defined $Pair; $Useperl = 0 unless defined $Useperl; $Sortkeys = 0 unless defined $Sortkeys; $Deparse = 0 unless defined $Deparse; # # expects an arrayref of values to be dumped. # can optionally pass an arrayref of names for the values. # names must have leading $ sign stripped. begin the name with * # to cause output of arrays and hashes rather than refs. # sub new { my($c, $v, $n) = @_; croak "Usage: PACKAGE->new(ARRAYREF, [ARRAYREF])" unless (defined($v) && (ref($v) eq 'ARRAY')); $n = [] unless (defined($n) && (ref($n) eq 'ARRAY')); my($s) = { level => 0, # current recursive depth indent => $Indent, # various styles of indenting pad => $Pad, # all lines prefixed by this string xpad => "", # padding-per-level apad => "", # added padding for hash keys n such sep => "", # list separator pair => $Pair, # hash key/value separator: defaults to ' => ' seen => {}, # local (nested) refs (id => [name, val]) todump => $v, # values to dump [] names => $n, # optional names for values [] varname => $Varname, # prefix to use for tagging nameless ones purity => $Purity, # degree to which output is evalable useqq => $Useqq, # use "" for strings (backslashitis ensues) terse => $Terse, # avoid name output (where feasible) freezer => $Freezer, # name of Freezer method for objects toaster => $Toaster, # name of method to revive objects deepcopy => $Deepcopy, # dont cross-ref, except to stop recursion quotekeys => $Quotekeys, # quote hash keys 'bless' => $Bless, # keyword to use for "bless" # expdepth => $Expdepth, # cutoff depth for explicit dumping maxdepth => $Maxdepth, # depth beyond which we give up useperl => $Useperl, # use the pure Perl implementation sortkeys => $Sortkeys, # flag or filter for sorting hash keys deparse => $Deparse, # use B::Deparse for coderefs }; if ($Indent > 0) { $s->{xpad} = " "; $s->{sep} = "\n"; } return bless($s, $c); } if ($] >= 5.008) { # Packed numeric addresses take less memory. Plus pack is faster than sprintf *init_refaddr_format = sub {}; *format_refaddr = sub { require Scalar::Util; pack "J", Scalar::Util::refaddr(shift); }; } else { *init_refaddr_format = sub { require Config; my $f = $Config::Config{uvxformat}; $f =~ tr/"//d; our $refaddr_format = "0x%" . $f; }; *format_refaddr = sub { require Scalar::Util; sprintf our $refaddr_format, Scalar::Util::refaddr(shift); } } # # add-to or query the table of already seen references # sub Seen { my($s, $g) = @_; if (defined($g) && (ref($g) eq 'HASH')) { init_refaddr_format(); my($k, $v, $id); while (($k, $v) = each %$g) { if (defined $v and ref $v) { $id = format_refaddr($v); if ($k =~ /^[*](.*)$/) { $k = (ref $v eq 'ARRAY') ? ( "\\\@" . $1 ) : (ref $v eq 'HASH') ? ( "\\\%" . $1 ) : (ref $v eq 'CODE') ? ( "\\\&" . $1 ) : ( "\$" . $1 ) ; } elsif ($k !~ /^\$/) { $k = "\$" . $k; } $s->{seen}{$id} = [$k, $v]; } else { carp "Only refs supported, ignoring non-ref item \$$k"; } } return $s; } else { return map { @$_ } values %{$s->{seen}}; } } # # set or query the values to be dumped # sub Values { my($s, $v) = @_; if (defined($v) && (ref($v) eq 'ARRAY')) { $s->{todump} = [@$v]; # make a copy return $s; } else { return @{$s->{todump}}; } } # # set or query the names of the values to be dumped # sub Names { my($s, $n) = @_; if (defined($n) && (ref($n) eq 'ARRAY')) { $s->{names} = [@$n]; # make a copy return $s; } else { return @{$s->{names}}; } } sub DESTROY {} sub Dump { return &Dumpxs unless $Data::Dumper::Useperl || (ref($_[0]) && $_[0]->{useperl}) || $Data::Dumper::Useqq || (ref($_[0]) && $_[0]->{useqq}) || $Data::Dumper::Deparse || (ref($_[0]) && $_[0]->{deparse}); return &Dumpperl; } # # dump the refs in the current dumper object. # expects same args as new() if called via package name. # sub Dumpperl { my($s) = shift; my(@out, $val, $name); my($i) = 0; local(@post); init_refaddr_format(); $s = $s->new(@_) unless ref $s; for $val (@{$s->{todump}}) { my $out = ""; @post = (); $name = $s->{names}[$i++]; if (defined $name) { if ($name =~ /^[*](.*)$/) { if (defined $val) { $name = (ref $val eq 'ARRAY') ? ( "\@" . $1 ) : (ref $val eq 'HASH') ? ( "\%" . $1 ) : (ref $val eq 'CODE') ? ( "\*" . $1 ) : ( "\$" . $1 ) ; } else { $name = "\$" . $1; } } elsif ($name !~ /^\$/) { $name = "\$" . $name; } } else { $name = "\$" . $s->{varname} . $i; } my $valstr; { local($s->{apad}) = $s->{apad}; $s->{apad} .= ' ' x (length($name) + 3) if $s->{indent} >= 2; $valstr = $s->_dump($val, $name); } $valstr = "$name = " . $valstr . ';' if @post or !$s->{terse}; $out .= $s->{pad} . $valstr . $s->{sep}; $out .= $s->{pad} . join(';' . $s->{sep} . $s->{pad}, @post) . ';' . $s->{sep} if @post; push @out, $out; } return wantarray ? @out : join('', @out); } # wrap string in single quotes (escaping if needed) sub _quote { my $val = shift; $val =~ s/([\\\'])/\\$1/g; return "'" . $val . "'"; } # # twist, toil and turn; # and recurse, of course. # sometimes sordidly; # and curse if no recourse. # sub _dump { my($s, $val, $name) = @_; my($sname); my($out, $realpack, $realtype, $type, $ipad, $id, $blesspad); $type = ref $val; $out = ""; if ($type) { # Call the freezer method if it's specified and the object has the # method. Trap errors and warn() instead of die()ing, like the XS # implementation. my $freezer = $s->{freezer}; if ($freezer and UNIVERSAL::can($val, $freezer)) { eval { $val->$freezer() }; warn "WARNING(Freezer method call failed): $@" if $@; } require Scalar::Util; $realpack = Scalar::Util::blessed($val); $realtype = $realpack ? Scalar::Util::reftype($val) : ref $val; $id = format_refaddr($val); # if it has a name, we need to either look it up, or keep a tab # on it so we know when we hit it later if (defined($name) and length($name)) { # keep a tab on it so that we dont fall into recursive pit if (exists $s->{seen}{$id}) { # if ($s->{expdepth} < $s->{level}) { if ($s->{purity} and $s->{level} > 0) { $out = ($realtype eq 'HASH') ? '{}' : ($realtype eq 'ARRAY') ? '[]' : 'do{my $o}' ; push @post, $name . " = " . $s->{seen}{$id}[0]; } else { $out = $s->{seen}{$id}[0]; if ($name =~ /^([\@\%])/) { my $start = $1; if ($out =~ /^\\$start/) { $out = substr($out, 1); } else { $out = $start . '{' . $out . '}'; } } } return $out; # } } else { # store our name $s->{seen}{$id} = [ (($name =~ /^[@%]/) ? ('\\' . $name ) : ($realtype eq 'CODE' and $name =~ /^[*](.*)$/) ? ('\\&' . $1 ) : $name ), $val ]; } } my $no_bless = 0; my $is_regex = 0; if ( $realpack and ($] >= 5.009005 ? re::is_regexp($val) : $realpack eq 'Regexp') ) { $is_regex = 1; $no_bless = $realpack eq 'Regexp'; } # If purity is not set and maxdepth is set, then check depth: # if we have reached maximum depth, return the string # representation of the thing we are currently examining # at this depth (i.e., 'Foo=ARRAY(0xdeadbeef)'). if (!$s->{purity} and $s->{maxdepth} > 0 and $s->{level} >= $s->{maxdepth}) { return qq['$val']; } # we have a blessed ref if ($realpack and !$no_bless) { $out = $s->{'bless'} . '( '; $blesspad = $s->{apad}; $s->{apad} .= ' ' if ($s->{indent} >= 2); } $s->{level}++; $ipad = $s->{xpad} x $s->{level}; if ($is_regex) { my $pat; # This really sucks, re:regexp_pattern is in ext/re/re.xs and not in # universal.c, and even worse we cant just require that re to be loaded # we *have* to use() it. # We should probably move it to universal.c for 5.10.1 and fix this. # Currently we only use re::regexp_pattern when the re is blessed into another # package. This has the disadvantage of meaning that a DD dump won't round trip # as the pattern will be repeatedly wrapped with the same modifiers. # This is an aesthetic issue so we will leave it for now, but we could use # regexp_pattern() in list context to get the modifiers separately. # But since this means loading the full debugging engine in process we wont # bother unless its necessary for accuracy. if (($realpack ne 'Regexp') && defined(*re::regexp_pattern{CODE})) { $pat = re::regexp_pattern($val); } else { $pat = "$val"; } $pat =~ s,/,\\/,g; $out .= "qr/$pat/"; } elsif ($realtype eq 'SCALAR' || $realtype eq 'REF') { if ($realpack) { $out .= 'do{\\(my $o = ' . $s->_dump($$val, "\${$name}") . ')}'; } else { $out .= '\\' . $s->_dump($$val, "\${$name}"); } } elsif ($realtype eq 'GLOB') { $out .= '\\' . $s->_dump($$val, "*{$name}"); } elsif ($realtype eq 'ARRAY') { my($v, $pad, $mname); my($i) = 0; $out .= ($name =~ /^\@/) ? '(' : '['; $pad = $s->{sep} . $s->{pad} . $s->{apad}; ($name =~ /^\@(.*)$/) ? ($mname = "\$" . $1) : # omit -> if $foo->[0]->{bar}, but not ${$foo->[0]}->{bar} ($name =~ /^\\?[\%\@\*\$][^{].*[]}]$/) ? ($mname = $name) : ($mname = $name . '->'); $mname .= '->' if $mname =~ /^\*.+\{[A-Z]+\}$/; for $v (@$val) { $sname = $mname . '[' . $i . ']'; $out .= $pad . $ipad . '#' . $i if $s->{indent} >= 3; $out .= $pad . $ipad . $s->_dump($v, $sname); $out .= "," if $i++ < $#$val; } $out .= $pad . ($s->{xpad} x ($s->{level} - 1)) if $i; $out .= ($name =~ /^\@/) ? ')' : ']'; } elsif ($realtype eq 'HASH') { my($k, $v, $pad, $lpad, $mname, $pair); $out .= ($name =~ /^\%/) ? '(' : '{'; $pad = $s->{sep} . $s->{pad} . $s->{apad}; $lpad = $s->{apad}; $pair = $s->{pair}; ($name =~ /^\%(.*)$/) ? ($mname = "\$" . $1) : # omit -> if $foo->[0]->{bar}, but not ${$foo->[0]}->{bar} ($name =~ /^\\?[\%\@\*\$][^{].*[]}]$/) ? ($mname = $name) : ($mname = $name . '->'); $mname .= '->' if $mname =~ /^\*.+\{[A-Z]+\}$/; my ($sortkeys, $keys, $key) = ("$s->{sortkeys}"); if ($sortkeys) { if (ref($s->{sortkeys}) eq 'CODE') { $keys = $s->{sortkeys}($val); unless (ref($keys) eq 'ARRAY') { carp "Sortkeys subroutine did not return ARRAYREF"; $keys = []; } } else { $keys = [ sort keys %$val ]; } } # Ensure hash iterator is reset keys(%$val); while (($k, $v) = ! $sortkeys ? (each %$val) : @$keys ? ($key = shift(@$keys), $val->{$key}) : () ) { my $nk = $s->_dump($k, ""); $nk = $1 if !$s->{quotekeys} and $nk =~ /^[\"\']([A-Za-z_]\w*)[\"\']$/; $sname = $mname . '{' . $nk . '}'; $out .= $pad . $ipad . $nk . $pair; # temporarily alter apad $s->{apad} .= (" " x (length($nk) + 4)) if $s->{indent} >= 2; $out .= $s->_dump($val->{$k}, $sname) . ","; $s->{apad} = $lpad if $s->{indent} >= 2; } if (substr($out, -1) eq ',') { chop $out; $out .= $pad . ($s->{xpad} x ($s->{level} - 1)); } $out .= ($name =~ /^\%/) ? ')' : '}'; } elsif ($realtype eq 'CODE') { if ($s->{deparse}) { require B::Deparse; my $sub = 'sub ' . (B::Deparse->new)->coderef2text($val); $pad = $s->{sep} . $s->{pad} . $s->{apad} . $s->{xpad} x ($s->{level} - 1); $sub =~ s/\n/$pad/gse; $out .= $sub; } else { $out .= 'sub { "DUMMY" }'; carp "Encountered CODE ref, using dummy placeholder" if $s->{purity}; } } else { croak "Can\'t handle $realtype type."; } if ($realpack and !$no_bless) { # we have a blessed ref $out .= ', ' . _quote($realpack) . ' )'; $out .= '->' . $s->{toaster} . '()' if $s->{toaster} ne ''; $s->{apad} = $blesspad; } $s->{level}--; } else { # simple scalar my $ref = \$_[1]; # first, catalog the scalar if ($name ne '') { $id = format_refaddr($ref); if (exists $s->{seen}{$id}) { if ($s->{seen}{$id}[2]) { $out = $s->{seen}{$id}[0]; #warn "[<$out]\n"; return "\${$out}"; } } else { #warn "[>\\$name]\n"; $s->{seen}{$id} = ["\\$name", $ref]; } } if (ref($ref) eq 'GLOB' or "$ref" =~ /=GLOB\([^()]+\)$/) { # glob my $name = substr($val, 1); if ($name =~ /^[A-Za-z_][\w:]*$/) { $name =~ s/^main::/::/; $sname = $name; } else { $sname = $s->_dump($name, ""); $sname = '{' . $sname . '}'; } if ($s->{purity}) { my $k; local ($s->{level}) = 0; for $k (qw(SCALAR ARRAY HASH)) { my $gval = *$val{$k}; next unless defined $gval; next if $k eq "SCALAR" && ! defined $$gval; # always there # _dump can push into @post, so we hold our place using $postlen my $postlen = scalar @post; $post[$postlen] = "\*$sname = "; local ($s->{apad}) = " " x length($post[$postlen]) if $s->{indent} >= 2; $post[$postlen] .= $s->_dump($gval, "\*$sname\{$k\}"); } } $out .= '*' . $sname; } elsif (!defined($val)) { $out .= "undef"; } elsif ($val =~ /^(?:0|-?[1-9]\d{0,8})\z/) { # safe decimal number $out .= $val; } else { # string if ($s->{useqq} or $val =~ tr/\0-\377//c) { # Fall back to qq if there's Unicode $out .= qquote($val, $s->{useqq}); } else { $out .= _quote($val); } } } if ($id) { # if we made it this far, $id was added to seen list at current # level, so remove it to get deep copies if ($s->{deepcopy}) { delete($s->{seen}{$id}); } elsif ($name) { $s->{seen}{$id}[2] = 1; } } return $out; } # # non-OO style of earlier version # sub Dumper { return Data::Dumper->Dump([@_]); } # compat stub sub DumperX { return Data::Dumper->Dumpxs([@_], []); } sub Dumpf { return Data::Dumper->Dump(@_) } sub Dumpp { print Data::Dumper->Dump(@_) } # # reset the "seen" cache # sub Reset { my($s) = shift; $s->{seen} = {}; return $s; } sub Indent { my($s, $v) = @_; if (defined($v)) { if ($v == 0) { $s->{xpad} = ""; $s->{sep} = ""; } else { $s->{xpad} = " "; $s->{sep} = "\n"; } $s->{indent} = $v; return $s; } else { return $s->{indent}; } } sub Pair { my($s, $v) = @_; defined($v) ? (($s->{pair} = $v), return $s) : $s->{pair}; } sub Pad { my($s, $v) = @_; defined($v) ? (($s->{pad} = $v), return $s) : $s->{pad}; } sub Varname { my($s, $v) = @_; defined($v) ? (($s->{varname} = $v), return $s) : $s->{varname}; } sub Purity { my($s, $v) = @_; defined($v) ? (($s->{purity} = $v), return $s) : $s->{purity}; } sub Useqq { my($s, $v) = @_; defined($v) ? (($s->{useqq} = $v), return $s) : $s->{useqq}; } sub Terse { my($s, $v) = @_; defined($v) ? (($s->{terse} = $v), return $s) : $s->{terse}; } sub Freezer { my($s, $v) = @_; defined($v) ? (($s->{freezer} = $v), return $s) : $s->{freezer}; } sub Toaster { my($s, $v) = @_; defined($v) ? (($s->{toaster} = $v), return $s) : $s->{toaster}; } sub Deepcopy { my($s, $v) = @_; defined($v) ? (($s->{deepcopy} = $v), return $s) : $s->{deepcopy}; } sub Quotekeys { my($s, $v) = @_; defined($v) ? (($s->{quotekeys} = $v), return $s) : $s->{quotekeys}; } sub Bless { my($s, $v) = @_; defined($v) ? (($s->{'bless'} = $v), return $s) : $s->{'bless'}; } sub Maxdepth { my($s, $v) = @_; defined($v) ? (($s->{'maxdepth'} = $v), return $s) : $s->{'maxdepth'}; } sub Useperl { my($s, $v) = @_; defined($v) ? (($s->{'useperl'} = $v), return $s) : $s->{'useperl'}; } sub Sortkeys { my($s, $v) = @_; defined($v) ? (($s->{'sortkeys'} = $v), return $s) : $s->{'sortkeys'}; } sub Deparse { my($s, $v) = @_; defined($v) ? (($s->{'deparse'} = $v), return $s) : $s->{'deparse'}; } # used by qquote below my %esc = ( "\a" => "\\a", "\b" => "\\b", "\t" => "\\t", "\n" => "\\n", "\f" => "\\f", "\r" => "\\r", "\e" => "\\e", ); # put a string value in double quotes sub qquote { local($_) = shift; s/([\\\"\@\$])/\\$1/g; my $bytes; { use bytes; $bytes = length } s/([^\x00-\x7f])/'\x{'.sprintf("%x",ord($1)).'}'/ge if $bytes > length; return qq("$_") unless /[^ !"\#\$%&'()*+,\-.\/0-9:;<=>?\@A-Z[\\\]^_`a-z{|}~]/; # fast exit my $high = shift || ""; s/([\a\b\t\n\f\r\e])/$esc{$1}/g; if (ord('^')==94) { # ascii # no need for 3 digits in escape for these s/([\0-\037])(?!\d)/'\\'.sprintf('%o',ord($1))/eg; s/([\0-\037\177])/'\\'.sprintf('%03o',ord($1))/eg; # all but last branch below not supported --BEHAVIOR SUBJECT TO CHANGE-- if ($high eq "iso8859") { s/([\200-\240])/'\\'.sprintf('%o',ord($1))/eg; } elsif ($high eq "utf8") { # use utf8; # $str =~ s/([^\040-\176])/sprintf "\\x{%04x}", ord($1)/ge; } elsif ($high eq "8bit") { # leave it as it is } else { s/([\200-\377])/'\\'.sprintf('%03o',ord($1))/eg; s/([^\040-\176])/sprintf "\\x{%04x}", ord($1)/ge; } } else { # ebcdic s{([^ !"\#\$%&'()*+,\-.\/0-9:;<=>?\@A-Z[\\\]^_`a-z{|}~])(?!\d)} {my $v = ord($1); '\\'.sprintf(($v <= 037 ? '%o' : '%03o'), $v)}eg; s{([^ !"\#\$%&'()*+,\-.\/0-9:;<=>?\@A-Z[\\\]^_`a-z{|}~])} {'\\'.sprintf('%03o',ord($1))}eg; } return qq("$_"); } # helper sub to sort hash keys in Perl < 5.8.0 where we don't have # access to sortsv() from XS sub _sortkeys { [ sort keys %{$_[0]} ] } 1; __END__ =head1 NAME Data::Dumper - stringified perl data structures, suitable for both printing and C =head1 SYNOPSIS use Data::Dumper; # simple procedural interface print Dumper($foo, $bar); # extended usage with names print Data::Dumper->Dump([$foo, $bar], [qw(foo *ary)]); # configuration variables { local $Data::Dumper::Purity = 1; eval Data::Dumper->Dump([$foo, $bar], [qw(foo *ary)]); } # OO usage $d = Data::Dumper->new([$foo, $bar], [qw(foo *ary)]); ... print $d->Dump; ... $d->Purity(1)->Terse(1)->Deepcopy(1); eval $d->Dump; =head1 DESCRIPTION Given a list of scalars or reference variables, writes out their contents in perl syntax. The references can also be objects. The contents of each variable is output in a single Perl statement. Handles self-referential structures correctly. The return value can be Ced to get back an identical copy of the original reference structure. Any references that are the same as one of those passed in will be named C<$VAR>I (where I is a numeric suffix), and other duplicate references to substructures within C<$VAR>I will be appropriately labeled using arrow notation. You can specify names for individual values to be dumped if you use the C method, or you can change the default C<$VAR> prefix to something else. See C<$Data::Dumper::Varname> and C<$Data::Dumper::Terse> below. The default output of self-referential structures can be Ced, but the nested references to C<$VAR>I will be undefined, since a recursive structure cannot be constructed using one Perl statement. You should set the C flag to 1 to get additional statements that will correctly fill in these references. Moreover, if Ced when strictures are in effect, you need to ensure that any variables it accesses are previously declared. In the extended usage form, the references to be dumped can be given user-specified names. If a name begins with a C<*>, the output will describe the dereferenced type of the supplied reference for hashes and arrays, and coderefs. Output of names will be avoided where possible if the C flag is set. In many cases, methods that are used to set the internal state of the object will return the object itself, so method calls can be conveniently chained together. Several styles of output are possible, all controlled by setting the C flag. See L below for details. =head2 Methods =over 4 =item I->new(I, I) Returns a newly created C object. The first argument is an anonymous array of values to be dumped. The optional second argument is an anonymous array of names for the values. The names need not have a leading C<$> sign, and must be comprised of alphanumeric characters. You can begin a name with a C<*> to specify that the dereferenced type must be dumped instead of the reference itself, for ARRAY and HASH references. The prefix specified by C<$Data::Dumper::Varname> will be used with a numeric suffix if the name for a value is undefined. Data::Dumper will catalog all references encountered while dumping the values. Cross-references (in the form of names of substructures in perl syntax) will be inserted at all possible points, preserving any structural interdependencies in the original set of values. Structure traversal is depth-first, and proceeds in order from the first supplied value to the last. =item I<$OBJ>->Dump I I->Dump(I, I) Returns the stringified form of the values stored in the object (preserving the order in which they were supplied to C), subject to the configuration options below. In a list context, it returns a list of strings corresponding to the supplied values. The second form, for convenience, simply calls the C method on its arguments before dumping the object immediately. =item I<$OBJ>->Seen(I<[HASHREF]>) Queries or adds to the internal table of already encountered references. You must use C to explicitly clear the table if needed. Such references are not dumped; instead, their names are inserted wherever they are encountered subsequently. This is useful especially for properly dumping subroutine references. Expects an anonymous hash of name => value pairs. Same rules apply for names as in C. If no argument is supplied, will return the "seen" list of name => value pairs, in a list context. Otherwise, returns the object itself. =item I<$OBJ>->Values(I<[ARRAYREF]>) Queries or replaces the internal array of values that will be dumped. When called without arguments, returns the values. Otherwise, returns the object itself. =item I<$OBJ>->Names(I<[ARRAYREF]>) Queries or replaces the internal array of user supplied names for the values that will be dumped. When called without arguments, returns the names. Otherwise, returns the object itself. =item I<$OBJ>->Reset Clears the internal table of "seen" references and returns the object itself. =back =head2 Functions =over 4 =item Dumper(I) Returns the stringified form of the values in the list, subject to the configuration options below. The values will be named C<$VAR>I in the output, where I is a numeric suffix. Will return a list of strings in a list context. =back =head2 Configuration Variables or Methods Several configuration variables can be used to control the kind of output generated when using the procedural interface. These variables are usually Cized in a block so that other parts of the code are not affected by the change. These variables determine the default state of the object created by calling the C method, but cannot be used to alter the state of the object thereafter. The equivalent method names should be used instead to query or set the internal state of the object. The method forms return the object itself when called with arguments, so that they can be chained together nicely. =over 4 =item * $Data::Dumper::Indent I I<$OBJ>->Indent(I<[NEWVAL]>) Controls the style of indentation. It can be set to 0, 1, 2 or 3. Style 0 spews output without any newlines, indentation, or spaces between list items. It is the most compact format possible that can still be called valid perl. Style 1 outputs a readable form with newlines but no fancy indentation (each level in the structure is simply indented by a fixed amount of whitespace). Style 2 (the default) outputs a very readable form which takes into account the length of hash keys (so the hash value lines up). Style 3 is like style 2, but also annotates the elements of arrays with their index (but the comment is on its own line, so array output consumes twice the number of lines). Style 2 is the default. =item * $Data::Dumper::Purity I I<$OBJ>->Purity(I<[NEWVAL]>) Controls the degree to which the output can be Ced to recreate the supplied reference structures. Setting it to 1 will output additional perl statements that will correctly recreate nested references. The default is 0. =item * $Data::Dumper::Pad I I<$OBJ>->Pad(I<[NEWVAL]>) Specifies the string that will be prefixed to every line of the output. Empty string by default. =item * $Data::Dumper::Varname I I<$OBJ>->Varname(I<[NEWVAL]>) Contains the prefix to use for tagging variable names in the output. The default is "VAR". =item * $Data::Dumper::Useqq I I<$OBJ>->Useqq(I<[NEWVAL]>) When set, enables the use of double quotes for representing string values. Whitespace other than space will be represented as C<[\n\t\r]>, "unsafe" characters will be backslashed, and unprintable characters will be output as quoted octal integers. Since setting this variable imposes a performance penalty, the default is 0. C will run slower if this flag is set, since the fast XSUB implementation doesn't support it yet. =item * $Data::Dumper::Terse I I<$OBJ>->Terse(I<[NEWVAL]>) When set, Data::Dumper will emit single, non-self-referential values as atoms/terms rather than statements. This means that the C<$VAR>I names will be avoided where possible, but be advised that such output may not always be parseable by C. =item * $Data::Dumper::Freezer I $I->Freezer(I<[NEWVAL]>) Can be set to a method name, or to an empty string to disable the feature. Data::Dumper will invoke that method via the object before attempting to stringify it. This method can alter the contents of the object (if, for instance, it contains data allocated from C), and even rebless it in a different package. The client is responsible for making sure the specified method can be called via the object, and that the object ends up containing only perl data types after the method has been called. Defaults to an empty string. If an object does not support the method specified (determined using UNIVERSAL::can()) then the call will be skipped. If the method dies a warning will be generated. =item * $Data::Dumper::Toaster I $I->Toaster(I<[NEWVAL]>) Can be set to a method name, or to an empty string to disable the feature. Data::Dumper will emit a method call for any objects that are to be dumped using the syntax CMETHOD()>. Note that this means that the method specified will have to perform any modifications required on the object (like creating new state within it, and/or reblessing it in a different package) and then return it. The client is responsible for making sure the method can be called via the object, and that it returns a valid object. Defaults to an empty string. =item * $Data::Dumper::Deepcopy I $I->Deepcopy(I<[NEWVAL]>) Can be set to a boolean value to enable deep copies of structures. Cross-referencing will then only be done when absolutely essential (i.e., to break reference cycles). Default is 0. =item * $Data::Dumper::Quotekeys I $I->Quotekeys(I<[NEWVAL]>) Can be set to a boolean value to control whether hash keys are quoted. A false value will avoid quoting hash keys when it looks like a simple string. Default is 1, which will always enclose hash keys in quotes. =item * $Data::Dumper::Bless I $I->Bless(I<[NEWVAL]>) Can be set to a string that specifies an alternative to the C builtin operator used to create objects. A function with the specified name should exist, and should accept the same arguments as the builtin. Default is C. =item * $Data::Dumper::Pair I $I->Pair(I<[NEWVAL]>) Can be set to a string that specifies the separator between hash keys and values. To dump nested hash, array and scalar values to JavaScript, use: C<$Data::Dumper::Pair = ' : ';>. Implementing C in JavaScript is left as an exercise for the reader. A function with the specified name exists, and accepts the same arguments as the builtin. Default is: C< =E >. =item * $Data::Dumper::Maxdepth I $I->Maxdepth(I<[NEWVAL]>) Can be set to a positive integer that specifies the depth beyond which which we don't venture into a structure. Has no effect when C is set. (Useful in debugger when we often don't want to see more than enough). Default is 0, which means there is no maximum depth. =item * $Data::Dumper::Useperl I $I->Useperl(I<[NEWVAL]>) Can be set to a boolean value which controls whether the pure Perl implementation of C is used. The C module is a dual implementation, with almost all functionality written in both pure Perl and also in XS ('C'). Since the XS version is much faster, it will always be used if possible. This option lets you override the default behavior, usually for testing purposes only. Default is 0, which means the XS implementation will be used if possible. =item * $Data::Dumper::Sortkeys I $I->Sortkeys(I<[NEWVAL]>) Can be set to a boolean value to control whether hash keys are dumped in sorted order. A true value will cause the keys of all hashes to be dumped in Perl's default sort order. Can also be set to a subroutine reference which will be called for each hash that is dumped. In this case C will call the subroutine once for each hash, passing it the reference of the hash. The purpose of the subroutine is to return a reference to an array of the keys that will be dumped, in the order that they should be dumped. Using this feature, you can control both the order of the keys, and which keys are actually used. In other words, this subroutine acts as a filter by which you can exclude certain keys from being dumped. Default is 0, which means that hash keys are not sorted. =item * $Data::Dumper::Deparse I $I->Deparse(I<[NEWVAL]>) Can be set to a boolean value to control whether code references are turned into perl source code. If set to a true value, C will be used to get the source of the code reference. Using this option will force using the Perl implementation of the dumper, since the fast XSUB implementation doesn't support it. Caution : use this option only if you know that your coderefs will be properly reconstructed by C. =back =head2 Exports =over 4 =item Dumper =back =head1 EXAMPLES Run these code snippets to get a quick feel for the behavior of this module. When you are through with these examples, you may want to add or change the various configuration variables described above, to see their behavior. (See the testsuite in the Data::Dumper distribution for more examples.) use Data::Dumper; package Foo; sub new {bless {'a' => 1, 'b' => sub { return "foo" }}, $_[0]}; package Fuz; # a weird REF-REF-SCALAR object sub new {bless \($_ = \ 'fu\'z'), $_[0]}; package main; $foo = Foo->new; $fuz = Fuz->new; $boo = [ 1, [], "abcd", \*foo, {1 => 'a', 023 => 'b', 0x45 => 'c'}, \\"p\q\'r", $foo, $fuz]; ######## # simple usage ######## $bar = eval(Dumper($boo)); print($@) if $@; print Dumper($boo), Dumper($bar); # pretty print (no array indices) $Data::Dumper::Terse = 1; # don't output names where feasible $Data::Dumper::Indent = 0; # turn off all pretty print print Dumper($boo), "\n"; $Data::Dumper::Indent = 1; # mild pretty print print Dumper($boo); $Data::Dumper::Indent = 3; # pretty print with array indices print Dumper($boo); $Data::Dumper::Useqq = 1; # print strings in double quotes print Dumper($boo); $Data::Dumper::Pair = " : "; # specify hash key/value separator print Dumper($boo); ######## # recursive structures ######## @c = ('c'); $c = \@c; $b = {}; $a = [1, $b, $c]; $b->{a} = $a; $b->{b} = $a->[1]; $b->{c} = $a->[2]; print Data::Dumper->Dump([$a,$b,$c], [qw(a b c)]); $Data::Dumper::Purity = 1; # fill in the holes for eval print Data::Dumper->Dump([$a, $b], [qw(*a b)]); # print as @a print Data::Dumper->Dump([$b, $a], [qw(*b a)]); # print as %b $Data::Dumper::Deepcopy = 1; # avoid cross-refs print Data::Dumper->Dump([$b, $a], [qw(*b a)]); $Data::Dumper::Purity = 0; # avoid cross-refs print Data::Dumper->Dump([$b, $a], [qw(*b a)]); ######## # deep structures ######## $a = "pearl"; $b = [ $a ]; $c = { 'b' => $b }; $d = [ $c ]; $e = { 'd' => $d }; $f = { 'e' => $e }; print Data::Dumper->Dump([$f], [qw(f)]); $Data::Dumper::Maxdepth = 3; # no deeper than 3 refs down print Data::Dumper->Dump([$f], [qw(f)]); ######## # object-oriented usage ######## $d = Data::Dumper->new([$a,$b], [qw(a b)]); $d->Seen({'*c' => $c}); # stash a ref without printing it $d->Indent(3); print $d->Dump; $d->Reset->Purity(0); # empty the seen cache print join "----\n", $d->Dump; ######## # persistence ######## package Foo; sub new { bless { state => 'awake' }, shift } sub Freeze { my $s = shift; print STDERR "preparing to sleep\n"; $s->{state} = 'asleep'; return bless $s, 'Foo::ZZZ'; } package Foo::ZZZ; sub Thaw { my $s = shift; print STDERR "waking up\n"; $s->{state} = 'awake'; return bless $s, 'Foo'; } package Foo; use Data::Dumper; $a = Foo->new; $b = Data::Dumper->new([$a], ['c']); $b->Freezer('Freeze'); $b->Toaster('Thaw'); $c = $b->Dump; print $c; $d = eval $c; print Data::Dumper->Dump([$d], ['d']); ######## # symbol substitution (useful for recreating CODE refs) ######## sub foo { print "foo speaking\n" } *other = \&foo; $bar = [ \&other ]; $d = Data::Dumper->new([\&other,$bar],['*other','bar']); $d->Seen({ '*foo' => \&foo }); print $d->Dump; ######## # sorting and filtering hash keys ######## $Data::Dumper::Sortkeys = \&my_filter; my $foo = { map { (ord, "$_$_$_") } 'I'..'Q' }; my $bar = { %$foo }; my $baz = { reverse %$foo }; print Dumper [ $foo, $bar, $baz ]; sub my_filter { my ($hash) = @_; # return an array ref containing the hash keys to dump # in the order that you want them to be dumped return [ # Sort the keys of %$foo in reverse numeric order $hash eq $foo ? (sort {$b <=> $a} keys %$hash) : # Only dump the odd number keys of %$bar $hash eq $bar ? (grep {$_ % 2} keys %$hash) : # Sort keys in default order for all other hashes (sort keys %$hash) ]; } =head1 BUGS Due to limitations of Perl subroutine call semantics, you cannot pass an array or hash. Prepend it with a C<\> to pass its reference instead. This will be remedied in time, now that Perl has subroutine prototypes. For now, you need to use the extended usage form, and prepend the name with a C<*> to output it as a hash or array. C cheats with CODE references. If a code reference is encountered in the structure being processed (and if you haven't set the C flag), an anonymous subroutine that contains the string '"DUMMY"' will be inserted in its place, and a warning will be printed if C is set. You can C the result, but bear in mind that the anonymous sub that gets created is just a placeholder. Someday, perl will have a switch to cache-on-demand the string representation of a compiled piece of code, I hope. If you have prior knowledge of all the code refs that your data structures are likely to have, you can use the C method to pre-seed the internal reference table and make the dumped output point to them, instead. See L above. The C and C flags makes Dump() run slower, since the XSUB implementation does not support them. SCALAR objects have the weirdest looking C workaround. Pure Perl version of C escapes UTF-8 strings correctly only in Perl 5.8.0 and later. =head2 NOTE Starting from Perl 5.8.1 different runs of Perl will have different ordering of hash keys. The change was done for greater security, see L. This means that different runs of Perl will have different Data::Dumper outputs if the data contains hashes. If you need to have identical Data::Dumper outputs from different runs of Perl, use the environment variable PERL_HASH_SEED, see L. Using this restores the old (platform-specific) ordering: an even prettier solution might be to use the C filter of Data::Dumper. =head1 AUTHOR Gurusamy Sarathy gsar@activestate.com Copyright (c) 1996-98 Gurusamy Sarathy. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 VERSION Version 2.124 (Jun 13 2009) =head1 SEE ALSO perl(1) =cut PK[[+5.10.1/Scalar/Util.pmnuW+A# Scalar::Util.pm # # Copyright (c) 1997-2007 Graham Barr . All rights reserved. # This program is free software; you can redistribute it and/or # modify it under the same terms as Perl itself. package Scalar::Util; use strict; use vars qw(@ISA @EXPORT_OK $VERSION @EXPORT_FAIL); require Exporter; require List::Util; # List::Util loads the XS @ISA = qw(Exporter); @EXPORT_OK = qw(blessed dualvar reftype weaken isweak tainted readonly openhandle refaddr isvstring looks_like_number set_prototype); $VERSION = "1.21"; $VERSION = eval $VERSION; unless (defined &dualvar) { # Load Pure Perl version if XS not loaded require Scalar::Util::PP; Scalar::Util::PP->import; push @EXPORT_FAIL, qw(weaken isweak dualvar isvstring set_prototype); } sub export_fail { if (grep { /dualvar/ } @EXPORT_FAIL) { # no XS loaded my $pat = join("|", @EXPORT_FAIL); if (my ($err) = grep { /^($pat)$/ } @_ ) { require Carp; Carp::croak("$err is only available with the XS version of Scalar::Util"); } } if (grep { /^(weaken|isweak)$/ } @_ ) { require Carp; Carp::croak("Weak references are not implemented in the version of perl"); } if (grep { /^(isvstring)$/ } @_ ) { require Carp; Carp::croak("Vstrings are not implemented in the version of perl"); } @_; } sub openhandle ($) { my $fh = shift; my $rt = reftype($fh) || ''; return defined(fileno($fh)) ? $fh : undef if $rt eq 'IO'; if (reftype(\$fh) eq 'GLOB') { # handle openhandle(*DATA) $fh = \(my $tmp=$fh); } elsif ($rt ne 'GLOB') { return undef; } (tied(*$fh) or defined(fileno($fh))) ? $fh : undef; } 1; __END__ PK[[Q5.10.1/Scalar/Util/PP.pmnuW+A# Scalar::Util::PP.pm # # Copyright (c) 1997-2009 Graham Barr . All rights reserved. # This program is free software; you can redistribute it and/or # modify it under the same terms as Perl itself. # # This module is normally only loaded if the XS module is not available package Scalar::Util::PP; use strict; use warnings; use vars qw(@ISA @EXPORT $VERSION $recurse); require Exporter; use B qw(svref_2object); @ISA = qw(Exporter); @EXPORT = qw(blessed reftype tainted readonly refaddr looks_like_number); $VERSION = "1.21"; $VERSION = eval $VERSION; sub blessed ($) { return undef unless length(ref($_[0])); my $b = svref_2object($_[0]); return undef unless $b->isa('B::PVMG'); my $s = $b->SvSTASH; return $s->isa('B::HV') ? $s->NAME : undef; } sub refaddr($) { return undef unless length(ref($_[0])); my $addr; if(defined(my $pkg = blessed($_[0]))) { $addr .= bless $_[0], 'Scalar::Util::Fake'; bless $_[0], $pkg; } else { $addr .= $_[0] } $addr =~ /0x(\w+)/; local $^W; hex($1); } { my %tmap = qw( B::HV HASH B::AV ARRAY B::CV CODE B::IO IO B::NULL SCALAR B::NV SCALAR B::PV SCALAR B::GV GLOB B::RV REF B::REGEXP REGEXP ); sub reftype ($) { my $r = shift; return undef unless length(ref($r)); my $t = ref(svref_2object($r)); return exists $tmap{$t} ? $tmap{$t} : length(ref($$r)) ? 'REF' : 'SCALAR'; } } sub tainted { local($@, $SIG{__DIE__}, $SIG{__WARN__}); local $^W = 0; no warnings; eval { kill 0 * $_[0] }; $@ =~ /^Insecure/; } sub readonly { return 0 if tied($_[0]) || (ref(\($_[0])) ne "SCALAR"); local($@, $SIG{__DIE__}, $SIG{__WARN__}); my $tmp = $_[0]; !eval { $_[0] = $tmp; 1 }; } sub looks_like_number { local $_ = shift; # checks from perlfaq4 return 0 if !defined($_); if (ref($_)) { require overload; return overload::Overloaded($_) ? defined(0 + $_) : 0; } return 1 if (/^[+-]?\d+$/); # is a +/- integer return 1 if (/^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/); # a C float return 1 if ($] >= 5.008 and /^(Inf(inity)?|NaN)$/i) or ($] >= 5.006001 and /^Inf$/i); 0; } 1; PK[[rQº5.10.1/asm-generic/termios.phnuW+Arequire '_h2ph_pre.ph'; no warnings qw(redefine misc); unless(defined(&_ASM_GENERIC_TERMIOS_H)) { eval 'sub _ASM_GENERIC_TERMIOS_H () {1;}' unless defined(&_ASM_GENERIC_TERMIOS_H); require 'asm/termbits.ph'; require 'asm/ioctls.ph'; eval 'sub NCC () {8;}' unless defined(&NCC); eval 'sub TIOCM_LE () {0x1;}' unless defined(&TIOCM_LE); eval 'sub TIOCM_DTR () {0x2;}' unless defined(&TIOCM_DTR); eval 'sub TIOCM_RTS () {0x4;}' unless defined(&TIOCM_RTS); eval 'sub TIOCM_ST () {0x8;}' unless defined(&TIOCM_ST); eval 'sub TIOCM_SR () {0x10;}' unless defined(&TIOCM_SR); eval 'sub TIOCM_CTS () {0x20;}' unless defined(&TIOCM_CTS); eval 'sub TIOCM_CAR () {0x40;}' unless defined(&TIOCM_CAR); eval 'sub TIOCM_RNG () {0x80;}' unless defined(&TIOCM_RNG); eval 'sub TIOCM_DSR () {0x100;}' unless defined(&TIOCM_DSR); eval 'sub TIOCM_CD () { &TIOCM_CAR;}' unless defined(&TIOCM_CD); eval 'sub TIOCM_RI () { &TIOCM_RNG;}' unless defined(&TIOCM_RI); eval 'sub TIOCM_OUT1 () {0x2000;}' unless defined(&TIOCM_OUT1); eval 'sub TIOCM_OUT2 () {0x4000;}' unless defined(&TIOCM_OUT2); eval 'sub TIOCM_LOOP () {0x8000;}' unless defined(&TIOCM_LOOP); } 1; PK[[q,{5.10.1/asm-generic/sockios.phnuW+Arequire '_h2ph_pre.ph'; no warnings qw(redefine misc); unless(defined(&__ASM_GENERIC_SOCKIOS_H)) { eval 'sub __ASM_GENERIC_SOCKIOS_H () {1;}' unless defined(&__ASM_GENERIC_SOCKIOS_H); eval 'sub FIOSETOWN () {0x8901;}' unless defined(&FIOSETOWN); eval 'sub SIOCSPGRP () {0x8902;}' unless defined(&SIOCSPGRP); eval 'sub FIOGETOWN () {0x8903;}' unless defined(&FIOGETOWN); eval 'sub SIOCGPGRP () {0x8904;}' unless defined(&SIOCGPGRP); eval 'sub SIOCATMARK () {0x8905;}' unless defined(&SIOCATMARK); eval 'sub SIOCGSTAMP () {0x8906;}' unless defined(&SIOCGSTAMP); eval 'sub SIOCGSTAMPNS () {0x8907;}' unless defined(&SIOCGSTAMPNS); } 1; PK[[N.' 5.10.1/asm-generic/socket.phnuW+Arequire '_h2ph_pre.ph'; no warnings qw(redefine misc); unless(defined(&__ASM_GENERIC_SOCKET_H)) { eval 'sub __ASM_GENERIC_SOCKET_H () {1;}' unless defined(&__ASM_GENERIC_SOCKET_H); require 'asm/sockios.ph'; eval 'sub SOL_SOCKET () {1;}' unless defined(&SOL_SOCKET); eval 'sub SO_DEBUG () {1;}' unless defined(&SO_DEBUG); eval 'sub SO_REUSEADDR () {2;}' unless defined(&SO_REUSEADDR); eval 'sub SO_TYPE () {3;}' unless defined(&SO_TYPE); eval 'sub SO_ERROR () {4;}' unless defined(&SO_ERROR); eval 'sub SO_DONTROUTE () {5;}' unless defined(&SO_DONTROUTE); eval 'sub SO_BROADCAST () {6;}' unless defined(&SO_BROADCAST); eval 'sub SO_SNDBUF () {7;}' unless defined(&SO_SNDBUF); eval 'sub SO_RCVBUF () {8;}' unless defined(&SO_RCVBUF); eval 'sub SO_SNDBUFFORCE () {32;}' unless defined(&SO_SNDBUFFORCE); eval 'sub SO_RCVBUFFORCE () {33;}' unless defined(&SO_RCVBUFFORCE); eval 'sub SO_KEEPALIVE () {9;}' unless defined(&SO_KEEPALIVE); eval 'sub SO_OOBINLINE () {10;}' unless defined(&SO_OOBINLINE); eval 'sub SO_NO_CHECK () {11;}' unless defined(&SO_NO_CHECK); eval 'sub SO_PRIORITY () {12;}' unless defined(&SO_PRIORITY); eval 'sub SO_LINGER () {13;}' unless defined(&SO_LINGER); eval 'sub SO_BSDCOMPAT () {14;}' unless defined(&SO_BSDCOMPAT); unless(defined(&SO_PASSCRED)) { eval 'sub SO_PASSCRED () {16;}' unless defined(&SO_PASSCRED); eval 'sub SO_PEERCRED () {17;}' unless defined(&SO_PEERCRED); eval 'sub SO_RCVLOWAT () {18;}' unless defined(&SO_RCVLOWAT); eval 'sub SO_SNDLOWAT () {19;}' unless defined(&SO_SNDLOWAT); eval 'sub SO_RCVTIMEO () {20;}' unless defined(&SO_RCVTIMEO); eval 'sub SO_SNDTIMEO () {21;}' unless defined(&SO_SNDTIMEO); } eval 'sub SO_SECURITY_AUTHENTICATION () {22;}' unless defined(&SO_SECURITY_AUTHENTICATION); eval 'sub SO_SECURITY_ENCRYPTION_TRANSPORT () {23;}' unless defined(&SO_SECURITY_ENCRYPTION_TRANSPORT); eval 'sub SO_SECURITY_ENCRYPTION_NETWORK () {24;}' unless defined(&SO_SECURITY_ENCRYPTION_NETWORK); eval 'sub SO_BINDTODEVICE () {25;}' unless defined(&SO_BINDTODEVICE); eval 'sub SO_ATTACH_FILTER () {26;}' unless defined(&SO_ATTACH_FILTER); eval 'sub SO_DETACH_FILTER () {27;}' unless defined(&SO_DETACH_FILTER); eval 'sub SO_PEERNAME () {28;}' unless defined(&SO_PEERNAME); eval 'sub SO_TIMESTAMP () {29;}' unless defined(&SO_TIMESTAMP); eval 'sub SCM_TIMESTAMP () { &SO_TIMESTAMP;}' unless defined(&SCM_TIMESTAMP); eval 'sub SO_ACCEPTCONN () {30;}' unless defined(&SO_ACCEPTCONN); eval 'sub SO_PEERSEC () {31;}' unless defined(&SO_PEERSEC); eval 'sub SO_PASSSEC () {34;}' unless defined(&SO_PASSSEC); eval 'sub SO_TIMESTAMPNS () {35;}' unless defined(&SO_TIMESTAMPNS); eval 'sub SCM_TIMESTAMPNS () { &SO_TIMESTAMPNS;}' unless defined(&SCM_TIMESTAMPNS); eval 'sub SO_MARK () {36;}' unless defined(&SO_MARK); eval 'sub SO_TIMESTAMPING () {37;}' unless defined(&SO_TIMESTAMPING); eval 'sub SCM_TIMESTAMPING () { &SO_TIMESTAMPING;}' unless defined(&SCM_TIMESTAMPING); eval 'sub SO_PROTOCOL () {38;}' unless defined(&SO_PROTOCOL); eval 'sub SO_DOMAIN () {39;}' unless defined(&SO_DOMAIN); } 1; PK[[I5.10.1/asm-generic/ioctls.phnuW+Arequire '_h2ph_pre.ph'; no warnings qw(redefine misc); unless(defined(&__ASM_GENERIC_IOCTLS_H)) { eval 'sub __ASM_GENERIC_IOCTLS_H () {1;}' unless defined(&__ASM_GENERIC_IOCTLS_H); require 'linux/ioctl.ph'; eval 'sub TCGETS () {0x5401;}' unless defined(&TCGETS); eval 'sub TCSETS () {0x5402;}' unless defined(&TCSETS); eval 'sub TCSETSW () {0x5403;}' unless defined(&TCSETSW); eval 'sub TCSETSF () {0x5404;}' unless defined(&TCSETSF); eval 'sub TCGETA () {0x5405;}' unless defined(&TCGETA); eval 'sub TCSETA () {0x5406;}' unless defined(&TCSETA); eval 'sub TCSETAW () {0x5407;}' unless defined(&TCSETAW); eval 'sub TCSETAF () {0x5408;}' unless defined(&TCSETAF); eval 'sub TCSBRK () {0x5409;}' unless defined(&TCSBRK); eval 'sub TCXONC () {0x540a;}' unless defined(&TCXONC); eval 'sub TCFLSH () {0x540b;}' unless defined(&TCFLSH); eval 'sub TIOCEXCL () {0x540c;}' unless defined(&TIOCEXCL); eval 'sub TIOCNXCL () {0x540d;}' unless defined(&TIOCNXCL); eval 'sub TIOCSCTTY () {0x540e;}' unless defined(&TIOCSCTTY); eval 'sub TIOCGPGRP () {0x540f;}' unless defined(&TIOCGPGRP); eval 'sub TIOCSPGRP () {0x5410;}' unless defined(&TIOCSPGRP); eval 'sub TIOCOUTQ () {0x5411;}' unless defined(&TIOCOUTQ); eval 'sub TIOCSTI () {0x5412;}' unless defined(&TIOCSTI); eval 'sub TIOCGWINSZ () {0x5413;}' unless defined(&TIOCGWINSZ); eval 'sub TIOCSWINSZ () {0x5414;}' unless defined(&TIOCSWINSZ); eval 'sub TIOCMGET () {0x5415;}' unless defined(&TIOCMGET); eval 'sub TIOCMBIS () {0x5416;}' unless defined(&TIOCMBIS); eval 'sub TIOCMBIC () {0x5417;}' unless defined(&TIOCMBIC); eval 'sub TIOCMSET () {0x5418;}' unless defined(&TIOCMSET); eval 'sub TIOCGSOFTCAR () {0x5419;}' unless defined(&TIOCGSOFTCAR); eval 'sub TIOCSSOFTCAR () {0x541a;}' unless defined(&TIOCSSOFTCAR); eval 'sub FIONREAD () {0x541b;}' unless defined(&FIONREAD); eval 'sub TIOCINQ () { &FIONREAD;}' unless defined(&TIOCINQ); eval 'sub TIOCLINUX () {0x541c;}' unless defined(&TIOCLINUX); eval 'sub TIOCCONS () {0x541d;}' unless defined(&TIOCCONS); eval 'sub TIOCGSERIAL () {0x541e;}' unless defined(&TIOCGSERIAL); eval 'sub TIOCSSERIAL () {0x541f;}' unless defined(&TIOCSSERIAL); eval 'sub TIOCPKT () {0x5420;}' unless defined(&TIOCPKT); eval 'sub FIONBIO () {0x5421;}' unless defined(&FIONBIO); eval 'sub TIOCNOTTY () {0x5422;}' unless defined(&TIOCNOTTY); eval 'sub TIOCSETD () {0x5423;}' unless defined(&TIOCSETD); eval 'sub TIOCGETD () {0x5424;}' unless defined(&TIOCGETD); eval 'sub TCSBRKP () {0x5425;}' unless defined(&TCSBRKP); eval 'sub TIOCSBRK () {0x5427;}' unless defined(&TIOCSBRK); eval 'sub TIOCCBRK () {0x5428;}' unless defined(&TIOCCBRK); eval 'sub TIOCGSID () {0x5429;}' unless defined(&TIOCGSID); eval 'sub TCGETS2 () { &_IOR(ord(\'T\'), 0x2a, 1;}' unless defined(&TCGETS2); eval 'sub TCSETS2 () { &_IOW(ord(\'T\'), 0x2b, 1;}' unless defined(&TCSETS2); eval 'sub TCSETSW2 () { &_IOW(ord(\'T\'), 0x2c, 1;}' unless defined(&TCSETSW2); eval 'sub TCSETSF2 () { &_IOW(ord(\'T\'), 0x2d, 1;}' unless defined(&TCSETSF2); eval 'sub TIOCGRS485 () {0x542e;}' unless defined(&TIOCGRS485); eval 'sub TIOCSRS485 () {0x542f;}' unless defined(&TIOCSRS485); eval 'sub TIOCGPTN () { &_IOR(ord(\'T\'), 0x30, \'unsigned int\');}' unless defined(&TIOCGPTN); eval 'sub TIOCSPTLCK () { &_IOW(ord(\'T\'), 0x31, \'int\');}' unless defined(&TIOCSPTLCK); eval 'sub TCGETX () {0x5432;}' unless defined(&TCGETX); eval 'sub TCSETX () {0x5433;}' unless defined(&TCSETX); eval 'sub TCSETXF () {0x5434;}' unless defined(&TCSETXF); eval 'sub TCSETXW () {0x5435;}' unless defined(&TCSETXW); eval 'sub FIONCLEX () {0x5450;}' unless defined(&FIONCLEX); eval 'sub FIOCLEX () {0x5451;}' unless defined(&FIOCLEX); eval 'sub FIOASYNC () {0x5452;}' unless defined(&FIOASYNC); eval 'sub TIOCSERCONFIG () {0x5453;}' unless defined(&TIOCSERCONFIG); eval 'sub TIOCSERGWILD () {0x5454;}' unless defined(&TIOCSERGWILD); eval 'sub TIOCSERSWILD () {0x5455;}' unless defined(&TIOCSERSWILD); eval 'sub TIOCGLCKTRMIOS () {0x5456;}' unless defined(&TIOCGLCKTRMIOS); eval 'sub TIOCSLCKTRMIOS () {0x5457;}' unless defined(&TIOCSLCKTRMIOS); eval 'sub TIOCSERGSTRUCT () {0x5458;}' unless defined(&TIOCSERGSTRUCT); eval 'sub TIOCSERGETLSR () {0x5459;}' unless defined(&TIOCSERGETLSR); eval 'sub TIOCSERGETMULTI () {0x545a;}' unless defined(&TIOCSERGETMULTI); eval 'sub TIOCSERSETMULTI () {0x545b;}' unless defined(&TIOCSERSETMULTI); eval 'sub TIOCMIWAIT () {0x545c;}' unless defined(&TIOCMIWAIT); eval 'sub TIOCGICOUNT () {0x545d;}' unless defined(&TIOCGICOUNT); unless(defined(&FIOQSIZE)) { eval 'sub TIOCGHAYESESP () {0x545e;}' unless defined(&TIOCGHAYESESP); eval 'sub TIOCSHAYESESP () {0x545f;}' unless defined(&TIOCSHAYESESP); eval 'sub FIOQSIZE () {0x5460;}' unless defined(&FIOQSIZE); } eval 'sub TIOCPKT_DATA () {0;}' unless defined(&TIOCPKT_DATA); eval 'sub TIOCPKT_FLUSHREAD () {1;}' unless defined(&TIOCPKT_FLUSHREAD); eval 'sub TIOCPKT_FLUSHWRITE () {2;}' unless defined(&TIOCPKT_FLUSHWRITE); eval 'sub TIOCPKT_STOP () {4;}' unless defined(&TIOCPKT_STOP); eval 'sub TIOCPKT_START () {8;}' unless defined(&TIOCPKT_START); eval 'sub TIOCPKT_NOSTOP () {16;}' unless defined(&TIOCPKT_NOSTOP); eval 'sub TIOCPKT_DOSTOP () {32;}' unless defined(&TIOCPKT_DOSTOP); eval 'sub TIOCSER_TEMT () {0x1;}' unless defined(&TIOCSER_TEMT); } 1; PK[[+5.10.1/asm-generic/ioctl.phnuW+Arequire '_h2ph_pre.ph'; no warnings qw(redefine misc); unless(defined(&_ASM_GENERIC_IOCTL_H)) { eval 'sub _ASM_GENERIC_IOCTL_H () {1;}' unless defined(&_ASM_GENERIC_IOCTL_H); eval 'sub _IOC_NRBITS () {8;}' unless defined(&_IOC_NRBITS); eval 'sub _IOC_TYPEBITS () {8;}' unless defined(&_IOC_TYPEBITS); unless(defined(&_IOC_SIZEBITS)) { eval 'sub _IOC_SIZEBITS () {14;}' unless defined(&_IOC_SIZEBITS); } unless(defined(&_IOC_DIRBITS)) { eval 'sub _IOC_DIRBITS () {2;}' unless defined(&_IOC_DIRBITS); } eval 'sub _IOC_NRMASK () {((1<< &_IOC_NRBITS)-1);}' unless defined(&_IOC_NRMASK); eval 'sub _IOC_TYPEMASK () {((1<< &_IOC_TYPEBITS)-1);}' unless defined(&_IOC_TYPEMASK); eval 'sub _IOC_SIZEMASK () {((1<< &_IOC_SIZEBITS)-1);}' unless defined(&_IOC_SIZEMASK); eval 'sub _IOC_DIRMASK () {((1<< &_IOC_DIRBITS)-1);}' unless defined(&_IOC_DIRMASK); eval 'sub _IOC_NRSHIFT () {0;}' unless defined(&_IOC_NRSHIFT); eval 'sub _IOC_TYPESHIFT () {( &_IOC_NRSHIFT+ &_IOC_NRBITS);}' unless defined(&_IOC_TYPESHIFT); eval 'sub _IOC_SIZESHIFT () {( &_IOC_TYPESHIFT+ &_IOC_TYPEBITS);}' unless defined(&_IOC_SIZESHIFT); eval 'sub _IOC_DIRSHIFT () {( &_IOC_SIZESHIFT+ &_IOC_SIZEBITS);}' unless defined(&_IOC_DIRSHIFT); unless(defined(&_IOC_NONE)) { eval 'sub _IOC_NONE () {0;}' unless defined(&_IOC_NONE); } unless(defined(&_IOC_WRITE)) { eval 'sub _IOC_WRITE () {1;}' unless defined(&_IOC_WRITE); } unless(defined(&_IOC_READ)) { eval 'sub _IOC_READ () {2;}' unless defined(&_IOC_READ); } eval 'sub _IOC { my($dir,$type,$nr,$size) = @_; eval q(((($dir) << &_IOC_DIRSHIFT) | (($type) << &_IOC_TYPESHIFT) | (($nr) << &_IOC_NRSHIFT) | (($size) << &_IOC_SIZESHIFT))); }' unless defined(&_IOC); eval 'sub _IOC_TYPECHECK { my($t) = @_; eval q(($sizeof{$t})); }' unless defined(&_IOC_TYPECHECK); eval 'sub _IO { my($type,$nr) = @_; eval q( &_IOC( &_IOC_NONE,($type),($nr),0)); }' unless defined(&_IO); eval 'sub _IOR { my($type,$nr,$size) = @_; eval q( &_IOC( &_IOC_READ,($type),($nr),( &_IOC_TYPECHECK($size)))); }' unless defined(&_IOR); eval 'sub _IOW { my($type,$nr,$size) = @_; eval q( &_IOC( &_IOC_WRITE,($type),($nr),( &_IOC_TYPECHECK($size)))); }' unless defined(&_IOW); eval 'sub _IOWR { my($type,$nr,$size) = @_; eval q( &_IOC( &_IOC_READ| &_IOC_WRITE,($type),($nr),( &_IOC_TYPECHECK($size)))); }' unless defined(&_IOWR); eval 'sub _IOR_BAD { my($type,$nr,$size) = @_; eval q( &_IOC( &_IOC_READ,($type),($nr),$sizeof{$size})); }' unless defined(&_IOR_BAD); eval 'sub _IOW_BAD { my($type,$nr,$size) = @_; eval q( &_IOC( &_IOC_WRITE,($type),($nr),$sizeof{$size})); }' unless defined(&_IOW_BAD); eval 'sub _IOWR_BAD { my($type,$nr,$size) = @_; eval q( &_IOC( &_IOC_READ| &_IOC_WRITE,($type),($nr),$sizeof{$size})); }' unless defined(&_IOWR_BAD); eval 'sub _IOC_DIR { my($nr) = @_; eval q(((($nr) >> &_IOC_DIRSHIFT) & &_IOC_DIRMASK)); }' unless defined(&_IOC_DIR); eval 'sub _IOC_TYPE { my($nr) = @_; eval q(((($nr) >> &_IOC_TYPESHIFT) & &_IOC_TYPEMASK)); }' unless defined(&_IOC_TYPE); eval 'sub _IOC_NR { my($nr) = @_; eval q(((($nr) >> &_IOC_NRSHIFT) & &_IOC_NRMASK)); }' unless defined(&_IOC_NR); eval 'sub _IOC_SIZE { my($nr) = @_; eval q(((($nr) >> &_IOC_SIZESHIFT) & &_IOC_SIZEMASK)); }' unless defined(&_IOC_SIZE); eval 'sub IOC_IN () {( &_IOC_WRITE << &_IOC_DIRSHIFT);}' unless defined(&IOC_IN); eval 'sub IOC_OUT () {( &_IOC_READ << &_IOC_DIRSHIFT);}' unless defined(&IOC_OUT); eval 'sub IOC_INOUT () {(( &_IOC_WRITE| &_IOC_READ) << &_IOC_DIRSHIFT);}' unless defined(&IOC_INOUT); eval 'sub IOCSIZE_MASK () {( &_IOC_SIZEMASK << &_IOC_SIZESHIFT);}' unless defined(&IOCSIZE_MASK); eval 'sub IOCSIZE_SHIFT () {( &_IOC_SIZESHIFT);}' unless defined(&IOCSIZE_SHIFT); } 1; PK[[! 5.10.1/asm-generic/termbits.phnuW+Arequire '_h2ph_pre.ph'; no warnings qw(redefine misc); unless(defined(&__ASM_GENERIC_TERMBITS_H)) { eval 'sub __ASM_GENERIC_TERMBITS_H () {1;}' unless defined(&__ASM_GENERIC_TERMBITS_H); require 'linux/posix_types.ph'; eval 'sub NCCS () {19;}' unless defined(&NCCS); eval 'sub VINTR () {0;}' unless defined(&VINTR); eval 'sub VQUIT () {1;}' unless defined(&VQUIT); eval 'sub VERASE () {2;}' unless defined(&VERASE); eval 'sub VKILL () {3;}' unless defined(&VKILL); eval 'sub VEOF () {4;}' unless defined(&VEOF); eval 'sub VTIME () {5;}' unless defined(&VTIME); eval 'sub VMIN () {6;}' unless defined(&VMIN); eval 'sub VSWTC () {7;}' unless defined(&VSWTC); eval 'sub VSTART () {8;}' unless defined(&VSTART); eval 'sub VSTOP () {9;}' unless defined(&VSTOP); eval 'sub VSUSP () {10;}' unless defined(&VSUSP); eval 'sub VEOL () {11;}' unless defined(&VEOL); eval 'sub VREPRINT () {12;}' unless defined(&VREPRINT); eval 'sub VDISCARD () {13;}' unless defined(&VDISCARD); eval 'sub VWERASE () {14;}' unless defined(&VWERASE); eval 'sub VLNEXT () {15;}' unless defined(&VLNEXT); eval 'sub VEOL2 () {16;}' unless defined(&VEOL2); eval 'sub IGNBRK () {0000001;}' unless defined(&IGNBRK); eval 'sub BRKINT () {0000002;}' unless defined(&BRKINT); eval 'sub IGNPAR () {0000004;}' unless defined(&IGNPAR); eval 'sub PARMRK () {0000010;}' unless defined(&PARMRK); eval 'sub INPCK () {0000020;}' unless defined(&INPCK); eval 'sub ISTRIP () {0000040;}' unless defined(&ISTRIP); eval 'sub INLCR () {0000100;}' unless defined(&INLCR); eval 'sub IGNCR () {0000200;}' unless defined(&IGNCR); eval 'sub ICRNL () {0000400;}' unless defined(&ICRNL); eval 'sub IUCLC () {0001000;}' unless defined(&IUCLC); eval 'sub IXON () {0002000;}' unless defined(&IXON); eval 'sub IXANY () {0004000;}' unless defined(&IXANY); eval 'sub IXOFF () {0010000;}' unless defined(&IXOFF); eval 'sub IMAXBEL () {0020000;}' unless defined(&IMAXBEL); eval 'sub IUTF8 () {0040000;}' unless defined(&IUTF8); eval 'sub OPOST () {0000001;}' unless defined(&OPOST); eval 'sub OLCUC () {0000002;}' unless defined(&OLCUC); eval 'sub ONLCR () {0000004;}' unless defined(&ONLCR); eval 'sub OCRNL () {0000010;}' unless defined(&OCRNL); eval 'sub ONOCR () {0000020;}' unless defined(&ONOCR); eval 'sub ONLRET () {0000040;}' unless defined(&ONLRET); eval 'sub OFILL () {0000100;}' unless defined(&OFILL); eval 'sub OFDEL () {0000200;}' unless defined(&OFDEL); eval 'sub NLDLY () {0000400;}' unless defined(&NLDLY); eval 'sub NL0 () {0000000;}' unless defined(&NL0); eval 'sub NL1 () {0000400;}' unless defined(&NL1); eval 'sub CRDLY () {0003000;}' unless defined(&CRDLY); eval 'sub CR0 () {0000000;}' unless defined(&CR0); eval 'sub CR1 () {0001000;}' unless defined(&CR1); eval 'sub CR2 () {0002000;}' unless defined(&CR2); eval 'sub CR3 () {0003000;}' unless defined(&CR3); eval 'sub TABDLY () {0014000;}' unless defined(&TABDLY); eval 'sub TAB0 () {0000000;}' unless defined(&TAB0); eval 'sub TAB1 () {0004000;}' unless defined(&TAB1); eval 'sub TAB2 () {0010000;}' unless defined(&TAB2); eval 'sub TAB3 () {0014000;}' unless defined(&TAB3); eval 'sub XTABS () {0014000;}' unless defined(&XTABS); eval 'sub BSDLY () {0020000;}' unless defined(&BSDLY); eval 'sub BS0 () {0000000;}' unless defined(&BS0); eval 'sub BS1 () {0020000;}' unless defined(&BS1); eval 'sub VTDLY () {0040000;}' unless defined(&VTDLY); eval 'sub VT0 () {0000000;}' unless defined(&VT0); eval 'sub VT1 () {0040000;}' unless defined(&VT1); eval 'sub FFDLY () {0100000;}' unless defined(&FFDLY); eval 'sub FF0 () {0000000;}' unless defined(&FF0); eval 'sub FF1 () {0100000;}' unless defined(&FF1); eval 'sub CBAUD () {0010017;}' unless defined(&CBAUD); eval 'sub B0 () {0000000;}' unless defined(&B0); eval 'sub B50 () {0000001;}' unless defined(&B50); eval 'sub B75 () {0000002;}' unless defined(&B75); eval 'sub B110 () {0000003;}' unless defined(&B110); eval 'sub B134 () {0000004;}' unless defined(&B134); eval 'sub B150 () {0000005;}' unless defined(&B150); eval 'sub B200 () {0000006;}' unless defined(&B200); eval 'sub B300 () {0000007;}' unless defined(&B300); eval 'sub B600 () {0000010;}' unless defined(&B600); eval 'sub B1200 () {0000011;}' unless defined(&B1200); eval 'sub B1800 () {0000012;}' unless defined(&B1800); eval 'sub B2400 () {0000013;}' unless defined(&B2400); eval 'sub B4800 () {0000014;}' unless defined(&B4800); eval 'sub B9600 () {0000015;}' unless defined(&B9600); eval 'sub B19200 () {0000016;}' unless defined(&B19200); eval 'sub B38400 () {0000017;}' unless defined(&B38400); eval 'sub EXTA () { &B19200;}' unless defined(&EXTA); eval 'sub EXTB () { &B38400;}' unless defined(&EXTB); eval 'sub CSIZE () {0000060;}' unless defined(&CSIZE); eval 'sub CS5 () {0000000;}' unless defined(&CS5); eval 'sub CS6 () {0000020;}' unless defined(&CS6); eval 'sub CS7 () {0000040;}' unless defined(&CS7); eval 'sub CS8 () {0000060;}' unless defined(&CS8); eval 'sub CSTOPB () {0000100;}' unless defined(&CSTOPB); eval 'sub CREAD () {0000200;}' unless defined(&CREAD); eval 'sub PARENB () {0000400;}' unless defined(&PARENB); eval 'sub PARODD () {0001000;}' unless defined(&PARODD); eval 'sub HUPCL () {0002000;}' unless defined(&HUPCL); eval 'sub CLOCAL () {0004000;}' unless defined(&CLOCAL); eval 'sub CBAUDEX () {0010000;}' unless defined(&CBAUDEX); eval 'sub BOTHER () {0010000;}' unless defined(&BOTHER); eval 'sub B57600 () {0010001;}' unless defined(&B57600); eval 'sub B115200 () {0010002;}' unless defined(&B115200); eval 'sub B230400 () {0010003;}' unless defined(&B230400); eval 'sub B460800 () {0010004;}' unless defined(&B460800); eval 'sub B500000 () {0010005;}' unless defined(&B500000); eval 'sub B576000 () {0010006;}' unless defined(&B576000); eval 'sub B921600 () {0010007;}' unless defined(&B921600); eval 'sub B1000000 () {0010010;}' unless defined(&B1000000); eval 'sub B1152000 () {0010011;}' unless defined(&B1152000); eval 'sub B1500000 () {0010012;}' unless defined(&B1500000); eval 'sub B2000000 () {0010013;}' unless defined(&B2000000); eval 'sub B2500000 () {0010014;}' unless defined(&B2500000); eval 'sub B3000000 () {0010015;}' unless defined(&B3000000); eval 'sub B3500000 () {0010016;}' unless defined(&B3500000); eval 'sub B4000000 () {0010017;}' unless defined(&B4000000); eval 'sub CIBAUD () {002003600000;}' unless defined(&CIBAUD); eval 'sub CMSPAR () {010000000000;}' unless defined(&CMSPAR); eval 'sub CRTSCTS () {020000000000;}' unless defined(&CRTSCTS); eval 'sub IBSHIFT () {16;}' unless defined(&IBSHIFT); eval 'sub ISIG () {0000001;}' unless defined(&ISIG); eval 'sub ICANON () {0000002;}' unless defined(&ICANON); eval 'sub XCASE () {0000004;}' unless defined(&XCASE); eval 'sub ECHO () {0000010;}' unless defined(&ECHO); eval 'sub ECHOE () {0000020;}' unless defined(&ECHOE); eval 'sub ECHOK () {0000040;}' unless defined(&ECHOK); eval 'sub ECHONL () {0000100;}' unless defined(&ECHONL); eval 'sub NOFLSH () {0000200;}' unless defined(&NOFLSH); eval 'sub TOSTOP () {0000400;}' unless defined(&TOSTOP); eval 'sub ECHOCTL () {0001000;}' unless defined(&ECHOCTL); eval 'sub ECHOPRT () {0002000;}' unless defined(&ECHOPRT); eval 'sub ECHOKE () {0004000;}' unless defined(&ECHOKE); eval 'sub FLUSHO () {0010000;}' unless defined(&FLUSHO); eval 'sub PENDIN () {0040000;}' unless defined(&PENDIN); eval 'sub IEXTEN () {0100000;}' unless defined(&IEXTEN); eval 'sub TCOOFF () {0;}' unless defined(&TCOOFF); eval 'sub TCOON () {1;}' unless defined(&TCOON); eval 'sub TCIOFF () {2;}' unless defined(&TCIOFF); eval 'sub TCION () {3;}' unless defined(&TCION); eval 'sub TCIFLUSH () {0;}' unless defined(&TCIFLUSH); eval 'sub TCOFLUSH () {1;}' unless defined(&TCOFLUSH); eval 'sub TCIOFLUSH () {2;}' unless defined(&TCIOFLUSH); eval 'sub TCSANOW () {0;}' unless defined(&TCSANOW); eval 'sub TCSADRAIN () {1;}' unless defined(&TCSADRAIN); eval 'sub TCSAFLUSH () {2;}' unless defined(&TCSAFLUSH); } 1; PK[[M1QQ 5.10.1/re.pmnuW+Apackage re; # pragma for controlling the regex engine use strict; use warnings; our $VERSION = "0.09"; our @ISA = qw(Exporter); my @XS_FUNCTIONS = qw(regmust); my %XS_FUNCTIONS = map { $_ => 1 } @XS_FUNCTIONS; our @EXPORT_OK = (@XS_FUNCTIONS, qw(is_regexp regexp_pattern regname regnames regnames_count)); our %EXPORT_OK = map { $_ => 1 } @EXPORT_OK; # *** WARNING *** WARNING *** WARNING *** WARNING *** WARNING *** # # If you modify these values see comment below! my %bitmask = ( taint => 0x00100000, # HINT_RE_TAINT eval => 0x00200000, # HINT_RE_EVAL ); # - File::Basename contains a literal for 'taint' as a fallback. If # taint is changed here, File::Basename must be updated as well. # # - ExtUtils::ParseXS uses a hardcoded # BEGIN { $^H |= 0x00200000 } # in it to allow re.xs to be built. So if 'eval' is changed here then # ExtUtils::ParseXS must be changed as well. # # *** WARNING *** WARNING *** WARNING *** WARNING *** WARNING *** sub setcolor { eval { # Ignore errors require Term::Cap; my $terminal = Tgetent Term::Cap ({OSPEED => 9600}); # Avoid warning. my $props = $ENV{PERL_RE_TC} || 'md,me,so,se,us,ue'; my @props = split /,/, $props; my $colors = join "\t", map {$terminal->Tputs($_,1)} @props; $colors =~ s/\0//g; $ENV{PERL_RE_COLORS} = $colors; }; if ($@) { $ENV{PERL_RE_COLORS} ||= qq'\t\t> <\t> <\t\t'; } } my %flags = ( COMPILE => 0x0000FF, PARSE => 0x000001, OPTIMISE => 0x000002, TRIEC => 0x000004, DUMP => 0x000008, FLAGS => 0x000010, EXECUTE => 0x00FF00, INTUIT => 0x000100, MATCH => 0x000200, TRIEE => 0x000400, EXTRA => 0xFF0000, TRIEM => 0x010000, OFFSETS => 0x020000, OFFSETSDBG => 0x040000, STATE => 0x080000, OPTIMISEM => 0x100000, STACK => 0x280000, BUFFERS => 0x400000, ); $flags{ALL} = -1 & ~($flags{OFFSETS}|$flags{OFFSETSDBG}|$flags{BUFFERS}); $flags{All} = $flags{all} = $flags{DUMP} | $flags{EXECUTE}; $flags{Extra} = $flags{EXECUTE} | $flags{COMPILE}; $flags{More} = $flags{MORE} = $flags{All} | $flags{TRIEC} | $flags{TRIEM} | $flags{STATE}; $flags{State} = $flags{DUMP} | $flags{EXECUTE} | $flags{STATE}; $flags{TRIE} = $flags{DUMP} | $flags{EXECUTE} | $flags{TRIEC}; my $installed; my $installed_error; sub _do_install { if ( ! defined($installed) ) { require XSLoader; $installed = eval { XSLoader::load('re', $VERSION) } || 0; $installed_error = $@; } } sub _load_unload { my ($on)= @_; if ($on) { _do_install(); if ( ! $installed ) { die "'re' not installed!? ($installed_error)"; } else { # We call install() every time, as if we didn't, we wouldn't # "see" any changes to the color environment var since # the last time it was called. # install() returns an integer, which if casted properly # in C resolves to a structure containing the regex # hooks. Setting it to a random integer will guarantee # segfaults. $^H{regcomp} = install(); } } else { delete $^H{regcomp}; } } sub bits { my $on = shift; my $bits = 0; unless (@_) { require Carp; Carp::carp("Useless use of \"re\" pragma"); } foreach my $idx (0..$#_){ my $s=$_[$idx]; if ($s eq 'Debug' or $s eq 'Debugcolor') { setcolor() if $s =~/color/i; ${^RE_DEBUG_FLAGS} = 0 unless defined ${^RE_DEBUG_FLAGS}; for my $idx ($idx+1..$#_) { if ($flags{$_[$idx]}) { if ($on) { ${^RE_DEBUG_FLAGS} |= $flags{$_[$idx]}; } else { ${^RE_DEBUG_FLAGS} &= ~ $flags{$_[$idx]}; } } else { require Carp; Carp::carp("Unknown \"re\" Debug flag '$_[$idx]', possible flags: ", join(", ",sort keys %flags ) ); } } _load_unload($on ? 1 : ${^RE_DEBUG_FLAGS}); last; } elsif ($s eq 'debug' or $s eq 'debugcolor') { setcolor() if $s =~/color/i; _load_unload($on); last; } elsif (exists $bitmask{$s}) { $bits |= $bitmask{$s}; } elsif ($XS_FUNCTIONS{$s}) { _do_install(); if (! $installed) { require Carp; Carp::croak("\"re\" function '$s' not available"); } require Exporter; re->export_to_level(2, 're', $s); } elsif ($EXPORT_OK{$s}) { require Exporter; re->export_to_level(2, 're', $s); } else { require Carp; Carp::carp("Unknown \"re\" subpragma '$s' (known ones are: ", join(', ', map {qq('$_')} 'debug', 'debugcolor', sort keys %bitmask), ")"); } } $bits; } sub import { shift; $^H |= bits(1, @_); } sub unimport { shift; $^H &= ~ bits(0, @_); } 1; __END__ PK[[LQf#t#t5.10.1/Encode.pmnuW+A# # $Id: Encode.pm,v 2.35 2009/07/13 00:49:38 dankogai Exp $ # package Encode; use strict; use warnings; our $VERSION = sprintf "%d.%02d", q$Revision: 2.35 $ =~ /(\d+)/g; sub DEBUG () { 0 } use XSLoader (); XSLoader::load( __PACKAGE__, $VERSION ); require Exporter; use base qw/Exporter/; # Public, encouraged API is exported by default our @EXPORT = qw( decode decode_utf8 encode encode_utf8 str2bytes bytes2str encodings find_encoding clone_encoding ); our @FB_FLAGS = qw( DIE_ON_ERR WARN_ON_ERR RETURN_ON_ERR LEAVE_SRC PERLQQ HTMLCREF XMLCREF STOP_AT_PARTIAL ); our @FB_CONSTS = qw( FB_DEFAULT FB_CROAK FB_QUIET FB_WARN FB_PERLQQ FB_HTMLCREF FB_XMLCREF ); our @EXPORT_OK = ( qw( _utf8_off _utf8_on define_encoding from_to is_16bit is_8bit is_utf8 perlio_ok resolve_alias utf8_downgrade utf8_upgrade ), @FB_FLAGS, @FB_CONSTS, ); our %EXPORT_TAGS = ( all => [ @EXPORT, @EXPORT_OK ], default => [ @EXPORT ], fallbacks => [ @FB_CONSTS ], fallback_all => [ @FB_CONSTS, @FB_FLAGS ], ); # Documentation moved after __END__ for speed - NI-S our $ON_EBCDIC = ( ord("A") == 193 ); use Encode::Alias; # Make a %Encoding package variable to allow a certain amount of cheating our %Encoding; our %ExtModule; require Encode::Config; # See # https://bugzilla.redhat.com/show_bug.cgi?id=435505#c2 # to find why sig handers inside eval{} are disabled. eval { local $SIG{__DIE__}; local $SIG{__WARN__}; require Encode::ConfigLocal; }; sub encodings { my $class = shift; my %enc; if ( @_ and $_[0] eq ":all" ) { %enc = ( %Encoding, %ExtModule ); } else { %enc = %Encoding; for my $mod ( map { m/::/o ? $_ : "Encode::$_" } @_ ) { DEBUG and warn $mod; for my $enc ( keys %ExtModule ) { $ExtModule{$enc} eq $mod and $enc{$enc} = $mod; } } } return sort { lc $a cmp lc $b } grep { !/^(?:Internal|Unicode|Guess)$/o } keys %enc; } sub perlio_ok { my $obj = ref( $_[0] ) ? $_[0] : find_encoding( $_[0] ); $obj->can("perlio_ok") and return $obj->perlio_ok(); return 0; # safety net } sub define_encoding { my $obj = shift; my $name = shift; $Encoding{$name} = $obj; my $lc = lc($name); define_alias( $lc => $obj ) unless $lc eq $name; while (@_) { my $alias = shift; define_alias( $alias, $obj ); } return $obj; } sub getEncoding { my ( $class, $name, $skip_external ) = @_; ref($name) && $name->can('renew') and return $name; exists $Encoding{$name} and return $Encoding{$name}; my $lc = lc $name; exists $Encoding{$lc} and return $Encoding{$lc}; my $oc = $class->find_alias($name); defined($oc) and return $oc; $lc ne $name and $oc = $class->find_alias($lc); defined($oc) and return $oc; unless ($skip_external) { if ( my $mod = $ExtModule{$name} || $ExtModule{$lc} ) { $mod =~ s,::,/,g; $mod .= '.pm'; eval { require $mod; }; exists $Encoding{$name} and return $Encoding{$name}; } } return; } sub find_encoding($;$) { my ( $name, $skip_external ) = @_; return __PACKAGE__->getEncoding( $name, $skip_external ); } sub resolve_alias($) { my $obj = find_encoding(shift); defined $obj and return $obj->name; return; } sub clone_encoding($) { my $obj = find_encoding(shift); ref $obj or return; eval { require Storable }; $@ and return; return Storable::dclone($obj); } sub encode($$;$) { my ( $name, $string, $check ) = @_; return undef unless defined $string; $string .= '' if ref $string; # stringify; $check ||= 0; unless ( defined $name ) { require Carp; Carp::croak("Encoding name should not be undef"); } my $enc = find_encoding($name); unless ( defined $enc ) { require Carp; Carp::croak("Unknown encoding '$name'"); } my $octets = $enc->encode( $string, $check ); $_[1] = $string if $check and !ref $check and !( $check & LEAVE_SRC() ); return $octets; } *str2bytes = \&encode; sub decode($$;$) { my ( $name, $octets, $check ) = @_; return undef unless defined $octets; $octets .= '' if ref $octets; $check ||= 0; my $enc = find_encoding($name); unless ( defined $enc ) { require Carp; Carp::croak("Unknown encoding '$name'"); } my $string = $enc->decode( $octets, $check ); $_[1] = $octets if $check and !ref $check and !( $check & LEAVE_SRC() ); return $string; } *bytes2str = \&decode; sub from_to($$$;$) { my ( $string, $from, $to, $check ) = @_; return undef unless defined $string; $check ||= 0; my $f = find_encoding($from); unless ( defined $f ) { require Carp; Carp::croak("Unknown encoding '$from'"); } my $t = find_encoding($to); unless ( defined $t ) { require Carp; Carp::croak("Unknown encoding '$to'"); } my $uni = $f->decode($string); $_[0] = $string = $t->encode( $uni, $check ); return undef if ( $check && length($uni) ); return defined( $_[0] ) ? length($string) : undef; } sub encode_utf8($) { my ($str) = @_; utf8::encode($str); return $str; } sub decode_utf8($;$) { my ( $str, $check ) = @_; return $str if is_utf8($str); if ($check) { return decode( "utf8", $str, $check ); } else { return decode( "utf8", $str ); return $str; } } predefine_encodings(1); # # This is to restore %Encoding if really needed; # sub predefine_encodings { require Encode::Encoding; no warnings 'redefine'; my $use_xs = shift; if ($ON_EBCDIC) { # was in Encode::UTF_EBCDIC package Encode::UTF_EBCDIC; push @Encode::UTF_EBCDIC::ISA, 'Encode::Encoding'; *decode = sub { my ( $obj, $str, $chk ) = @_; my $res = ''; for ( my $i = 0 ; $i < length($str) ; $i++ ) { $res .= chr( utf8::unicode_to_native( ord( substr( $str, $i, 1 ) ) ) ); } $_[1] = '' if $chk; return $res; }; *encode = sub { my ( $obj, $str, $chk ) = @_; my $res = ''; for ( my $i = 0 ; $i < length($str) ; $i++ ) { $res .= chr( utf8::native_to_unicode( ord( substr( $str, $i, 1 ) ) ) ); } $_[1] = '' if $chk; return $res; }; $Encode::Encoding{Unicode} = bless { Name => "UTF_EBCDIC" } => "Encode::UTF_EBCDIC"; } else { package Encode::Internal; push @Encode::Internal::ISA, 'Encode::Encoding'; *decode = sub { my ( $obj, $str, $chk ) = @_; utf8::upgrade($str); $_[1] = '' if $chk; return $str; }; *encode = \&decode; $Encode::Encoding{Unicode} = bless { Name => "Internal" } => "Encode::Internal"; } { # was in Encode::utf8 package Encode::utf8; push @Encode::utf8::ISA, 'Encode::Encoding'; # if ($use_xs) { Encode::DEBUG and warn __PACKAGE__, " XS on"; *decode = \&decode_xs; *encode = \&encode_xs; } else { Encode::DEBUG and warn __PACKAGE__, " XS off"; *decode = sub { my ( $obj, $octets, $chk ) = @_; my $str = Encode::decode_utf8($octets); if ( defined $str ) { $_[1] = '' if $chk; return $str; } return undef; }; *encode = sub { my ( $obj, $string, $chk ) = @_; my $octets = Encode::encode_utf8($string); $_[1] = '' if $chk; return $octets; }; } *cat_decode = sub { # ($obj, $dst, $src, $pos, $trm, $chk) # currently ignores $chk my ( $obj, undef, undef, $pos, $trm ) = @_; my ( $rdst, $rsrc, $rpos ) = \@_[ 1, 2, 3 ]; use bytes; if ( ( my $npos = index( $$rsrc, $trm, $pos ) ) >= 0 ) { $$rdst .= substr( $$rsrc, $pos, $npos - $pos + length($trm) ); $$rpos = $npos + length($trm); return 1; } $$rdst .= substr( $$rsrc, $pos ); $$rpos = length($$rsrc); return ''; }; $Encode::Encoding{utf8} = bless { Name => "utf8" } => "Encode::utf8"; $Encode::Encoding{"utf-8-strict"} = bless { Name => "utf-8-strict", strict_utf8 => 1 } => "Encode::utf8"; } } 1; __END__ =head1 NAME Encode - character encodings =head1 SYNOPSIS use Encode; =head2 Table of Contents Encode consists of a collection of modules whose details are too big to fit in one document. This POD itself explains the top-level APIs and general topics at a glance. For other topics and more details, see the PODs below: Name Description -------------------------------------------------------- Encode::Alias Alias definitions to encodings Encode::Encoding Encode Implementation Base Class Encode::Supported List of Supported Encodings Encode::CN Simplified Chinese Encodings Encode::JP Japanese Encodings Encode::KR Korean Encodings Encode::TW Traditional Chinese Encodings -------------------------------------------------------- =head1 DESCRIPTION The C module provides the interfaces between Perl's strings and the rest of the system. Perl strings are sequences of B. The repertoire of characters that Perl can represent is at least that defined by the Unicode Consortium. On most platforms the ordinal values of the characters (as returned by C) is the "Unicode codepoint" for the character (the exceptions are those platforms where the legacy encoding is some variant of EBCDIC rather than a super-set of ASCII - see L). Traditionally, computer data has been moved around in 8-bit chunks often called "bytes". These chunks are also known as "octets" in networking standards. Perl is widely used to manipulate data of many types - not only strings of characters representing human or computer languages but also "binary" data being the machine's representation of numbers, pixels in an image - or just about anything. When Perl is processing "binary data", the programmer wants Perl to process "sequences of bytes". This is not a problem for Perl - as a byte has 256 possible values, it easily fits in Perl's much larger "logical character". =head2 TERMINOLOGY =over 2 =item * I: a character in the range 0..(2**32-1) (or more). (What Perl's strings are made of.) =item * I: a character in the range 0..255 (A special case of a Perl character.) =item * I: 8 bits of data, with ordinal values 0..255 (Term for bytes passed to or from a non-Perl context, e.g. a disk file.) =back =head1 PERL ENCODING API =over 2 =item $octets = encode(ENCODING, $string [, CHECK]) Encodes a string from Perl's internal form into I and returns a sequence of octets. ENCODING can be either a canonical name or an alias. For encoding names and aliases, see L. For CHECK, see L. For example, to convert a string from Perl's internal format to iso-8859-1 (also known as Latin1), $octets = encode("iso-8859-1", $string); B: When you run C<$octets = encode("utf8", $string)>, then $octets B $string. Though they both contain the same data, the UTF8 flag for $octets is B off. When you encode anything, UTF8 flag of the result is always off, even when it contains completely valid utf8 string. See L below. If the $string is C then C is returned. =item $string = decode(ENCODING, $octets [, CHECK]) Decodes a sequence of octets assumed to be in I into Perl's internal form and returns the resulting string. As in encode(), ENCODING can be either a canonical name or an alias. For encoding names and aliases, see L. For CHECK, see L. For example, to convert ISO-8859-1 data to a string in Perl's internal format: $string = decode("iso-8859-1", $octets); B: When you run C<$string = decode("utf8", $octets)>, then $string B $octets. Though they both contain the same data, the UTF8 flag for $string is on unless $octets entirely consists of ASCII data (or EBCDIC on EBCDIC machines). See L below. If the $string is C then C is returned. =item [$obj =] find_encoding(ENCODING) Returns the I corresponding to ENCODING. Returns undef if no matching ENCODING is find. This object is what actually does the actual (en|de)coding. $utf8 = decode($name, $bytes); is in fact $utf8 = do{ $obj = find_encoding($name); croak qq(encoding "$name" not found) unless ref $obj; $obj->decode($bytes) }; with more error checking. Therefore you can save time by reusing this object as follows; my $enc = find_encoding("iso-8859-1"); while(<>){ my $utf8 = $enc->decode($_); # and do someting with $utf8; } Besides C<< ->decode >> and C<< ->encode >>, other methods are available as well. For instance, C<< -> name >> returns the canonical name of the encoding object. find_encoding("latin1")->name; # iso-8859-1 See L for details. =item [$length =] from_to($octets, FROM_ENC, TO_ENC [, CHECK]) Converts B data between two encodings. The data in $octets must be encoded as octets and not as characters in Perl's internal format. For example, to convert ISO-8859-1 data to Microsoft's CP1250 encoding: from_to($octets, "iso-8859-1", "cp1250"); and to convert it back: from_to($octets, "cp1250", "iso-8859-1"); Note that because the conversion happens in place, the data to be converted cannot be a string constant; it must be a scalar variable. from_to() returns the length of the converted string in octets on success, I on error. B: The following operations look the same but are not quite so; from_to($data, "iso-8859-1", "utf8"); #1 $data = decode("iso-8859-1", $data); #2 Both #1 and #2 make $data consist of a completely valid UTF-8 string but only #2 turns UTF8 flag on. #1 is equivalent to $data = encode("utf8", decode("iso-8859-1", $data)); See L below. Also note that from_to($octets, $from, $to, $check); is equivalent to $octets = encode($to, decode($from, $octets), $check); Yes, it does not respect the $check during decoding. It is deliberately done that way. If you need minute control, C then C as follows; $octets = encode($to, decode($from, $octets, $check_from), $check_to); =item $octets = encode_utf8($string); Equivalent to C<$octets = encode("utf8", $string);> The characters that comprise $string are encoded in Perl's internal format and the result is returned as a sequence of octets. All possible characters have a UTF-8 representation so this function cannot fail. =item $string = decode_utf8($octets [, CHECK]); equivalent to C<$string = decode("utf8", $octets [, CHECK])>. The sequence of octets represented by $octets is decoded from UTF-8 into a sequence of logical characters. Not all sequences of octets form valid UTF-8 encodings, so it is possible for this call to fail. For CHECK, see L. =back =head2 Listing available encodings use Encode; @list = Encode->encodings(); Returns a list of the canonical names of the available encodings that are loaded. To get a list of all available encodings including the ones that are not loaded yet, say @all_encodings = Encode->encodings(":all"); Or you can give the name of a specific module. @with_jp = Encode->encodings("Encode::JP"); When "::" is not in the name, "Encode::" is assumed. @ebcdic = Encode->encodings("EBCDIC"); To find out in detail which encodings are supported by this package, see L. =head2 Defining Aliases To add a new alias to a given encoding, use: use Encode; use Encode::Alias; define_alias(newName => ENCODING); After that, newName can be used as an alias for ENCODING. ENCODING may be either the name of an encoding or an I But before you do so, make sure the alias is nonexistent with C, which returns the canonical name thereof. i.e. Encode::resolve_alias("latin1") eq "iso-8859-1" # true Encode::resolve_alias("iso-8859-12") # false; nonexistent Encode::resolve_alias($name) eq $name # true if $name is canonical resolve_alias() does not need C; it can be exported via C. See L for details. =head2 Finding IANA Character Set Registry names The canonical name of a given encoding does not necessarily agree with IANA IANA Character Set Registry, commonly seen as C<< Content-Type: text/plain; charset=I >>. For most cases canonical names work but sometimes it does not (notably 'utf-8-strict'). Therefore as of Encode version 2.21, a new method C is added. use Encode; my $enc = find_encoding('UTF-8'); warn $enc->name; # utf-8-strict warn $enc->mime_name; # UTF-8 See also: L =head1 Encoding via PerlIO If your perl supports I (which is the default), you can use a PerlIO layer to decode and encode directly via a filehandle. The following two examples are totally identical in their functionality. # via PerlIO open my $in, "<:encoding(shiftjis)", $infile or die; open my $out, ">:encoding(euc-jp)", $outfile or die; while(<$in>){ print $out $_; } # via from_to open my $in, "<", $infile or die; open my $out, ">", $outfile or die; while(<$in>){ from_to($_, "shiftjis", "euc-jp", 1); print $out $_; } Unfortunately, it may be that encodings are PerlIO-savvy. You can check if your encoding is supported by PerlIO by calling the C method. Encode::perlio_ok("hz"); # False find_encoding("euc-cn")->perlio_ok; # True where PerlIO is available use Encode qw(perlio_ok); # exported upon request perlio_ok("euc-jp") Fortunately, all encodings that come with Encode core are PerlIO-savvy except for hz and ISO-2022-kr. For gory details, see L and L. =head1 Handling Malformed Data The optional I argument tells Encode what to do when it encounters malformed data. Without CHECK, Encode::FB_DEFAULT ( == 0 ) is assumed. As of version 2.12 Encode supports coderef values for CHECK. See below. =over 2 =item B Not all encoding support this feature Some encodings ignore I argument. For example, L ignores I and it always croaks on error. =back Now here is the list of I values available =over 2 =item I = Encode::FB_DEFAULT ( == 0) If I is 0, (en|de)code will put a I in place of a malformed character. When you encode, EsubcharE will be used. When you decode the code point C<0xFFFD> is used. If the data is supposed to be UTF-8, an optional lexical warning (category utf8) is given. =item I = Encode::FB_CROAK ( == 1) If I is 1, methods will die on error immediately with an error message. Therefore, when I is set to 1, you should trap the error with eval{} unless you really want to let it die. =item I = Encode::FB_QUIET If I is set to Encode::FB_QUIET, (en|de)code will immediately return the portion of the data that has been processed so far when an error occurs. The data argument will be overwritten with everything after that point (that is, the unprocessed part of data). This is handy when you have to call decode repeatedly in the case where your source data may contain partial multi-byte character sequences, (i.e. you are reading with a fixed-width buffer). Here is a sample code that does exactly this: my $buffer = ''; my $string = ''; while(read $fh, $buffer, 256, length($buffer)){ $string .= decode($encoding, $buffer, Encode::FB_QUIET); # $buffer now contains the unprocessed partial character } =item I = Encode::FB_WARN This is the same as above, except that it warns on error. Handy when you are debugging the mode above. =item perlqq mode (I = Encode::FB_PERLQQ) =item HTML charref mode (I = Encode::FB_HTMLCREF) =item XML charref mode (I = Encode::FB_XMLCREF) For encodings that are implemented by Encode::XS, CHECK == Encode::FB_PERLQQ turns (en|de)code into C fallback mode. When you decode, C<\xI> will be inserted for a malformed character, where I is the hex representation of the octet that could not be decoded to utf8. And when you encode, C<\x{I}> will be inserted, where I is the Unicode ID of the character that cannot be found in the character repertoire of the encoding. HTML/XML character reference modes are about the same, in place of C<\x{I}>, HTML uses C<&#I;> where I is a decimal number and XML uses C<&#xI;> where I is the hexadecimal number. In Encode 2.10 or later, C is also implied. =item The bitmask These modes are actually set via a bitmask. Here is how the FB_XX constants are laid out. You can import the FB_XX constants via C; you can import the generic bitmask constants via C. FB_DEFAULT FB_CROAK FB_QUIET FB_WARN FB_PERLQQ DIE_ON_ERR 0x0001 X WARN_ON_ERR 0x0002 X RETURN_ON_ERR 0x0004 X X LEAVE_SRC 0x0008 X PERLQQ 0x0100 X HTMLCREF 0x0200 XMLCREF 0x0400 =back =over 2 =item Encode::LEAVE_SRC If the C bit is not set, but I is, then the second argument to C or C may be assigned to by the functions. If you're not interested in this, then bitwise-or the bitmask with it. =back =head2 coderef for CHECK As of Encode 2.12 CHECK can also be a code reference which takes the ord value of unmapped caharacter as an argument and returns a string that represents the fallback character. For instance, $ascii = encode("ascii", $utf8, sub{ sprintf "", shift }); Acts like FB_PERLQQ but EU+IE is used instead of \x{I}. =head1 Defining Encodings To define a new encoding, use: use Encode qw(define_encoding); define_encoding($object, 'canonicalName' [, alias...]); I will be associated with I<$object>. The object should provide the interface described in L. If more than two arguments are provided then additional arguments are taken as aliases for I<$object>. See L for more details. =head1 The UTF8 flag Before the introduction of Unicode support in perl, The C operator just compared the strings represented by two scalars. Beginning with perl 5.8, C compares two strings with simultaneous consideration of I. To explain why we made it so, I will quote page 402 of C =over 2 =item Goal #1: Old byte-oriented programs should not spontaneously break on the old byte-oriented data they used to work on. =item Goal #2: Old byte-oriented programs should magically start working on the new character-oriented data when appropriate. =item Goal #3: Programs should run just as fast in the new character-oriented mode as in the old byte-oriented mode. =item Goal #4: Perl should remain one language, rather than forking into a byte-oriented Perl and a character-oriented Perl. =back Back when C was written, not even Perl 5.6.0 was born and many features documented in the book remained unimplemented for a long time. Perl 5.8 corrected this and the introduction of the UTF8 flag is one of them. You can think of this perl notion as of a byte-oriented mode (UTF8 flag off) and a character-oriented mode (UTF8 flag on). Here is how Encode takes care of the UTF8 flag. =over 2 =item * When you encode, the resulting UTF8 flag is always off. =item * When you decode, the resulting UTF8 flag is on unless you can unambiguously represent data. Here is the definition of dis-ambiguity. After C<$utf8 = decode('foo', $octet);>, When $octet is... The UTF8 flag in $utf8 is --------------------------------------------- In ASCII only (or EBCDIC only) OFF In ISO-8859-1 ON In any other Encoding ON --------------------------------------------- As you see, there is one exception, In ASCII. That way you can assume Goal #1. And with Encode Goal #2 is assumed but you still have to be careful in such cases mentioned in B paragraphs. This UTF8 flag is not visible in perl scripts, exactly for the same reason you cannot (or you I) see if a scalar contains a string, integer, or floating point number. But you can still peek and poke these if you will. See the section below. =back =head2 Messing with Perl's Internals The following API uses parts of Perl's internals in the current implementation. As such, they are efficient but may change. =over 2 =item is_utf8(STRING [, CHECK]) [INTERNAL] Tests whether the UTF8 flag is turned on in the STRING. If CHECK is true, also checks the data in STRING for being well-formed UTF-8. Returns true if successful, false otherwise. As of perl 5.8.1, L also has utf8::is_utf8(). =item _utf8_on(STRING) [INTERNAL] Turns on the UTF8 flag in STRING. The data in STRING is B checked for being well-formed UTF-8. Do not use unless you B that the STRING is well-formed UTF-8. Returns the previous state of the UTF8 flag (so please don't treat the return value as indicating success or failure), or C if STRING is not a string. This function does not work on tainted values. =item _utf8_off(STRING) [INTERNAL] Turns off the UTF8 flag in STRING. Do not use frivolously. Returns the previous state of the UTF8 flag (so please don't treat the return value as indicating success or failure), or C if STRING is not a string. This function does not work on tainted values. =back =head1 UTF-8 vs. utf8 vs. UTF8 ....We now view strings not as sequences of bytes, but as sequences of numbers in the range 0 .. 2**32-1 (or in the case of 64-bit computers, 0 .. 2**64-1) -- Programming Perl, 3rd ed. That has been the perl's notion of UTF-8 but official UTF-8 is more strict; Its ranges is much narrower (0 .. 10FFFF), some sequences are not allowed (i.e. Those used in the surrogate pair, 0xFFFE, et al). Now that is overruled by Larry Wall himself. From: Larry Wall Date: December 04, 2004 11:51:58 JST To: perl-unicode@perl.org Subject: Re: Make Encode.pm support the real UTF-8 Message-Id: <20041204025158.GA28754@wall.org> On Fri, Dec 03, 2004 at 10:12:12PM +0000, Tim Bunce wrote: : I've no problem with 'utf8' being perl's unrestricted uft8 encoding, : but "UTF-8" is the name of the standard and should give the : corresponding behaviour. For what it's worth, that's how I've always kept them straight in my head. Also for what it's worth, Perl 6 will mostly default to strict but make it easy to switch back to lax. Larry Do you copy? As of Perl 5.8.7, B means strict, official UTF-8 while B means liberal, lax, version thereof. And Encode version 2.10 or later thus groks the difference between C and C"utf8". encode("utf8", "\x{FFFF_FFFF}", 1); # okay encode("UTF-8", "\x{FFFF_FFFF}", 1); # croaks C in Encode is actually a canonical name for C. Yes, the hyphen between "UTF" and "8" is important. Without it Encode goes "liberal" find_encoding("UTF-8")->name # is 'utf-8-strict' find_encoding("utf-8")->name # ditto. names are case insensitive find_encoding("utf_8")->name # ditto. "_" are treated as "-" find_encoding("UTF8")->name # is 'utf8'. The UTF8 flag is internally called UTF8, without a hyphen. It indicates whether a string is internally encoded as utf8, also without a hypen. =head1 SEE ALSO L, L, L, L, L, L, L, L, L, L L, the Perl Unicode Mailing List Eperl-unicode@perl.orgE =head1 MAINTAINER This project was originated by Nick Ing-Simmons and later maintained by Dan Kogai Edankogai@dan.co.jpE. See AUTHORS for a full list of people involved. For any questions, use Eperl-unicode@perl.orgE so we can all share. While Dan Kogai retains the copyright as a maintainer, the credit should go to all those involoved. See AUTHORS for those submitted codes. =head1 COPYRIGHT Copyright 2002-2006 Dan Kogai Edankogai@dan.co.jpE This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut PK[[ޖ5.10.1/Text/Soundex.pmnuW+A# -*- perl -*- # (c) Copyright 1998-2007 by Mark Mielke # # Freedom to use these sources for whatever you want, as long as credit # is given where credit is due, is hereby granted. You may make modifications # where you see fit but leave this copyright somewhere visible. As well, try # to initial any changes you make so that if I like the changes I can # incorporate them into later versions. # # - Mark Mielke # package Text::Soundex; require 5.006; use Exporter (); use XSLoader (); use strict; our $VERSION = '3.03'; our @EXPORT_OK = qw(soundex soundex_unicode soundex_nara soundex_nara_unicode $soundex_nocode); our @EXPORT = qw(soundex soundex_nara $soundex_nocode); our @ISA = qw(Exporter); our $nocode; # Previous releases of Text::Soundex made $nocode available as $soundex_nocode. # For now, this part of the interface is exported and maintained. # In the feature, $soundex_nocode will be deprecated. *Text::Soundex::soundex_nocode = \$nocode; sub soundex_noxs { # Original Soundex algorithm my @results = map { my $code = uc($_); $code =~ tr/AaEeHhIiOoUuWwYyBbFfPpVvCcGgJjKkQqSsXxZzDdTtLlMmNnRr//cd; if (length($code)) { my $firstchar = substr($code, 0, 1); $code =~ tr[AaEeHhIiOoUuWwYyBbFfPpVvCcGgJjKkQqSsXxZzDdTtLlMmNnRr] [0000000000000000111111112222222222222222333344555566]s; ($code = substr($code, 1)) =~ tr/0//d; substr($firstchar . $code . '000', 0, 4); } else { $nocode; } } @_; wantarray ? @results : $results[0]; } sub soundex_nara { # US census (NARA) algorithm. my @results = map { my $code = uc($_); $code =~ tr/AaEeHhIiOoUuWwYyBbFfPpVvCcGgJjKkQqSsXxZzDdTtLlMmNnRr//cd; if (length($code)) { my $firstchar = substr($code, 0, 1); $code =~ tr[AaEeHhIiOoUuWwYyBbFfPpVvCcGgJjKkQqSsXxZzDdTtLlMmNnRr] [0000990000009900111111112222222222222222333344555566]s; $code =~ s/(.)9\1/$1/gs; ($code = substr($code, 1)) =~ tr/09//d; substr($firstchar . $code . '000', 0, 4); } else { $nocode } } @_; wantarray ? @results : $results[0]; } sub soundex_unicode { require Text::Unidecode unless defined &Text::Unidecode::unidecode; soundex(Text::Unidecode::unidecode(@_)); } sub soundex_nara_unicode { require Text::Unidecode unless defined &Text::Unidecode::unidecode; soundex_nara(Text::Unidecode::unidecode(@_)); } eval { XSLoader::load(__PACKAGE__, $VERSION) }; if (defined(&soundex_xs)) { *soundex = \&soundex_xs; } else { *soundex = \&soundex_noxs; *soundex_xs = sub { require Carp; Carp::croak("XS implementation of Text::Soundex::soundex_xs() ". "could not be loaded"); }; } 1; __END__ # Implementation of the soundex algorithm. # # Some of this documention was written by Mike Stok. # # Examples: # # Euler, Ellery -> E460 # Gauss, Ghosh -> G200 # Hilbert, Heilbronn -> H416 # Knuth, Kant -> K530 # Lloyd, Ladd -> L300 # Lukasiewicz, Lissajous -> L222 # =head1 NAME Text::Soundex - Implementation of the soundex algorithm. =head1 SYNOPSIS use Text::Soundex; # Original algorithm. $code = soundex($name); # Get the soundex code for a name. @codes = soundex(@names); # Get the list of codes for a list of names. # American Soundex variant (NARA) - Used for US census data. $code = soundex_nara($name); # Get the soundex code for a name. @codes = soundex_nara(@names); # Get the list of codes for a list of names. # Redefine the value that soundex() will return if the input string # contains no identifiable sounds within it. $Text::Soundex::nocode = 'Z000'; =head1 DESCRIPTION Soundex is a phonetic algorithm for indexing names by sound, as pronounced in English. The goal is for names with the same pronunciation to be encoded to the same representation so that they can be matched despite minor differences in spelling. Soundex is the most widely known of all phonetic algorithms and is often used (incorrectly) as a synonym for "phonetic algorithm". Improvements to Soundex are the basis for many modern phonetic algorithms. (Wikipedia, 2007) This module implements the original soundex algorithm developed by Robert Russell and Margaret Odell, patented in 1918 and 1922, as well as a variation called "American Soundex" used for US census data, and current maintained by the National Archives and Records Administration (NARA). The soundex algorithm may be recognized from Donald Knuth's B. The algorithm described by Knuth is the NARA algorithm. The value returned for strings which have no soundex encoding is defined using C<$Text::Soundex::nocode>. The default value is C, however values such as C<'Z000'> are commonly used alternatives. For backward compatibility with older versions of this module the C<$Text::Soundex::nocode> is exported into the caller's namespace as C<$soundex_nocode>. In scalar context, C returns the soundex code of its first argument. In list context, a list is returned in which each element is the soundex code for the corresponding argument passed to C. For example, the following code assigns @codes the value C<('M200', 'S320')>: @codes = soundex qw(Mike Stok); To use C to generate codes that can be used to search one of the publically available US Censuses, a variant of the soundex algorithm must be used: use Text::Soundex; $code = soundex_nara($name); An example of where these algorithm differ follows: use Text::Soundex; print soundex("Ashcraft"), "\n"; # prints: A226 print soundex_nara("Ashcraft"), "\n"; # prints: A261 =head1 EXAMPLES Donald Knuth's examples of names and the soundex codes they map to are listed below: Euler, Ellery -> E460 Gauss, Ghosh -> G200 Hilbert, Heilbronn -> H416 Knuth, Kant -> K530 Lloyd, Ladd -> L300 Lukasiewicz, Lissajous -> L222 so: $code = soundex 'Knuth'; # $code contains 'K530' @list = soundex qw(Lloyd Gauss); # @list contains 'L300', 'G200' =head1 LIMITATIONS As the soundex algorithm was originally used a B time ago in the US it considers only the English alphabet and pronunciation. In particular, non-ASCII characters will be ignored. The recommended method of dealing with characters that have accents, or other unicode characters, is to use the Text::Unidecode module available from CPAN. Either use the module explicitly: use Text::Soundex; use Text::Unidecode; print soundex(unidecode("Fran\xE7ais")), "\n"; # Prints "F652\n" Or use the convenient wrapper routine: use Text::Soundex 'soundex_unicode'; print soundex_unicode("Fran\xE7ais"), "\n"; # Prints "F652\n" Since the soundex algorithm maps a large space (strings of arbitrary length) onto a small space (single letter plus 3 digits) no inference can be made about the similarity of two strings which end up with the same soundex code. For example, both C and C end up with a soundex code of C. =head1 MAINTAINER This module is currently maintain by Mark Mielke (C). =head1 HISTORY Version 3 is a significant update to provide support for versions of Perl later than Perl 5.004. Specifically, the XS version of the soundex() subroutine understands strings that are encoded using UTF-8 (unicode strings). Version 2 of this module was a re-write by Mark Mielke (C) to improve the speed of the subroutines. The XS version of the soundex() subroutine was introduced in 2.00. Version 1 of this module was written by Mike Stok (C) and was included into the Perl core library set. Dave Carlsen (C) made the request for the NARA algorithm to be included. The NARA soundex page can be viewed at: C Ian Phillips (C) and Rich Pinder (C) supplied ideas and spotted mistakes for v1.x. =cut PK[[Z//5.10.1/DB_File.pmnuW+A# DB_File.pm -- Perl 5 interface to Berkeley DB # # written by Paul Marquess (pmqs@cpan.org) # last modified 28th October 2007 # version 1.818 # # Copyright (c) 1995-2009 Paul Marquess. All rights reserved. # This program is free software; you can redistribute it and/or # modify it under the same terms as Perl itself. package DB_File::HASHINFO ; require 5.00404; use warnings; use strict; use Carp; require Tie::Hash; @DB_File::HASHINFO::ISA = qw(Tie::Hash); sub new { my $pkg = shift ; my %x ; tie %x, $pkg ; bless \%x, $pkg ; } sub TIEHASH { my $pkg = shift ; bless { VALID => { bsize => 1, ffactor => 1, nelem => 1, cachesize => 1, hash => 2, lorder => 1, }, GOT => {} }, $pkg ; } sub FETCH { my $self = shift ; my $key = shift ; return $self->{GOT}{$key} if exists $self->{VALID}{$key} ; my $pkg = ref $self ; croak "${pkg}::FETCH - Unknown element '$key'" ; } sub STORE { my $self = shift ; my $key = shift ; my $value = shift ; my $type = $self->{VALID}{$key}; if ( $type ) { croak "Key '$key' not associated with a code reference" if $type == 2 && !ref $value && ref $value ne 'CODE'; $self->{GOT}{$key} = $value ; return ; } my $pkg = ref $self ; croak "${pkg}::STORE - Unknown element '$key'" ; } sub DELETE { my $self = shift ; my $key = shift ; if ( exists $self->{VALID}{$key} ) { delete $self->{GOT}{$key} ; return ; } my $pkg = ref $self ; croak "DB_File::HASHINFO::DELETE - Unknown element '$key'" ; } sub EXISTS { my $self = shift ; my $key = shift ; exists $self->{VALID}{$key} ; } sub NotHere { my $self = shift ; my $method = shift ; croak ref($self) . " does not define the method ${method}" ; } sub FIRSTKEY { my $self = shift ; $self->NotHere("FIRSTKEY") } sub NEXTKEY { my $self = shift ; $self->NotHere("NEXTKEY") } sub CLEAR { my $self = shift ; $self->NotHere("CLEAR") } package DB_File::RECNOINFO ; use warnings; use strict ; @DB_File::RECNOINFO::ISA = qw(DB_File::HASHINFO) ; sub TIEHASH { my $pkg = shift ; bless { VALID => { map {$_, 1} qw( bval cachesize psize flags lorder reclen bfname ) }, GOT => {}, }, $pkg ; } package DB_File::BTREEINFO ; use warnings; use strict ; @DB_File::BTREEINFO::ISA = qw(DB_File::HASHINFO) ; sub TIEHASH { my $pkg = shift ; bless { VALID => { flags => 1, cachesize => 1, maxkeypage => 1, minkeypage => 1, psize => 1, compare => 2, prefix => 2, lorder => 1, }, GOT => {}, }, $pkg ; } package DB_File ; use warnings; use strict; our ($VERSION, @ISA, @EXPORT, $AUTOLOAD, $DB_BTREE, $DB_HASH, $DB_RECNO); our ($db_version, $use_XSLoader, $splice_end_array, $Error); use Carp; $VERSION = "1.820" ; $VERSION = eval $VERSION; # needed for dev releases { local $SIG{__WARN__} = sub {$splice_end_array = "@_";}; my @a =(1); splice(@a, 3); $splice_end_array = ($splice_end_array =~ /^splice\(\) offset past end of array at /); } #typedef enum { DB_BTREE, DB_HASH, DB_RECNO } DBTYPE; $DB_BTREE = new DB_File::BTREEINFO ; $DB_HASH = new DB_File::HASHINFO ; $DB_RECNO = new DB_File::RECNOINFO ; require Tie::Hash; require Exporter; use AutoLoader; BEGIN { $use_XSLoader = 1 ; { local $SIG{__DIE__} ; eval { require XSLoader } ; } if ($@) { $use_XSLoader = 0 ; require DynaLoader; @ISA = qw(DynaLoader); } } push @ISA, qw(Tie::Hash Exporter); @EXPORT = qw( $DB_BTREE $DB_HASH $DB_RECNO BTREEMAGIC BTREEVERSION DB_LOCK DB_SHMEM DB_TXN HASHMAGIC HASHVERSION MAX_PAGE_NUMBER MAX_PAGE_OFFSET MAX_REC_NUMBER RET_ERROR RET_SPECIAL RET_SUCCESS R_CURSOR R_DUP R_FIRST R_FIXEDLEN R_IAFTER R_IBEFORE R_LAST R_NEXT R_NOKEY R_NOOVERWRITE R_PREV R_RECNOSYNC R_SETCURSOR R_SNAPSHOT __R_UNUSED ); sub AUTOLOAD { my($constname); ($constname = $AUTOLOAD) =~ s/.*:://; my ($error, $val) = constant($constname); Carp::croak $error if $error; no strict 'refs'; *{$AUTOLOAD} = sub { $val }; goto &{$AUTOLOAD}; } eval { # Make all Fcntl O_XXX constants available for importing require Fcntl; my @O = grep /^O_/, @Fcntl::EXPORT; Fcntl->import(@O); # first we import what we want to export push(@EXPORT, @O); }; if ($use_XSLoader) { XSLoader::load("DB_File", $VERSION)} else { bootstrap DB_File $VERSION } # Preloaded methods go here. Autoload methods go after __END__, and are # processed by the autosplit program. sub tie_hash_or_array { my (@arg) = @_ ; my $tieHASH = ( (caller(1))[3] =~ /TIEHASH/ ) ; use File::Spec; $arg[1] = File::Spec->rel2abs($arg[1]) if defined $arg[1] ; $arg[4] = tied %{ $arg[4] } if @arg >= 5 && ref $arg[4] && $arg[4] =~ /=HASH/ && tied %{ $arg[4] } ; $arg[2] = O_CREAT()|O_RDWR() if @arg >=3 && ! defined $arg[2]; $arg[3] = 0666 if @arg >=4 && ! defined $arg[3]; # make recno in Berkeley DB version 2 (or better) work like # recno in version 1. if ($db_version >= 4 and ! $tieHASH) { $arg[2] |= O_CREAT(); } if ($db_version > 1 and defined $arg[4] and $arg[4] =~ /RECNO/ and $arg[1] and ! -e $arg[1]) { open(FH, ">$arg[1]") or return undef ; close FH ; chmod $arg[3] ? $arg[3] : 0666 , $arg[1] ; } DoTie_($tieHASH, @arg) ; } sub TIEHASH { tie_hash_or_array(@_) ; } sub TIEARRAY { tie_hash_or_array(@_) ; } sub CLEAR { my $self = shift; my $key = 0 ; my $value = "" ; my $status = $self->seq($key, $value, R_FIRST()); my @keys; while ($status == 0) { push @keys, $key; $status = $self->seq($key, $value, R_NEXT()); } foreach $key (reverse @keys) { my $s = $self->del($key); } } sub EXTEND { } sub STORESIZE { my $self = shift; my $length = shift ; my $current_length = $self->length() ; if ($length < $current_length) { my $key ; for ($key = $current_length - 1 ; $key >= $length ; -- $key) { $self->del($key) } } elsif ($length > $current_length) { $self->put($length-1, "") ; } } sub SPLICE { my $self = shift; my $offset = shift; if (not defined $offset) { warnings::warnif('uninitialized', 'Use of uninitialized value in splice'); $offset = 0; } my $length = @_ ? shift : 0; # Carping about definedness comes _after_ the OFFSET sanity check. # This is so we get the same error messages as Perl's splice(). # my @list = @_; my $size = $self->FETCHSIZE(); # 'If OFFSET is negative then it start that far from the end of # the array.' # if ($offset < 0) { my $new_offset = $size + $offset; if ($new_offset < 0) { die "Modification of non-creatable array value attempted, " . "subscript $offset"; } $offset = $new_offset; } if (not defined $length) { warnings::warnif('uninitialized', 'Use of uninitialized value in splice'); $length = 0; } if ($offset > $size) { $offset = $size; warnings::warnif('misc', 'splice() offset past end of array') if $splice_end_array; } # 'If LENGTH is omitted, removes everything from OFFSET onward.' if (not defined $length) { $length = $size - $offset; } # 'If LENGTH is negative, leave that many elements off the end of # the array.' # if ($length < 0) { $length = $size - $offset + $length; if ($length < 0) { # The user must have specified a length bigger than the # length of the array passed in. But perl's splice() # doesn't catch this, it just behaves as for length=0. # $length = 0; } } if ($length > $size - $offset) { $length = $size - $offset; } # $num_elems holds the current number of elements in the database. my $num_elems = $size; # 'Removes the elements designated by OFFSET and LENGTH from an # array,'... # my @removed = (); foreach (0 .. $length - 1) { my $old; my $status = $self->get($offset, $old); if ($status != 0) { my $msg = "error from Berkeley DB on get($offset, \$old)"; if ($status == 1) { $msg .= ' (no such element?)'; } else { $msg .= ": error status $status"; if (defined $! and $! ne '') { $msg .= ", message $!"; } } die $msg; } push @removed, $old; $status = $self->del($offset); if ($status != 0) { my $msg = "error from Berkeley DB on del($offset)"; if ($status == 1) { $msg .= ' (no such element?)'; } else { $msg .= ": error status $status"; if (defined $! and $! ne '') { $msg .= ", message $!"; } } die $msg; } -- $num_elems; } # ...'and replaces them with the elements of LIST, if any.' my $pos = $offset; while (defined (my $elem = shift @list)) { my $old_pos = $pos; my $status; if ($pos >= $num_elems) { $status = $self->put($pos, $elem); } else { $status = $self->put($pos, $elem, $self->R_IBEFORE); } if ($status != 0) { my $msg = "error from Berkeley DB on put($pos, $elem, ...)"; if ($status == 1) { $msg .= ' (no such element?)'; } else { $msg .= ", error status $status"; if (defined $! and $! ne '') { $msg .= ", message $!"; } } die $msg; } die "pos unexpectedly changed from $old_pos to $pos with R_IBEFORE" if $old_pos != $pos; ++ $pos; ++ $num_elems; } if (wantarray) { # 'In list context, returns the elements removed from the # array.' # return @removed; } elsif (defined wantarray and not wantarray) { # 'In scalar context, returns the last element removed, or # undef if no elements are removed.' # if (@removed) { my $last = pop @removed; return "$last"; } else { return undef; } } elsif (not defined wantarray) { # Void context } else { die } } sub ::DB_File::splice { &SPLICE } sub find_dup { croak "Usage: \$db->find_dup(key,value)\n" unless @_ == 3 ; my $db = shift ; my ($origkey, $value_wanted) = @_ ; my ($key, $value) = ($origkey, 0); my ($status) = 0 ; for ($status = $db->seq($key, $value, R_CURSOR() ) ; $status == 0 ; $status = $db->seq($key, $value, R_NEXT() ) ) { return 0 if $key eq $origkey and $value eq $value_wanted ; } return $status ; } sub del_dup { croak "Usage: \$db->del_dup(key,value)\n" unless @_ == 3 ; my $db = shift ; my ($key, $value) = @_ ; my ($status) = $db->find_dup($key, $value) ; return $status if $status != 0 ; $status = $db->del($key, R_CURSOR() ) ; return $status ; } sub get_dup { croak "Usage: \$db->get_dup(key [,flag])\n" unless @_ == 2 or @_ == 3 ; my $db = shift ; my $key = shift ; my $flag = shift ; my $value = 0 ; my $origkey = $key ; my $wantarray = wantarray ; my %values = () ; my @values = () ; my $counter = 0 ; my $status = 0 ; # iterate through the database until either EOF ($status == 0) # or a different key is encountered ($key ne $origkey). for ($status = $db->seq($key, $value, R_CURSOR()) ; $status == 0 and $key eq $origkey ; $status = $db->seq($key, $value, R_NEXT()) ) { # save the value or count number of matches if ($wantarray) { if ($flag) { ++ $values{$value} } else { push (@values, $value) } } else { ++ $counter } } return ($wantarray ? ($flag ? %values : @values) : $counter) ; } 1; __END__ =head1 NAME DB_File - Perl5 access to Berkeley DB version 1.x =head1 SYNOPSIS use DB_File; [$X =] tie %hash, 'DB_File', [$filename, $flags, $mode, $DB_HASH] ; [$X =] tie %hash, 'DB_File', $filename, $flags, $mode, $DB_BTREE ; [$X =] tie @array, 'DB_File', $filename, $flags, $mode, $DB_RECNO ; $status = $X->del($key [, $flags]) ; $status = $X->put($key, $value [, $flags]) ; $status = $X->get($key, $value [, $flags]) ; $status = $X->seq($key, $value, $flags) ; $status = $X->sync([$flags]) ; $status = $X->fd ; # BTREE only $count = $X->get_dup($key) ; @list = $X->get_dup($key) ; %list = $X->get_dup($key, 1) ; $status = $X->find_dup($key, $value) ; $status = $X->del_dup($key, $value) ; # RECNO only $a = $X->length; $a = $X->pop ; $X->push(list); $a = $X->shift; $X->unshift(list); @r = $X->splice(offset, length, elements); # DBM Filters $old_filter = $db->filter_store_key ( sub { ... } ) ; $old_filter = $db->filter_store_value( sub { ... } ) ; $old_filter = $db->filter_fetch_key ( sub { ... } ) ; $old_filter = $db->filter_fetch_value( sub { ... } ) ; untie %hash ; untie @array ; =head1 DESCRIPTION B is a module which allows Perl programs to make use of the facilities provided by Berkeley DB version 1.x (if you have a newer version of DB, see L). It is assumed that you have a copy of the Berkeley DB manual pages at hand when reading this documentation. The interface defined here mirrors the Berkeley DB interface closely. Berkeley DB is a C library which provides a consistent interface to a number of database formats. B provides an interface to all three of the database types currently supported by Berkeley DB. The file types are: =over 5 =item B This database type allows arbitrary key/value pairs to be stored in data files. This is equivalent to the functionality provided by other hashing packages like DBM, NDBM, ODBM, GDBM, and SDBM. Remember though, the files created using DB_HASH are not compatible with any of the other packages mentioned. A default hashing algorithm, which will be adequate for most applications, is built into Berkeley DB. If you do need to use your own hashing algorithm it is possible to write your own in Perl and have B use it instead. =item B The btree format allows arbitrary key/value pairs to be stored in a sorted, balanced binary tree. As with the DB_HASH format, it is possible to provide a user defined Perl routine to perform the comparison of keys. By default, though, the keys are stored in lexical order. =item B DB_RECNO allows both fixed-length and variable-length flat text files to be manipulated using the same key/value pair interface as in DB_HASH and DB_BTREE. In this case the key will consist of a record (line) number. =back =head2 Using DB_File with Berkeley DB version 2 or greater Although B is intended to be used with Berkeley DB version 1, it can also be used with version 2, 3 or 4. In this case the interface is limited to the functionality provided by Berkeley DB 1.x. Anywhere the version 2 or greater interface differs, B arranges for it to work like version 1. This feature allows B scripts that were built with version 1 to be migrated to version 2 or greater without any changes. If you want to make use of the new features available in Berkeley DB 2.x or greater, use the Perl module B instead. B The database file format has changed multiple times in Berkeley DB version 2, 3 and 4. If you cannot recreate your databases, you must dump any existing databases with either the C or the C utility that comes with Berkeley DB. Once you have rebuilt DB_File to use Berkeley DB version 2 or greater, your databases can be recreated using C. Refer to the Berkeley DB documentation for further details. Please read L<"COPYRIGHT"> before using version 2.x or greater of Berkeley DB with DB_File. =head2 Interface to Berkeley DB B allows access to Berkeley DB files using the tie() mechanism in Perl 5 (for full details, see L). This facility allows B to access Berkeley DB files using either an associative array (for DB_HASH & DB_BTREE file types) or an ordinary array (for the DB_RECNO file type). In addition to the tie() interface, it is also possible to access most of the functions provided in the Berkeley DB API directly. See L. =head2 Opening a Berkeley DB Database File Berkeley DB uses the function dbopen() to open or create a database. Here is the C prototype for dbopen(): DB* dbopen (const char * file, int flags, int mode, DBTYPE type, const void * openinfo) The parameter C is an enumeration which specifies which of the 3 interface methods (DB_HASH, DB_BTREE or DB_RECNO) is to be used. Depending on which of these is actually chosen, the final parameter, I points to a data structure which allows tailoring of the specific interface method. This interface is handled slightly differently in B. Here is an equivalent call using B: tie %array, 'DB_File', $filename, $flags, $mode, $DB_HASH ; The C, C and C parameters are the direct equivalent of their dbopen() counterparts. The final parameter $DB_HASH performs the function of both the C and C parameters in dbopen(). In the example above $DB_HASH is actually a pre-defined reference to a hash object. B has three of these pre-defined references. Apart from $DB_HASH, there is also $DB_BTREE and $DB_RECNO. The keys allowed in each of these pre-defined references is limited to the names used in the equivalent C structure. So, for example, the $DB_HASH reference will only allow keys called C, C, C, C, C and C. To change one of these elements, just assign to it like this: $DB_HASH->{'cachesize'} = 10000 ; The three predefined variables $DB_HASH, $DB_BTREE and $DB_RECNO are usually adequate for most applications. If you do need to create extra instances of these objects, constructors are available for each file type. Here are examples of the constructors and the valid options available for DB_HASH, DB_BTREE and DB_RECNO respectively. $a = new DB_File::HASHINFO ; $a->{'bsize'} ; $a->{'cachesize'} ; $a->{'ffactor'}; $a->{'hash'} ; $a->{'lorder'} ; $a->{'nelem'} ; $b = new DB_File::BTREEINFO ; $b->{'flags'} ; $b->{'cachesize'} ; $b->{'maxkeypage'} ; $b->{'minkeypage'} ; $b->{'psize'} ; $b->{'compare'} ; $b->{'prefix'} ; $b->{'lorder'} ; $c = new DB_File::RECNOINFO ; $c->{'bval'} ; $c->{'cachesize'} ; $c->{'psize'} ; $c->{'flags'} ; $c->{'lorder'} ; $c->{'reclen'} ; $c->{'bfname'} ; The values stored in the hashes above are mostly the direct equivalent of their C counterpart. Like their C counterparts, all are set to a default values - that means you don't have to set I of the values when you only want to change one. Here is an example: $a = new DB_File::HASHINFO ; $a->{'cachesize'} = 12345 ; tie %y, 'DB_File', "filename", $flags, 0777, $a ; A few of the options need extra discussion here. When used, the C equivalent of the keys C, C and C store pointers to C functions. In B these keys are used to store references to Perl subs. Below are templates for each of the subs: sub hash { my ($data) = @_ ; ... # return the hash value for $data return $hash ; } sub compare { my ($key, $key2) = @_ ; ... # return 0 if $key1 eq $key2 # -1 if $key1 lt $key2 # 1 if $key1 gt $key2 return (-1 , 0 or 1) ; } sub prefix { my ($key, $key2) = @_ ; ... # return number of bytes of $key2 which are # necessary to determine that it is greater than $key1 return $bytes ; } See L for an example of using the C template. If you are using the DB_RECNO interface and you intend making use of C, you should check out L. =head2 Default Parameters It is possible to omit some or all of the final 4 parameters in the call to C and let them take default values. As DB_HASH is the most common file format used, the call: tie %A, "DB_File", "filename" ; is equivalent to: tie %A, "DB_File", "filename", O_CREAT|O_RDWR, 0666, $DB_HASH ; It is also possible to omit the filename parameter as well, so the call: tie %A, "DB_File" ; is equivalent to: tie %A, "DB_File", undef, O_CREAT|O_RDWR, 0666, $DB_HASH ; See L for a discussion on the use of C in place of a filename. =head2 In Memory Databases Berkeley DB allows the creation of in-memory databases by using NULL (that is, a C<(char *)0> in C) in place of the filename. B uses C instead of NULL to provide this functionality. =head1 DB_HASH The DB_HASH file format is probably the most commonly used of the three file formats that B supports. It is also very straightforward to use. =head2 A Simple Example This example shows how to create a database, add key/value pairs to the database, delete keys/value pairs and finally how to enumerate the contents of the database. use warnings ; use strict ; use DB_File ; our (%h, $k, $v) ; unlink "fruit" ; tie %h, "DB_File", "fruit", O_RDWR|O_CREAT, 0666, $DB_HASH or die "Cannot open file 'fruit': $!\n"; # Add a few key/value pairs to the file $h{"apple"} = "red" ; $h{"orange"} = "orange" ; $h{"banana"} = "yellow" ; $h{"tomato"} = "red" ; # Check for existence of a key print "Banana Exists\n\n" if $h{"banana"} ; # Delete a key/value pair. delete $h{"apple"} ; # print the contents of the file while (($k, $v) = each %h) { print "$k -> $v\n" } untie %h ; here is the output: Banana Exists orange -> orange tomato -> red banana -> yellow Note that the like ordinary associative arrays, the order of the keys retrieved is in an apparently random order. =head1 DB_BTREE The DB_BTREE format is useful when you want to store data in a given order. By default the keys will be stored in lexical order, but as you will see from the example shown in the next section, it is very easy to define your own sorting function. =head2 Changing the BTREE sort order This script shows how to override the default sorting algorithm that BTREE uses. Instead of using the normal lexical ordering, a case insensitive compare function will be used. use warnings ; use strict ; use DB_File ; my %h ; sub Compare { my ($key1, $key2) = @_ ; "\L$key1" cmp "\L$key2" ; } # specify the Perl sub that will do the comparison $DB_BTREE->{'compare'} = \&Compare ; unlink "tree" ; tie %h, "DB_File", "tree", O_RDWR|O_CREAT, 0666, $DB_BTREE or die "Cannot open file 'tree': $!\n" ; # Add a key/value pair to the file $h{'Wall'} = 'Larry' ; $h{'Smith'} = 'John' ; $h{'mouse'} = 'mickey' ; $h{'duck'} = 'donald' ; # Delete delete $h{"duck"} ; # Cycle through the keys printing them in order. # Note it is not necessary to sort the keys as # the btree will have kept them in order automatically. foreach (keys %h) { print "$_\n" } untie %h ; Here is the output from the code above. mouse Smith Wall There are a few point to bear in mind if you want to change the ordering in a BTREE database: =over 5 =item 1. The new compare function must be specified when you create the database. =item 2. You cannot change the ordering once the database has been created. Thus you must use the same compare function every time you access the database. =item 3 Duplicate keys are entirely defined by the comparison function. In the case-insensitive example above, the keys: 'KEY' and 'key' would be considered duplicates, and assigning to the second one would overwrite the first. If duplicates are allowed for (with the R_DUP flag discussed below), only a single copy of duplicate keys is stored in the database --- so (again with example above) assigning three values to the keys: 'KEY', 'Key', and 'key' would leave just the first key: 'KEY' in the database with three values. For some situations this results in information loss, so care should be taken to provide fully qualified comparison functions when necessary. For example, the above comparison routine could be modified to additionally compare case-sensitively if two keys are equal in the case insensitive comparison: sub compare { my($key1, $key2) = @_; lc $key1 cmp lc $key2 || $key1 cmp $key2; } And now you will only have duplicates when the keys themselves are truly the same. (note: in versions of the db library prior to about November 1996, such duplicate keys were retained so it was possible to recover the original keys in sets of keys that compared as equal). =back =head2 Handling Duplicate Keys The BTREE file type optionally allows a single key to be associated with an arbitrary number of values. This option is enabled by setting the flags element of C<$DB_BTREE> to R_DUP when creating the database. There are some difficulties in using the tied hash interface if you want to manipulate a BTREE database with duplicate keys. Consider this code: use warnings ; use strict ; use DB_File ; my ($filename, %h) ; $filename = "tree" ; unlink $filename ; # Enable duplicate records $DB_BTREE->{'flags'} = R_DUP ; tie %h, "DB_File", $filename, O_RDWR|O_CREAT, 0666, $DB_BTREE or die "Cannot open $filename: $!\n"; # Add some key/value pairs to the file $h{'Wall'} = 'Larry' ; $h{'Wall'} = 'Brick' ; # Note the duplicate key $h{'Wall'} = 'Brick' ; # Note the duplicate key and value $h{'Smith'} = 'John' ; $h{'mouse'} = 'mickey' ; # iterate through the associative array # and print each key/value pair. foreach (sort keys %h) { print "$_ -> $h{$_}\n" } untie %h ; Here is the output: Smith -> John Wall -> Larry Wall -> Larry Wall -> Larry mouse -> mickey As you can see 3 records have been successfully created with key C - the only thing is, when they are retrieved from the database they I to have the same value, namely C. The problem is caused by the way that the associative array interface works. Basically, when the associative array interface is used to fetch the value associated with a given key, it will only ever retrieve the first value. Although it may not be immediately obvious from the code above, the associative array interface can be used to write values with duplicate keys, but it cannot be used to read them back from the database. The way to get around this problem is to use the Berkeley DB API method called C. This method allows sequential access to key/value pairs. See L for details of both the C method and the API in general. Here is the script above rewritten using the C API method. use warnings ; use strict ; use DB_File ; my ($filename, $x, %h, $status, $key, $value) ; $filename = "tree" ; unlink $filename ; # Enable duplicate records $DB_BTREE->{'flags'} = R_DUP ; $x = tie %h, "DB_File", $filename, O_RDWR|O_CREAT, 0666, $DB_BTREE or die "Cannot open $filename: $!\n"; # Add some key/value pairs to the file $h{'Wall'} = 'Larry' ; $h{'Wall'} = 'Brick' ; # Note the duplicate key $h{'Wall'} = 'Brick' ; # Note the duplicate key and value $h{'Smith'} = 'John' ; $h{'mouse'} = 'mickey' ; # iterate through the btree using seq # and print each key/value pair. $key = $value = 0 ; for ($status = $x->seq($key, $value, R_FIRST) ; $status == 0 ; $status = $x->seq($key, $value, R_NEXT) ) { print "$key -> $value\n" } undef $x ; untie %h ; that prints: Smith -> John Wall -> Brick Wall -> Brick Wall -> Larry mouse -> mickey This time we have got all the key/value pairs, including the multiple values associated with the key C. To make life easier when dealing with duplicate keys, B comes with a few utility methods. =head2 The get_dup() Method The C method assists in reading duplicate values from BTREE databases. The method can take the following forms: $count = $x->get_dup($key) ; @list = $x->get_dup($key) ; %list = $x->get_dup($key, 1) ; In a scalar context the method returns the number of values associated with the key, C<$key>. In list context, it returns all the values which match C<$key>. Note that the values will be returned in an apparently random order. In list context, if the second parameter is present and evaluates TRUE, the method returns an associative array. The keys of the associative array correspond to the values that matched in the BTREE and the values of the array are a count of the number of times that particular value occurred in the BTREE. So assuming the database created above, we can use C like this: use warnings ; use strict ; use DB_File ; my ($filename, $x, %h) ; $filename = "tree" ; # Enable duplicate records $DB_BTREE->{'flags'} = R_DUP ; $x = tie %h, "DB_File", $filename, O_RDWR|O_CREAT, 0666, $DB_BTREE or die "Cannot open $filename: $!\n"; my $cnt = $x->get_dup("Wall") ; print "Wall occurred $cnt times\n" ; my %hash = $x->get_dup("Wall", 1) ; print "Larry is there\n" if $hash{'Larry'} ; print "There are $hash{'Brick'} Brick Walls\n" ; my @list = sort $x->get_dup("Wall") ; print "Wall => [@list]\n" ; @list = $x->get_dup("Smith") ; print "Smith => [@list]\n" ; @list = $x->get_dup("Dog") ; print "Dog => [@list]\n" ; and it will print: Wall occurred 3 times Larry is there There are 2 Brick Walls Wall => [Brick Brick Larry] Smith => [John] Dog => [] =head2 The find_dup() Method $status = $X->find_dup($key, $value) ; This method checks for the existence of a specific key/value pair. If the pair exists, the cursor is left pointing to the pair and the method returns 0. Otherwise the method returns a non-zero value. Assuming the database from the previous example: use warnings ; use strict ; use DB_File ; my ($filename, $x, %h, $found) ; $filename = "tree" ; # Enable duplicate records $DB_BTREE->{'flags'} = R_DUP ; $x = tie %h, "DB_File", $filename, O_RDWR|O_CREAT, 0666, $DB_BTREE or die "Cannot open $filename: $!\n"; $found = ( $x->find_dup("Wall", "Larry") == 0 ? "" : "not") ; print "Larry Wall is $found there\n" ; $found = ( $x->find_dup("Wall", "Harry") == 0 ? "" : "not") ; print "Harry Wall is $found there\n" ; undef $x ; untie %h ; prints this Larry Wall is there Harry Wall is not there =head2 The del_dup() Method $status = $X->del_dup($key, $value) ; This method deletes a specific key/value pair. It returns 0 if they exist and have been deleted successfully. Otherwise the method returns a non-zero value. Again assuming the existence of the C database use warnings ; use strict ; use DB_File ; my ($filename, $x, %h, $found) ; $filename = "tree" ; # Enable duplicate records $DB_BTREE->{'flags'} = R_DUP ; $x = tie %h, "DB_File", $filename, O_RDWR|O_CREAT, 0666, $DB_BTREE or die "Cannot open $filename: $!\n"; $x->del_dup("Wall", "Larry") ; $found = ( $x->find_dup("Wall", "Larry") == 0 ? "" : "not") ; print "Larry Wall is $found there\n" ; undef $x ; untie %h ; prints this Larry Wall is not there =head2 Matching Partial Keys The BTREE interface has a feature which allows partial keys to be matched. This functionality is I available when the C method is used along with the R_CURSOR flag. $x->seq($key, $value, R_CURSOR) ; Here is the relevant quote from the dbopen man page where it defines the use of the R_CURSOR flag with seq: Note, for the DB_BTREE access method, the returned key is not necessarily an exact match for the specified key. The returned key is the smallest key greater than or equal to the specified key, permitting partial key matches and range searches. In the example script below, the C sub uses this feature to find and print the first matching key/value pair given a partial key. use warnings ; use strict ; use DB_File ; use Fcntl ; my ($filename, $x, %h, $st, $key, $value) ; sub match { my $key = shift ; my $value = 0; my $orig_key = $key ; $x->seq($key, $value, R_CURSOR) ; print "$orig_key\t-> $key\t-> $value\n" ; } $filename = "tree" ; unlink $filename ; $x = tie %h, "DB_File", $filename, O_RDWR|O_CREAT, 0666, $DB_BTREE or die "Cannot open $filename: $!\n"; # Add some key/value pairs to the file $h{'mouse'} = 'mickey' ; $h{'Wall'} = 'Larry' ; $h{'Walls'} = 'Brick' ; $h{'Smith'} = 'John' ; $key = $value = 0 ; print "IN ORDER\n" ; for ($st = $x->seq($key, $value, R_FIRST) ; $st == 0 ; $st = $x->seq($key, $value, R_NEXT) ) { print "$key -> $value\n" } print "\nPARTIAL MATCH\n" ; match "Wa" ; match "A" ; match "a" ; undef $x ; untie %h ; Here is the output: IN ORDER Smith -> John Wall -> Larry Walls -> Brick mouse -> mickey PARTIAL MATCH Wa -> Wall -> Larry A -> Smith -> John a -> mouse -> mickey =head1 DB_RECNO DB_RECNO provides an interface to flat text files. Both variable and fixed length records are supported. In order to make RECNO more compatible with Perl, the array offset for all RECNO arrays begins at 0 rather than 1 as in Berkeley DB. As with normal Perl arrays, a RECNO array can be accessed using negative indexes. The index -1 refers to the last element of the array, -2 the second last, and so on. Attempting to access an element before the start of the array will raise a fatal run-time error. =head2 The 'bval' Option The operation of the bval option warrants some discussion. Here is the definition of bval from the Berkeley DB 1.85 recno manual page: The delimiting byte to be used to mark the end of a record for variable-length records, and the pad charac- ter for fixed-length records. If no value is speci- fied, newlines (``\n'') are used to mark the end of variable-length records and fixed-length records are padded with spaces. The second sentence is wrong. In actual fact bval will only default to C<"\n"> when the openinfo parameter in dbopen is NULL. If a non-NULL openinfo parameter is used at all, the value that happens to be in bval will be used. That means you always have to specify bval when making use of any of the options in the openinfo parameter. This documentation error will be fixed in the next release of Berkeley DB. That clarifies the situation with regards Berkeley DB itself. What about B? Well, the behavior defined in the quote above is quite useful, so B conforms to it. That means that you can specify other options (e.g. cachesize) and still have bval default to C<"\n"> for variable length records, and space for fixed length records. Also note that the bval option only allows you to specify a single byte as a delimiter. =head2 A Simple Example Here is a simple example that uses RECNO (if you are using a version of Perl earlier than 5.004_57 this example won't work -- see L for a workaround). use warnings ; use strict ; use DB_File ; my $filename = "text" ; unlink $filename ; my @h ; tie @h, "DB_File", $filename, O_RDWR|O_CREAT, 0666, $DB_RECNO or die "Cannot open file 'text': $!\n" ; # Add a few key/value pairs to the file $h[0] = "orange" ; $h[1] = "blue" ; $h[2] = "yellow" ; push @h, "green", "black" ; my $elements = scalar @h ; print "The array contains $elements entries\n" ; my $last = pop @h ; print "popped $last\n" ; unshift @h, "white" ; my $first = shift @h ; print "shifted $first\n" ; # Check for existence of a key print "Element 1 Exists with value $h[1]\n" if $h[1] ; # use a negative index print "The last element is $h[-1]\n" ; print "The 2nd last element is $h[-2]\n" ; untie @h ; Here is the output from the script: The array contains 5 entries popped black shifted white Element 1 Exists with value blue The last element is green The 2nd last element is yellow =head2 Extra RECNO Methods If you are using a version of Perl earlier than 5.004_57, the tied array interface is quite limited. In the example script above C, C, C, C or determining the array length will not work with a tied array. To make the interface more useful for older versions of Perl, a number of methods are supplied with B to simulate the missing array operations. All these methods are accessed via the object returned from the tie call. Here are the methods: =over 5 =item B<$X-Epush(list) ;> Pushes the elements of C to the end of the array. =item B<$value = $X-Epop ;> Removes and returns the last element of the array. =item B<$X-Eshift> Removes and returns the first element of the array. =item B<$X-Eunshift(list) ;> Pushes the elements of C to the start of the array. =item B<$X-Elength> Returns the number of elements in the array. =item B<$X-Esplice(offset, length, elements);> Returns a splice of the array. =back =head2 Another Example Here is a more complete example that makes use of some of the methods described above. It also makes use of the API interface directly (see L). use warnings ; use strict ; my (@h, $H, $file, $i) ; use DB_File ; use Fcntl ; $file = "text" ; unlink $file ; $H = tie @h, "DB_File", $file, O_RDWR|O_CREAT, 0666, $DB_RECNO or die "Cannot open file $file: $!\n" ; # first create a text file to play with $h[0] = "zero" ; $h[1] = "one" ; $h[2] = "two" ; $h[3] = "three" ; $h[4] = "four" ; # Print the records in order. # # The length method is needed here because evaluating a tied # array in a scalar context does not return the number of # elements in the array. print "\nORIGINAL\n" ; foreach $i (0 .. $H->length - 1) { print "$i: $h[$i]\n" ; } # use the push & pop methods $a = $H->pop ; $H->push("last") ; print "\nThe last record was [$a]\n" ; # and the shift & unshift methods $a = $H->shift ; $H->unshift("first") ; print "The first record was [$a]\n" ; # Use the API to add a new record after record 2. $i = 2 ; $H->put($i, "Newbie", R_IAFTER) ; # and a new record before record 1. $i = 1 ; $H->put($i, "New One", R_IBEFORE) ; # delete record 3 $H->del(3) ; # now print the records in reverse order print "\nREVERSE\n" ; for ($i = $H->length - 1 ; $i >= 0 ; -- $i) { print "$i: $h[$i]\n" } # same again, but use the API functions instead print "\nREVERSE again\n" ; my ($s, $k, $v) = (0, 0, 0) ; for ($s = $H->seq($k, $v, R_LAST) ; $s == 0 ; $s = $H->seq($k, $v, R_PREV)) { print "$k: $v\n" } undef $H ; untie @h ; and this is what it outputs: ORIGINAL 0: zero 1: one 2: two 3: three 4: four The last record was [four] The first record was [zero] REVERSE 5: last 4: three 3: Newbie 2: one 1: New One 0: first REVERSE again 5: last 4: three 3: Newbie 2: one 1: New One 0: first Notes: =over 5 =item 1. Rather than iterating through the array, C<@h> like this: foreach $i (@h) it is necessary to use either this: foreach $i (0 .. $H->length - 1) or this: for ($a = $H->get($k, $v, R_FIRST) ; $a == 0 ; $a = $H->get($k, $v, R_NEXT) ) =item 2. Notice that both times the C method was used the record index was specified using a variable, C<$i>, rather than the literal value itself. This is because C will return the record number of the inserted line via that parameter. =back =head1 THE API INTERFACE As well as accessing Berkeley DB using a tied hash or array, it is also possible to make direct use of most of the API functions defined in the Berkeley DB documentation. To do this you need to store a copy of the object returned from the tie. $db = tie %hash, "DB_File", "filename" ; Once you have done that, you can access the Berkeley DB API functions as B methods directly like this: $db->put($key, $value, R_NOOVERWRITE) ; B If you have saved a copy of the object returned from C, the underlying database file will I be closed until both the tied variable is untied and all copies of the saved object are destroyed. use DB_File ; $db = tie %hash, "DB_File", "filename" or die "Cannot tie filename: $!" ; ... undef $db ; untie %hash ; See L for more details. All the functions defined in L are available except for close() and dbopen() itself. The B method interface to the supported functions have been implemented to mirror the way Berkeley DB works whenever possible. In particular note that: =over 5 =item * The methods return a status value. All return 0 on success. All return -1 to signify an error and set C<$!> to the exact error code. The return code 1 generally (but not always) means that the key specified did not exist in the database. Other return codes are defined. See below and in the Berkeley DB documentation for details. The Berkeley DB documentation should be used as the definitive source. =item * Whenever a Berkeley DB function returns data via one of its parameters, the equivalent B method does exactly the same. =item * If you are careful, it is possible to mix API calls with the tied hash/array interface in the same piece of code. Although only a few of the methods used to implement the tied interface currently make use of the cursor, you should always assume that the cursor has been changed any time the tied hash/array interface is used. As an example, this code will probably not do what you expect: $X = tie %x, 'DB_File', $filename, O_RDWR|O_CREAT, 0777, $DB_BTREE or die "Cannot tie $filename: $!" ; # Get the first key/value pair and set the cursor $X->seq($key, $value, R_FIRST) ; # this line will modify the cursor $count = scalar keys %x ; # Get the second key/value pair. # oops, it didn't, it got the last key/value pair! $X->seq($key, $value, R_NEXT) ; The code above can be rearranged to get around the problem, like this: $X = tie %x, 'DB_File', $filename, O_RDWR|O_CREAT, 0777, $DB_BTREE or die "Cannot tie $filename: $!" ; # this line will modify the cursor $count = scalar keys %x ; # Get the first key/value pair and set the cursor $X->seq($key, $value, R_FIRST) ; # Get the second key/value pair. # worked this time. $X->seq($key, $value, R_NEXT) ; =back All the constants defined in L for use in the flags parameters in the methods defined below are also available. Refer to the Berkeley DB documentation for the precise meaning of the flags values. Below is a list of the methods available. =over 5 =item B<$status = $X-Eget($key, $value [, $flags]) ;> Given a key (C<$key>) this method reads the value associated with it from the database. The value read from the database is returned in the C<$value> parameter. If the key does not exist the method returns 1. No flags are currently defined for this method. =item B<$status = $X-Eput($key, $value [, $flags]) ;> Stores the key/value pair in the database. If you use either the R_IAFTER or R_IBEFORE flags, the C<$key> parameter will have the record number of the inserted key/value pair set. Valid flags are R_CURSOR, R_IAFTER, R_IBEFORE, R_NOOVERWRITE and R_SETCURSOR. =item B<$status = $X-Edel($key [, $flags]) ;> Removes all key/value pairs with key C<$key> from the database. A return code of 1 means that the requested key was not in the database. R_CURSOR is the only valid flag at present. =item B<$status = $X-Efd ;> Returns the file descriptor for the underlying database. See L for an explanation for why you should not use C to lock your database. =item B<$status = $X-Eseq($key, $value, $flags) ;> This interface allows sequential retrieval from the database. See L for full details. Both the C<$key> and C<$value> parameters will be set to the key/value pair read from the database. The flags parameter is mandatory. The valid flag values are R_CURSOR, R_FIRST, R_LAST, R_NEXT and R_PREV. =item B<$status = $X-Esync([$flags]) ;> Flushes any cached buffers to disk. R_RECNOSYNC is the only valid flag at present. =back =head1 DBM FILTERS A DBM Filter is a piece of code that is be used when you I want to make the same transformation to all keys and/or values in a DBM database. There are four methods associated with DBM Filters. All work identically, and each is used to install (or uninstall) a single DBM Filter. Each expects a single parameter, namely a reference to a sub. The only difference between them is the place that the filter is installed. To summarise: =over 5 =item B If a filter has been installed with this method, it will be invoked every time you write a key to a DBM database. =item B If a filter has been installed with this method, it will be invoked every time you write a value to a DBM database. =item B If a filter has been installed with this method, it will be invoked every time you read a key from a DBM database. =item B If a filter has been installed with this method, it will be invoked every time you read a value from a DBM database. =back You can use any combination of the methods, from none, to all four. All filter methods return the existing filter, if present, or C in not. To delete a filter pass C to it. =head2 The Filter When each filter is called by Perl, a local copy of C<$_> will contain the key or value to be filtered. Filtering is achieved by modifying the contents of C<$_>. The return code from the filter is ignored. =head2 An Example -- the NULL termination problem. Consider the following scenario. You have a DBM database that you need to share with a third-party C application. The C application assumes that I keys and values are NULL terminated. Unfortunately when Perl writes to DBM databases it doesn't use NULL termination, so your Perl application will have to manage NULL termination itself. When you write to the database you will have to use something like this: $hash{"$key\0"} = "$value\0" ; Similarly the NULL needs to be taken into account when you are considering the length of existing keys/values. It would be much better if you could ignore the NULL terminations issue in the main application code and have a mechanism that automatically added the terminating NULL to all keys and values whenever you write to the database and have them removed when you read from the database. As I'm sure you have already guessed, this is a problem that DBM Filters can fix very easily. use warnings ; use strict ; use DB_File ; my %hash ; my $filename = "filt" ; unlink $filename ; my $db = tie %hash, 'DB_File', $filename, O_CREAT|O_RDWR, 0666, $DB_HASH or die "Cannot open $filename: $!\n" ; # Install DBM Filters $db->filter_fetch_key ( sub { s/\0$// } ) ; $db->filter_store_key ( sub { $_ .= "\0" } ) ; $db->filter_fetch_value( sub { s/\0$// } ) ; $db->filter_store_value( sub { $_ .= "\0" } ) ; $hash{"abc"} = "def" ; my $a = $hash{"ABC"} ; # ... undef $db ; untie %hash ; Hopefully the contents of each of the filters should be self-explanatory. Both "fetch" filters remove the terminating NULL, and both "store" filters add a terminating NULL. =head2 Another Example -- Key is a C int. Here is another real-life example. By default, whenever Perl writes to a DBM database it always writes the key and value as strings. So when you use this: $hash{12345} = "something" ; the key 12345 will get stored in the DBM database as the 5 byte string "12345". If you actually want the key to be stored in the DBM database as a C int, you will have to use C when writing, and C when reading. Here is a DBM Filter that does it: use warnings ; use strict ; use DB_File ; my %hash ; my $filename = "filt" ; unlink $filename ; my $db = tie %hash, 'DB_File', $filename, O_CREAT|O_RDWR, 0666, $DB_HASH or die "Cannot open $filename: $!\n" ; $db->filter_fetch_key ( sub { $_ = unpack("i", $_) } ) ; $db->filter_store_key ( sub { $_ = pack ("i", $_) } ) ; $hash{123} = "def" ; # ... undef $db ; untie %hash ; This time only two filters have been used -- we only need to manipulate the contents of the key, so it wasn't necessary to install any value filters. =head1 HINTS AND TIPS =head2 Locking: The Trouble with fd Until version 1.72 of this module, the recommended technique for locking B databases was to flock the filehandle returned from the "fd" function. Unfortunately this technique has been shown to be fundamentally flawed (Kudos to David Harris for tracking this down). Use it at your own peril! The locking technique went like this. $db = tie(%db, 'DB_File', 'foo.db', O_CREAT|O_RDWR, 0644) || die "dbcreat foo.db $!"; $fd = $db->fd; open(DB_FH, "+<&=$fd") || die "dup $!"; flock (DB_FH, LOCK_EX) || die "flock: $!"; ... $db{"Tom"} = "Jerry" ; ... flock(DB_FH, LOCK_UN); undef $db; untie %db; close(DB_FH); In simple terms, this is what happens: =over 5 =item 1. Use "tie" to open the database. =item 2. Lock the database with fd & flock. =item 3. Read & Write to the database. =item 4. Unlock and close the database. =back Here is the crux of the problem. A side-effect of opening the B database in step 2 is that an initial block from the database will get read from disk and cached in memory. To see why this is a problem, consider what can happen when two processes, say "A" and "B", both want to update the same B database using the locking steps outlined above. Assume process "A" has already opened the database and has a write lock, but it hasn't actually updated the database yet (it has finished step 2, but not started step 3 yet). Now process "B" tries to open the same database - step 1 will succeed, but it will block on step 2 until process "A" releases the lock. The important thing to notice here is that at this point in time both processes will have cached identical initial blocks from the database. Now process "A" updates the database and happens to change some of the data held in the initial buffer. Process "A" terminates, flushing all cached data to disk and releasing the database lock. At this point the database on disk will correctly reflect the changes made by process "A". With the lock released, process "B" can now continue. It also updates the database and unfortunately it too modifies the data that was in its initial buffer. Once that data gets flushed to disk it will overwrite some/all of the changes process "A" made to the database. The result of this scenario is at best a database that doesn't contain what you expect. At worst the database will corrupt. The above won't happen every time competing process update the same B database, but it does illustrate why the technique should not be used. =head2 Safe ways to lock a database Starting with version 2.x, Berkeley DB has internal support for locking. The companion module to this one, B, provides an interface to this locking functionality. If you are serious about locking Berkeley DB databases, I strongly recommend using B. If using B isn't an option, there are a number of modules available on CPAN that can be used to implement locking. Each one implements locking differently and has different goals in mind. It is therefore worth knowing the difference, so that you can pick the right one for your application. Here are the three locking wrappers: =over 5 =item B A B wrapper which creates copies of the database file for read access, so that you have a kind of a multiversioning concurrent read system. However, updates are still serial. Use for databases where reads may be lengthy and consistency problems may occur. =item B A B wrapper that has the ability to lock and unlock the database while it is being used. Avoids the tie-before-flock problem by simply re-tie-ing the database when you get or drop a lock. Because of the flexibility in dropping and re-acquiring the lock in the middle of a session, this can be massaged into a system that will work with long updates and/or reads if the application follows the hints in the POD documentation. =item B An extremely lightweight B wrapper that simply flocks a lockfile before tie-ing the database and drops the lock after the untie. Allows one to use the same lockfile for multiple databases to avoid deadlock problems, if desired. Use for databases where updates are reads are quick and simple flock locking semantics are enough. =back =head2 Sharing Databases With C Applications There is no technical reason why a Berkeley DB database cannot be shared by both a Perl and a C application. The vast majority of problems that are reported in this area boil down to the fact that C strings are NULL terminated, whilst Perl strings are not. See L for a generic way to work around this problem. Here is a real example. Netscape 2.0 keeps a record of the locations you visit along with the time you last visited them in a DB_HASH database. This is usually stored in the file F<~/.netscape/history.db>. The key field in the database is the location string and the value field is the time the location was last visited stored as a 4 byte binary value. If you haven't already guessed, the location string is stored with a terminating NULL. This means you need to be careful when accessing the database. Here is a snippet of code that is loosely based on Tom Christiansen's I script (available from your nearest CPAN archive in F). use warnings ; use strict ; use DB_File ; use Fcntl ; my ($dotdir, $HISTORY, %hist_db, $href, $binary_time, $date) ; $dotdir = $ENV{HOME} || $ENV{LOGNAME}; $HISTORY = "$dotdir/.netscape/history.db"; tie %hist_db, 'DB_File', $HISTORY or die "Cannot open $HISTORY: $!\n" ;; # Dump the complete database while ( ($href, $binary_time) = each %hist_db ) { # remove the terminating NULL $href =~ s/\x00$// ; # convert the binary time into a user friendly string $date = localtime unpack("V", $binary_time); print "$date $href\n" ; } # check for the existence of a specific key # remember to add the NULL if ( $binary_time = $hist_db{"http://mox.perl.com/\x00"} ) { $date = localtime unpack("V", $binary_time) ; print "Last visited mox.perl.com on $date\n" ; } else { print "Never visited mox.perl.com\n" } untie %hist_db ; =head2 The untie() Gotcha If you make use of the Berkeley DB API, it is I strongly recommended that you read L. Even if you don't currently make use of the API interface, it is still worth reading it. Here is an example which illustrates the problem from a B perspective: use DB_File ; use Fcntl ; my %x ; my $X ; $X = tie %x, 'DB_File', 'tst.fil' , O_RDWR|O_TRUNC or die "Cannot tie first time: $!" ; $x{123} = 456 ; untie %x ; tie %x, 'DB_File', 'tst.fil' , O_RDWR|O_CREAT or die "Cannot tie second time: $!" ; untie %x ; When run, the script will produce this error message: Cannot tie second time: Invalid argument at bad.file line 14. Although the error message above refers to the second tie() statement in the script, the source of the problem is really with the untie() statement that precedes it. Having read L you will probably have already guessed that the error is caused by the extra copy of the tied object stored in C<$X>. If you haven't, then the problem boils down to the fact that the B destructor, DESTROY, will not be called until I references to the tied object are destroyed. Both the tied variable, C<%x>, and C<$X> above hold a reference to the object. The call to untie() will destroy the first, but C<$X> still holds a valid reference, so the destructor will not get called and the database file F will remain open. The fact that Berkeley DB then reports the attempt to open a database that is already open via the catch-all "Invalid argument" doesn't help. If you run the script with the C<-w> flag the error message becomes: untie attempted while 1 inner references still exist at bad.file line 12. Cannot tie second time: Invalid argument at bad.file line 14. which pinpoints the real problem. Finally the script can now be modified to fix the original problem by destroying the API object before the untie: ... $x{123} = 456 ; undef $X ; untie %x ; $X = tie %x, 'DB_File', 'tst.fil' , O_RDWR|O_CREAT ... =head1 COMMON QUESTIONS =head2 Why is there Perl source in my database? If you look at the contents of a database file created by DB_File, there can sometimes be part of a Perl script included in it. This happens because Berkeley DB uses dynamic memory to allocate buffers which will subsequently be written to the database file. Being dynamic, the memory could have been used for anything before DB malloced it. As Berkeley DB doesn't clear the memory once it has been allocated, the unused portions will contain random junk. In the case where a Perl script gets written to the database, the random junk will correspond to an area of dynamic memory that happened to be used during the compilation of the script. Unless you don't like the possibility of there being part of your Perl scripts embedded in a database file, this is nothing to worry about. =head2 How do I store complex data structures with DB_File? Although B cannot do this directly, there is a module which can layer transparently over B to accomplish this feat. Check out the MLDBM module, available on CPAN in the directory F. =head2 What does "Invalid Argument" mean? You will get this error message when one of the parameters in the C call is wrong. Unfortunately there are quite a few parameters to get wrong, so it can be difficult to figure out which one it is. Here are a couple of possibilities: =over 5 =item 1. Attempting to reopen a database without closing it. =item 2. Using the O_WRONLY flag. =back =head2 What does "Bareword 'DB_File' not allowed" mean? You will encounter this particular error message when you have the C pragma (or the full strict pragma) in your script. Consider this script: use warnings ; use strict ; use DB_File ; my %x ; tie %x, DB_File, "filename" ; Running it produces the error in question: Bareword "DB_File" not allowed while "strict subs" in use To get around the error, place the word C in either single or double quotes, like this: tie %x, "DB_File", "filename" ; Although it might seem like a real pain, it is really worth the effort of having a C in all your scripts. =head1 REFERENCES Articles that are either about B or make use of it. =over 5 =item 1. I, Tim Kientzle (tkientzle@ddj.com), Dr. Dobb's Journal, Issue 295, January 1999, pp 34-41 =back =head1 HISTORY Moved to the Changes file. =head1 BUGS Some older versions of Berkeley DB had problems with fixed length records using the RECNO file format. This problem has been fixed since version 1.85 of Berkeley DB. I am sure there are bugs in the code. If you do find any, or can suggest any enhancements, I would welcome your comments. =head1 AVAILABILITY B comes with the standard Perl source distribution. Look in the directory F. Given the amount of time between releases of Perl the version that ships with Perl is quite likely to be out of date, so the most recent version can always be found on CPAN (see L for details), in the directory F. This version of B will work with either version 1.x, 2.x or 3.x of Berkeley DB, but is limited to the functionality provided by version 1. The official web site for Berkeley DB is F. All versions of Berkeley DB are available there. Alternatively, Berkeley DB version 1 is available at your nearest CPAN archive in F. If you are running IRIX, then get Berkeley DB version 1 from F. It has the patches necessary to compile properly on IRIX 5.3. =head1 COPYRIGHT Copyright (c) 1995-2007 Paul Marquess. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Although B is covered by the Perl license, the library it makes use of, namely Berkeley DB, is not. Berkeley DB has its own copyright and its own license. Please take the time to read it. Here are are few words taken from the Berkeley DB FAQ (at F) regarding the license: Do I have to license DB to use it in Perl scripts? No. The Berkeley DB license requires that software that uses Berkeley DB be freely redistributable. In the case of Perl, that software is Perl, and not your scripts. Any Perl scripts that you write are your property, including scripts that make use of Berkeley DB. Neither the Perl license nor the Berkeley DB license place any restriction on what you may do with them. If you are in any doubt about the license situation, contact either the Berkeley DB authors or the author of DB_File. See L<"AUTHOR"> for details. =head1 SEE ALSO L, L, L, L, L, L =head1 AUTHOR The DB_File interface was written by Paul Marquess Epmqs@cpan.orgE. =cut PK[[뭃5.10.1/Hash/Util.pmnuW+Apackage Hash::Util; require 5.007003; use strict; use Carp; use warnings; use warnings::register; use Scalar::Util qw(reftype); require Exporter; our @ISA = qw(Exporter); our @EXPORT_OK = qw( fieldhash fieldhashes all_keys lock_keys unlock_keys lock_value unlock_value lock_hash unlock_hash lock_keys_plus hash_locked hidden_keys legal_keys lock_ref_keys unlock_ref_keys lock_ref_value unlock_ref_value lock_hashref unlock_hashref lock_ref_keys_plus hashref_locked hidden_ref_keys legal_ref_keys hash_seed hv_store ); our $VERSION = 0.07; require DynaLoader; local @ISA = qw(DynaLoader); bootstrap Hash::Util $VERSION; sub import { my $class = shift; if ( grep /fieldhash/, @_ ) { require Hash::Util::FieldHash; Hash::Util::FieldHash->import(':all'); # for re-export } unshift @_, $class; goto &Exporter::import; } sub lock_ref_keys { my($hash, @keys) = @_; Internals::hv_clear_placeholders %$hash; if( @keys ) { my %keys = map { ($_ => 1) } @keys; my %original_keys = map { ($_ => 1) } keys %$hash; foreach my $k (keys %original_keys) { croak "Hash has key '$k' which is not in the new key set" unless $keys{$k}; } foreach my $k (@keys) { $hash->{$k} = undef unless exists $hash->{$k}; } Internals::SvREADONLY %$hash, 1; foreach my $k (@keys) { delete $hash->{$k} unless $original_keys{$k}; } } else { Internals::SvREADONLY %$hash, 1; } return $hash; } sub unlock_ref_keys { my $hash = shift; Internals::SvREADONLY %$hash, 0; return $hash; } sub lock_keys (\%;@) { lock_ref_keys(@_) } sub unlock_keys (\%) { unlock_ref_keys(@_) } sub lock_ref_keys_plus { my ($hash,@keys)=@_; my @delete; Internals::hv_clear_placeholders(%$hash); foreach my $key (@keys) { unless (exists($hash->{$key})) { $hash->{$key}=undef; push @delete,$key; } } Internals::SvREADONLY(%$hash,1); delete @{$hash}{@delete}; return $hash } sub lock_keys_plus(\%;@) { lock_ref_keys_plus(@_) } sub lock_ref_value { my($hash, $key) = @_; # I'm doubtful about this warning, as it seems not to be true. # Marking a value in the hash as RO is useful, regardless # of the status of the hash itself. carp "Cannot usefully lock values in an unlocked hash" if !Internals::SvREADONLY(%$hash) && warnings::enabled; Internals::SvREADONLY $hash->{$key}, 1; return $hash } sub unlock_ref_value { my($hash, $key) = @_; Internals::SvREADONLY $hash->{$key}, 0; return $hash } sub lock_value (\%$) { lock_ref_value(@_) } sub unlock_value (\%$) { unlock_ref_value(@_) } sub lock_hashref { my $hash = shift; lock_ref_keys($hash); foreach my $value (values %$hash) { Internals::SvREADONLY($value,1); } return $hash; } sub unlock_hashref { my $hash = shift; foreach my $value (values %$hash) { Internals::SvREADONLY($value, 0); } unlock_ref_keys($hash); return $hash; } sub lock_hash (\%) { lock_hashref(@_) } sub unlock_hash (\%) { unlock_hashref(@_) } sub lock_hashref_recurse { my $hash = shift; lock_ref_keys($hash); foreach my $value (values %$hash) { if (reftype($value) eq 'HASH') { lock_hashref_recurse($value); } Internals::SvREADONLY($value,1); } return $hash } sub unlock_hashref_recurse { my $hash = shift; foreach my $value (values %$hash) { if (reftype($value) eq 'HASH') { unlock_hashref_recurse($value); } Internals::SvREADONLY($value,1); } unlock_ref_keys($hash); return $hash; } sub lock_hash_recurse (\%) { lock_hashref_recurse(@_) } sub unlock_hash_recurse (\%) { unlock_hashref_recurse(@_) } sub hashref_unlocked { my $hash=shift; return Internals::SvREADONLY($hash) } sub hash_unlocked(\%) { hashref_unlocked(@_) } sub legal_keys(\%) { legal_ref_keys(@_) } sub hidden_keys(\%){ hidden_ref_keys(@_) } sub hash_seed () { Internals::rehash_seed(); } 1; PK[[[btbt5.10.1/Hash/Util/FieldHash.pmnuW+Apackage Hash::Util::FieldHash; use 5.009004; use strict; use warnings; use Scalar::Util qw( reftype); our $VERSION = '1.04'; require Exporter; our @ISA = qw(Exporter); our %EXPORT_TAGS = ( 'all' => [ qw( fieldhash fieldhashes idhash idhashes id id_2obj register )], ); our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); { require XSLoader; my %ob_reg; # private object registry sub _ob_reg { \ %ob_reg } XSLoader::load('Hash::Util::FieldHash', $VERSION); } sub fieldhash (\%) { for ( shift ) { return unless ref() && reftype( $_) eq 'HASH'; return $_ if Hash::Util::FieldHash::_fieldhash( $_, 0); return $_ if Hash::Util::FieldHash::_fieldhash( $_, 2) == 2; return; } } sub idhash (\%) { for ( shift ) { return unless ref() && reftype( $_) eq 'HASH'; return $_ if Hash::Util::FieldHash::_fieldhash( $_, 0); return $_ if Hash::Util::FieldHash::_fieldhash( $_, 1) == 1; return; } } sub fieldhashes { map &fieldhash( $_), @_ } sub idhashes { map &idhash( $_), @_ } 1; __END__ =head1 NAME Hash::Util::FieldHash - Support for Inside-Out Classes =head1 SYNOPSIS ### Create fieldhashes use Hash::Util qw(fieldhash fieldhashes); # Create a single field hash fieldhash my %foo; # Create three at once... fieldhashes \ my(%foo, %bar, %baz); # ...or any number fieldhashes @hashrefs; ### Create an idhash and register it for garbage collection use Hash::Util::FieldHash qw(idhash register); idhash my %name; my $object = \ do { my $o }; # register the idhash for garbage collection with $object register($object, \ %name); # the following entry will be deleted when $object goes out of scope $name{$object} = 'John Doe'; ### Register an ordinary hash for garbage collection use Hash::Util::FieldHash qw(id register); my %name; my $object = \ do { my $o }; # register the hash %name for garbage collection of $object's id register $object, \ %name; # the following entry will be deleted when $object goes out of scope $name{id $object} = 'John Doe'; =head1 FUNCTIONS C offers a number of functions in support of L of class construction. =over =item id id($obj) Returns the reference address of a reference $obj. If $obj is not a reference, returns $obj. This function is a stand-in replacement for L, that is, it returns the reference address of its argument as a numeric value. The only difference is that C returns C when given a non-reference while C returns its argument unchanged. C also uses a caching technique that makes it faster when the id of an object is requested often, but slower if it is needed only once or twice. =item id_2obj $obj = id_2obj($id) If C<$id> is the id of a registered object (see L), returns the object, otherwise an undefined value. For registered objects this is the inverse function of C. =item register register($obj) register($obj, @hashrefs) In the first form, registers an object to work with for the function C. In the second form, it additionally marks the given hashrefs down for garbage collection. This means that when the object goes out of scope, any entries in the given hashes under the key of C will be deleted from the hashes. It is a fatal error to register a non-reference $obj. Any non-hashrefs among the following arguments are silently ignored. It is I an error to register the same object multiple times with varying sets of hashrefs. Any hashrefs that are not registered yet will be added, others ignored. Registry also implies thread support. When a new thread is created, all references are replaced with new ones, including all objects. If a hash uses the reference address of an object as a key, that connection would be broken. With a registered object, its id will be updated in all hashes registered with it. =item idhash idhash my %hash Makes an idhash from the argument, which must be a hash. An I works like a normal hash, except that it stringifies a I differently. A reference is stringified as if the C function had been invoked on it, that is, its reference address in decimal is used as the key. =item idhashes idhashes \ my(%hash, %gnash, %trash) idhashes \ @hashrefs Creates many idhashes from its hashref arguments. Returns those arguments that could be converted or their number in scalar context. =item fieldhash fieldhash %hash; Creates a single fieldhash. The argument must be a hash. Returns a reference to the given hash if successful, otherwise nothing. A I is, in short, an idhash with auto-registry. When an object (or, indeed, any reference) is used as a fieldhash key, the fieldhash is automatically registered for garbage collection with the object, as if C had been called. =item fieldhashes fieldhashes @hashrefs; Creates any number of field hashes. Arguments must be hash references. Returns the converted hashrefs in list context, their number in scalar context. =back =head1 DESCRIPTION A word on terminology: I shall use the term I for a scalar piece of data that a class associates with an object. Other terms that have been used for this concept are "object variable", "(object) property", "(object) attribute" and more. Especially "attribute" has some currency among Perl programmer, but that clashes with the C pragma. The term "field" also has some currency in this sense and doesn't seem to conflict with other Perl terminology. In Perl, an object is a blessed reference. The standard way of associating data with an object is to store the data inside the object's body, that is, the piece of data pointed to by the reference. In consequence, if two or more classes want to access an object they I agree on the type of reference and also on the organization of data within the object body. Failure to agree on the type results in immediate death when the wrong method tries to access an object. Failure to agree on data organization may lead to one class trampling over the data of another. This object model leads to a tight coupling between subclasses. If one class wants to inherit from another (and both classes access object data), the classes must agree about implementation details. Inheritance can only be used among classes that are maintained together, in a single source or not. In particular, it is not possible to write general-purpose classes in this technique, classes that can advertise themselves as "Put me on your @ISA list and use my methods". If the other class has different ideas about how the object body is used, there is trouble. For reference L in L shows the standard implementation of a simple class C in the well-known hash based way. It also demonstrates the predictable failure to construct a common subclass C of C and the class C (whose objects I be globrefs). Thus, techniques are of interest that store object data I in the object body but some other place. =head2 The Inside-out Technique With I classes, each class declares a (typically lexical) hash for each field it wants to use. The reference address of an object is used as the hash key. By definition, the reference address is unique to each object so this guarantees a place for each field that is private to the class and unique to each object. See L in L for a simple example. In comparison to the standard implementation where the object is a hash and the fields correspond to hash keys, here the fields correspond to hashes, and the object determines the hash key. Thus the hashes appear to be turned I. The body of an object is never examined by an inside-out class, only its reference address is used. This allows for the body of an actual object to be I while the object methods of the class still work as designed. This is a key feature of inside-out classes. =head2 Problems of Inside-out Inside-out classes give us freedom of inheritance, but as usual there is a price. Most obviously, there is the necessity of retrieving the reference address of an object for each data access. It's a minor inconvenience, but it does clutter the code. More important (and less obvious) is the necessity of garbage collection. When a normal object dies, anything stored in the object body is garbage-collected by perl. With inside-out objects, Perl knows nothing about the data stored in field hashes by a class, but these must be deleted when the object goes out of scope. Thus the class must provide a C method to take care of that. In the presence of multiple classes it can be non-trivial to make sure that every relevant destructor is called for every object. Perl calls the first one it finds on the inheritance tree (if any) and that's it. A related issue is thread-safety. When a new thread is created, the Perl interpreter is cloned, which implies that all reference addresses in use will be replaced with new ones. Thus, if a class tries to access a field of a cloned object its (cloned) data will still be stored under the now invalid reference address of the original in the parent thread. A general C method must be provided to re-establish the association. =head2 Solutions C addresses these issues on several levels. The C function is provided in addition to the existing C. Besides its short name it can be a little faster under some circumstances (and a bit slower under others). Benchmark if it matters. The working of C also allows the use of the class name as a I as described L. The C function is incorporated in I in the sense that it is called automatically on every key that is used with the hash. No explicit call is necessary. The problems of garbage collection and thread safety are both addressed by the function C. It registers an object together with any number of hashes. Registry means that when the object dies, an entry in any of the hashes under the reference address of this object will be deleted. This guarantees garbage collection in these hashes. It also means that on thread cloning the object's entries in registered hashes will be replaced with updated entries whose key is the cloned object's reference address. Thus the object-data association becomes thread-safe. Object registry is best done when the object is initialized for use with a class. That way, garbage collection and thread safety are established for every object and every field that is initialized. Finally, I incorporate all these functions in one package. Besides automatically calling the C function on every object used as a key, the object is registered with the field hash on first use. Classes based on field hashes are fully garbage-collected and thread safe without further measures. =head2 More Problems Another problem that occurs with inside-out classes is serialization. Since the object data is not in its usual place, standard routines like C, C and C can't deal with it on their own. Both C and C provide the necessary hooks to make things work, but the functions or methods used by the hooks must be provided by each inside-out class. A general solution to the serialization problem would require another level of registry, one that that associates I and fields. So far, the functions of C are unaware of any classes, which I consider a feature. Therefore C doesn't address the serialization problems. =head2 The Generic Object Classes based on the C function (and hence classes based on C and C) show a peculiar behavior in that the class name can be used like an object. Specifically, methods that set or read data associated with an object continue to work as class methods, just as if the class name were an object, distinct from all other objects, with its own data. This object may be called the I of the class. This works because field hashes respond to keys that are not references like a normal hash would and use the string offered as the hash key. Thus, if a method is called as a class method, the field hash is presented with the class name instead of an object and blithely uses it as a key. Since the keys of real objects are decimal numbers, there is no conflict and the slot in the field hash can be used like any other. The C function behaves correspondingly with respect to non-reference arguments. Two possible uses (besides ignoring the property) come to mind. A singleton class could be implemented this using the generic object. If necessary, an C method could die or ignore calls with actual objects (references), so only the generic object will ever exist. Another use of the generic object would be as a template. It is a convenient place to store class-specific defaults for various fields to be used in actual object initialization. Usually, the feature can be entirely ignored. Calling I as I normally leads to an error and isn't used routinely anywhere. It may be a problem that this error isn't indicated by a class with a generic object. =head2 How to use Field Hashes Traditionally, the definition of an inside-out class contains a bare block inside which a number of lexical hashes are declared and the basic accessor methods defined, usually through C. Further methods may be defined outside this block. There has to be a DESTROY method and, for thread support, a CLONE method. When field hashes are used, the basic structure remains the same. Each lexical hash will be made a field hash. The call to C can be omitted from the accessor methods. DESTROY and CLONE methods are not necessary. If you have an existing inside-out class, simply making all hashes field hashes with no other change should make no difference. Through the calls to C or equivalent, the field hashes never get to see a reference and work like normal hashes. Your DESTROY (and CLONE) methods are still needed. To make the field hashes kick in, it is easiest to redefine C as sub refaddr { shift } instead of importing it from C. It should now be possible to disable DESTROY and CLONE. Note that while it isn't disabled, DESTROY will be called before the garbage collection of field hashes, so it will be invoked with a functional object and will continue to function. It is not desirable to import the functions C and/or C into every class that is going to use them. They are only used once to set up the class. When the class is up and running, these functions serve no more purpose. If there are only a few field hashes to declare, it is simplest to use Hash::Util::FieldHash; early and call the functions qualified: Hash::Util::FieldHash::fieldhash my %foo; Otherwise, import the functions into a convenient package like C or, more general, C { package Aux; use Hash::Util::FieldHash ':all'; } and call Aux::fieldhash my %foo; as needed. =head2 Garbage-Collected Hashes Garbage collection in a field hash means that entries will "spontaneously" disappear when the object that created them disappears. That must be borne in mind, especially when looping over a field hash. If anything you do inside the loop could cause an object to go out of scope, a random key may be deleted from the hash you are looping over. That can throw the loop iterator, so it's best to cache a consistent snapshot of the keys and/or values and loop over that. You will still have to check that a cached entry still exists when you get to it. Garbage collection can be confusing when keys are created in a field hash from normal scalars as well as references. Once a reference is I with a field hash, the entry will be collected, even if it was later overwritten with a plain scalar key (every positive integer is a candidate). This is true even if the original entry was deleted in the meantime. In fact, deletion from a field hash, and also a test for existence constitute I in this sense and create a liability to delete the entry when the reference goes out of scope. If you happen to create an entry with an identical key from a string or integer, that will be collected instead. Thus, mixed use of references and plain scalars as field hash keys is not entirely supported. =head1 EXAMPLES The examples show a very simple class that implements a I, consisting of a first and last name (no middle initial). The name class has four methods: =over =item * C An object method that initializes the first and last name to its two arguments. If called as a class method, C creates an object in the given class and initializes that. =item * C Retrieve the first name =item * C Retrieve the last name =item * C Retrieve the full name, the first and last name joined by a blank. =back The examples show this class implemented with different levels of support by C. All supported combinations are shown. The difference between implementations is often quite small. The implementations are: =over =item * C A conventional (not inside-out) implementation where an object is a hash that stores the field values, without support by C. This implementation doesn't allow arbitrary inheritance. =item * C Inside-out implementation based on the C function. It needs a C method. For thread support a C method (not shown) would also be needed. Instead of C the function C could be used with very little functional difference. This is the basic pattern of an inside-out class. =item * C Idhash-based inside-out implementation. Like L it needs a C method and would need C for thread support. =item * C Inside-out implementation based on the C function with explicit object registry. No destructor is needed and objects are thread safe. =item * C Idhash-based inside-out implementation with explicit object registry. No destructor is needed and objects are thread safe. =item * C FieldHash-based inside-out implementation. Object registry happens automatically. No destructor is needed and objects are thread safe. =back These examples are realized in the code below, which could be copied to a file F. =head2 Example 1 use strict; use warnings; { package Name_hash; # standard implementation: the object is a hash sub init { my $obj = shift; my ($first, $last) = @_; # create an object if called as class method $obj = bless {}, $obj unless ref $obj; $obj->{ first} = $first; $obj->{ last} = $last; $obj; } sub first { shift()->{ first} } sub last { shift()->{ last} } sub name { my $n = shift; join ' ' => $n->first, $n->last; } } { package Name_id; use Hash::Util::FieldHash qw(id); my (%first, %last); sub init { my $obj = shift; my ($first, $last) = @_; # create an object if called as class method $obj = bless \ my $o, $obj unless ref $obj; $first{ id $obj} = $first; $last{ id $obj} = $last; $obj; } sub first { $first{ id shift()} } sub last { $last{ id shift()} } sub name { my $n = shift; join ' ' => $n->first, $n->last; } sub DESTROY { my $id = id shift; delete $first{ $id}; delete $last{ $id}; } } { package Name_idhash; use Hash::Util::FieldHash; Hash::Util::FieldHash::idhashes( \ my (%first, %last) ); sub init { my $obj = shift; my ($first, $last) = @_; # create an object if called as class method $obj = bless \ my $o, $obj unless ref $obj; $first{ $obj} = $first; $last{ $obj} = $last; $obj; } sub first { $first{ shift()} } sub last { $last{ shift()} } sub name { my $n = shift; join ' ' => $n->first, $n->last; } sub DESTROY { my $n = shift; delete $first{ $n}; delete $last{ $n}; } } { package Name_id_reg; use Hash::Util::FieldHash qw(id register); my (%first, %last); sub init { my $obj = shift; my ($first, $last) = @_; # create an object if called as class method $obj = bless \ my $o, $obj unless ref $obj; register( $obj, \ (%first, %last) ); $first{ id $obj} = $first; $last{ id $obj} = $last; $obj; } sub first { $first{ id shift()} } sub last { $last{ id shift()} } sub name { my $n = shift; join ' ' => $n->first, $n->last; } } { package Name_idhash_reg; use Hash::Util::FieldHash qw(register); Hash::Util::FieldHash::idhashes \ my (%first, %last); sub init { my $obj = shift; my ($first, $last) = @_; # create an object if called as class method $obj = bless \ my $o, $obj unless ref $obj; register( $obj, \ (%first, %last) ); $first{ $obj} = $first; $last{ $obj} = $last; $obj; } sub first { $first{ shift()} } sub last { $last{ shift()} } sub name { my $n = shift; join ' ' => $n->first, $n->last; } } { package Name_fieldhash; use Hash::Util::FieldHash; Hash::Util::FieldHash::fieldhashes \ my (%first, %last); sub init { my $obj = shift; my ($first, $last) = @_; # create an object if called as class method $obj = bless \ my $o, $obj unless ref $obj; $first{ $obj} = $first; $last{ $obj} = $last; $obj; } sub first { $first{ shift()} } sub last { $last{ shift()} } sub name { my $n = shift; join ' ' => $n->first, $n->last; } } 1; To exercise the various implementations the script L can be used. It sets up a class C that is a mirror of one of the implementation classes C, C, ..., C. That determines which implementation is run. The script first verifies the function of the C class. In the second step, the free inheritability of the implementation (or lack thereof) is demonstrated. For this purpose it constructs a class called C which is a common subclass of C and the standard class C. This puts inheritability to the test because objects of C I be globrefs. Objects of C should behave like a file opened for reading and also support the C method. This class juncture works with exception of the C implementation, where object initialization fails because of the incompatibility of object bodies. =head2 Example 2 use strict; use warnings; $| = 1; use Example; { package Name; use base 'Name_id'; # define here which implementation to run } # Verify that the base package works my $n = Name->init(qw(Albert Einstein)); print $n->name, "\n"; print "\n"; # Create a named file handle (See definition below) my $nf = NamedFile->init(qw(/tmp/x Filomena File)); # use as a file handle... for ( 1 .. 3 ) { my $l = <$nf>; print "line $_: $l"; } # ...and as a Name object print "...brought to you by ", $nf->name, "\n"; exit; # Definition of NamedFile package NamedFile; use base 'Name'; use base 'IO::File'; sub init { my $obj = shift; my ($file, $first, $last) = @_; $obj = $obj->IO::File::new() unless ref $obj; $obj->open($file) or die "Can't read '$file': $!"; $obj->Name::init($first, $last); } __END__ =head1 GUTS To make C work, there were two changes to F itself. C was made avalaible for hashes, and weak references now call uvar C magic after a weakref has been cleared. The first feature is used to make field hashes intercept their keys upon access. The second one triggers garbage collection. =head2 The C interface for hashes C I magic is called from C and C through the function C, which defines the interface. The call happens for hashes with "uvar" magic if the C structure has equal values in the C and C fields. Hashes are unaffected if (and as long as) these fields hold different values. Upon the call, the C field will hold the hash key to be accessed. Upon return, the C value in C will be used in place of the original key in the hash access. The integer index value in the first parameter will be the C value from C, or -1 if the call is from C. This is a template for a function suitable for the C field in a C structure for this call. The C and C fields are irrelevant. IV watch_key(pTHX_ IV action, SV* field) { MAGIC* mg = mg_find(field, PERL_MAGIC_uvar); SV* keysv = mg->mg_obj; /* Do whatever you need to. If you decide to supply a different key newkey, return it like this */ sv_2mortal(newkey); mg->mg_obj = newkey; return 0; } =head2 Weakrefs call uvar magic When a weak reference is stored in an C that has "uvar" magic, C magic is called after the reference has gone stale. This hook can be used to trigger further garbage-collection activities associated with the referenced object. =head2 How field hashes work The three features of key hashes, I, I, and I are supported by a data structure called the I. This is a private hash where every object is stored. An "object" in this sense is any reference (blessed or unblessed) that has been used as a field hash key. The object registry keeps track of references that have been used as field hash keys. The keys are generated from the reference address like in a field hash (though the registry isn't a field hash). Each value is a weak copy of the original reference, stored in an C that is itself magical (C again). The magical structure holds a list (another hash, really) of field hashes that the reference has been used with. When the weakref becomes stale, the magic is activated and uses the list to delete the reference from all field hashes it has been used with. After that, the entry is removed from the object registry itself. Implicitly, that frees the magic structure and the storage it has been using. Whenever a reference is used as a field hash key, the object registry is checked and a new entry is made if necessary. The field hash is then added to the list of fields this reference has used. The object registry is also used to repair a field hash after thread cloning. Here, the entire object registry is processed. For every reference found there, the field hashes it has used are visited and the entry is updated. =head2 Internal function Hash::Util::FieldHash::_fieldhash # test if %hash is a field hash my $result = _fieldhash \ %hash, 0; # make %hash a field hash my $result = _fieldhash \ %hash, 1; C<_fieldhash> is the internal function used to create field hashes. It takes two arguments, a hashref and a mode. If the mode is boolean false, the hash is not changed but tested if it is a field hash. If the hash isn't a field hash the return value is boolean false. If it is, the return value indicates the mode of field hash. When called with a boolean true mode, it turns the given hash into a field hash of this mode, returning the mode of the created field hash. C<_fieldhash> does not erase the given hash. Currently there is only one type of field hash, and only the boolean value of the mode makes a difference, but that may change. =head1 AUTHOR Anno Siegel (ANNO) wrote the xs code and the changes in perl proper Jerry Hedden (JDHEDDEN) made it faster =head1 COPYRIGHT AND LICENSE Copyright (C) 2006-2007 by (Anno Siegel) This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.7 or, at your option, any later version of Perl 5 you may have available. =cut PK[[5 5.10.1/ops.pmnuW+Apackage ops; our $VERSION = '1.02'; use Opcode qw(opmask_add opset invert_opset); sub import { shift; # Not that unimport is the preferred form since import's don't # accumulate well owing to the 'only ever add opmask' rule. # E.g., perl -Mops=:set1 -Mops=:setb is unlikely to do as expected. opmask_add(invert_opset opset(@_)) if @_; } sub unimport { shift; opmask_add(opset(@_)) if @_; } 1; __END__ =head1 NAME ops - Perl pragma to restrict unsafe operations when compiling =head1 SYNOPSIS perl -Mops=:default ... # only allow reasonably safe operations perl -M-ops=system ... # disable the 'system' opcode =head1 DESCRIPTION Since the C pragma currently has an irreversible global effect, it is only of significant practical use with the C<-M> option on the command line. See the L module for information about opcodes, optags, opmasks and important information about safety. =head1 SEE ALSO L, L, L =cut PK[[3]BFBF5.10.1/Digest/SHA.pmnuW+Apackage Digest::SHA; require 5.003000; use strict; use integer; use vars qw($VERSION @ISA @EXPORT @EXPORT_OK); $VERSION = '5.47'; require Exporter; require DynaLoader; @ISA = qw(Exporter DynaLoader); @EXPORT_OK = qw( hmac_sha1 hmac_sha1_base64 hmac_sha1_hex hmac_sha224 hmac_sha224_base64 hmac_sha224_hex hmac_sha256 hmac_sha256_base64 hmac_sha256_hex hmac_sha384 hmac_sha384_base64 hmac_sha384_hex hmac_sha512 hmac_sha512_base64 hmac_sha512_hex sha1 sha1_base64 sha1_hex sha224 sha224_base64 sha224_hex sha256 sha256_base64 sha256_hex sha384 sha384_base64 sha384_hex sha512 sha512_base64 sha512_hex); # If possible, inherit from Digest::base (which depends on MIME::Base64) *addfile = \&Addfile; eval { require MIME::Base64; require Digest::base; push(@ISA, 'Digest::base'); }; if ($@) { *hexdigest = \&Hexdigest; *b64digest = \&B64digest; } # The following routines aren't time-critical, so they can be left in Perl sub new { my($class, $alg) = @_; $alg =~ s/\D+//g if defined $alg; if (ref($class)) { # instance method unless (defined($alg) && ($alg != $class->algorithm)) { sharewind($$class); return($class); } shaclose($$class) if $$class; $$class = shaopen($alg) || return; return($class); } $alg = 1 unless defined $alg; my $state = shaopen($alg) || return; my $self = \$state; bless($self, $class); return($self); } sub DESTROY { my $self = shift; shaclose($$self) if $$self; } sub clone { my $self = shift; my $state = shadup($$self) || return; my $copy = \$state; bless($copy, ref($self)); return($copy); } *reset = \&new; sub add_bits { my($self, $data, $nbits) = @_; unless (defined $nbits) { $nbits = length($data); $data = pack("B*", $data); } shawrite($data, $nbits, $$self); return($self); } sub _bail { my $msg = shift; require Carp; Carp::croak("$msg: $!"); } sub _addfile { # this is "addfile" from Digest::base 1.00 my ($self, $handle) = @_; my $n; my $buf = ""; while (($n = read($handle, $buf, 4096))) { $self->add($buf); } _bail("Read failed") unless defined $n; $self; } sub Addfile { my ($self, $file, $mode) = @_; return(_addfile($self, $file)) unless ref(\$file) eq 'SCALAR'; $mode = defined($mode) ? $mode : ""; my ($binary, $portable) = map { $_ eq $mode } ("b", "p"); my $text = -T $file; local *FH; # protect any leading or trailing whitespace in $file; # otherwise, 2-arg "open" will ignore them $file =~ s#^(\s)#./$1#; open(FH, "< $file\0") or _bail("Open failed"); binmode(FH) if $binary || $portable; unless ($portable && $text) { $self->_addfile(*FH); close(FH); return($self); } my ($n1, $n2); my ($buf1, $buf2) = ("", ""); while (($n1 = read(FH, $buf1, 4096))) { while (substr($buf1, -1) eq "\015") { $n2 = read(FH, $buf2, 4096); _bail("Read failed") unless defined $n2; last unless $n2; $buf1 .= $buf2; } $buf1 =~ s/\015?\015\012/\012/g; # DOS/Windows $buf1 =~ s/\015/\012/g; # early MacOS $self->add($buf1); } _bail("Read failed") unless defined $n1; close(FH); $self; } sub dump { my $self = shift; my $file = shift || ""; shadump($file, $$self) || return; return($self); } sub load { my $class = shift; my $file = shift || ""; if (ref($class)) { # instance method shaclose($$class) if $$class; $$class = shaload($file) || return; return($class); } my $state = shaload($file) || return; my $self = \$state; bless($self, $class); return($self); } Digest::SHA->bootstrap($VERSION); 1; __END__ =head1 NAME Digest::SHA - Perl extension for SHA-1/224/256/384/512 =head1 SYNOPSIS In programs: # Functional interface use Digest::SHA qw(sha1 sha1_hex sha1_base64 ...); $digest = sha1($data); $digest = sha1_hex($data); $digest = sha1_base64($data); $digest = sha256($data); $digest = sha384_hex($data); $digest = sha512_base64($data); # Object-oriented use Digest::SHA; $sha = Digest::SHA->new($alg); $sha->add($data); # feed data into stream $sha->addfile(*F); $sha->addfile($filename); $sha->add_bits($bits); $sha->add_bits($data, $nbits); $sha_copy = $sha->clone; # if needed, make copy of $sha->dump($file); # current digest state, $sha->load($file); # or save it on disk $digest = $sha->digest; # compute digest $digest = $sha->hexdigest; $digest = $sha->b64digest; From the command line: $ shasum files $ shasum --help =head1 SYNOPSIS (HMAC-SHA) # Functional interface only use Digest::SHA qw(hmac_sha1 hmac_sha1_hex ...); $digest = hmac_sha1($data, $key); $digest = hmac_sha224_hex($data, $key); $digest = hmac_sha256_base64($data, $key); =head1 ABSTRACT Digest::SHA is a complete implementation of the NIST Secure Hash Standard. It gives Perl programmers a convenient way to calculate SHA-1, SHA-224, SHA-256, SHA-384, and SHA-512 message digests. The module can handle all types of input, including partial-byte data. =head1 DESCRIPTION Digest::SHA is written in C for speed. If your platform lacks a C compiler, you can install the functionally equivalent (but much slower) L module. The programming interface is easy to use: it's the same one found in CPAN's L module. So, if your applications currently use L and you'd prefer the stronger security of SHA, it's a simple matter to convert them. The interface provides two ways to calculate digests: all-at-once, or in stages. To illustrate, the following short program computes the SHA-256 digest of "hello world" using each approach: use Digest::SHA qw(sha256_hex); $data = "hello world"; @frags = split(//, $data); # all-at-once (Functional style) $digest1 = sha256_hex($data); # in-stages (OOP style) $state = Digest::SHA->new(256); for (@frags) { $state->add($_) } $digest2 = $state->hexdigest; print $digest1 eq $digest2 ? "whew!\n" : "oops!\n"; To calculate the digest of an n-bit message where I is not a multiple of 8, use the I method. For example, consider the 446-bit message consisting of the bit-string "110" repeated 148 times, followed by "11". Here's how to display its SHA-1 digest: use Digest::SHA; $bits = "110" x 148 . "11"; $sha = Digest::SHA->new(1)->add_bits($bits); print $sha->hexdigest, "\n"; Note that for larger bit-strings, it's more efficient to use the two-argument version I, where I<$data> is in the customary packed binary format used for Perl strings. The module also lets you save intermediate SHA states to disk, or display them on standard output. The I method generates portable, human-readable text describing the current state of computation. You can subsequently retrieve the file with I to resume where the calculation left off. To see what a state description looks like, just run the following: use Digest::SHA; Digest::SHA->new->add("Shaw" x 1962)->dump; As an added convenience, the Digest::SHA module offers routines to calculate keyed hashes using the HMAC-SHA-1/224/256/384/512 algorithms. These services exist in functional form only, and mimic the style and behavior of the I, I, and I functions. # Test vector from draft-ietf-ipsec-ciph-sha-256-01.txt use Digest::SHA qw(hmac_sha256_hex); print hmac_sha256_hex("Hi There", chr(0x0b) x 32), "\n"; =head1 NIST STATEMENT ON SHA-1 I I ref. L =head1 PADDING OF BASE64 DIGESTS By convention, CPAN Digest modules do B pad their Base64 output. Problems can occur when feeding such digests to other software that expects properly padded Base64 encodings. For the time being, any necessary padding must be done by the user. Fortunately, this is a simple operation: if the length of a Base64-encoded digest isn't a multiple of 4, simply append "=" characters to the end of the digest until it is: while (length($b64_digest) % 4) { $b64_digest .= '='; } To illustrate, I is computed to be ungWv48Bz+pBQUDeXa4iI7ADYaOWF3qctBD/YfIAFa0 which has a length of 43. So, the properly padded version is ungWv48Bz+pBQUDeXa4iI7ADYaOWF3qctBD/YfIAFa0= =head1 EXPORT None by default. =head1 EXPORTABLE FUNCTIONS Provided your C compiler supports a 64-bit type (e.g. the I of C99, or I<__int64> used by Microsoft C/C++), all of these functions will be available for use. Otherwise, you won't be able to perform the SHA-384 and SHA-512 transforms, both of which require 64-bit operations. I =over 4 =item B =item B =item B =item B =item B Logically joins the arguments into a single string, and returns its SHA-1/224/256/384/512 digest encoded as a binary string. =item B =item B =item B =item B =item B Logically joins the arguments into a single string, and returns its SHA-1/224/256/384/512 digest encoded as a hexadecimal string. =item B =item B =item B =item B =item B Logically joins the arguments into a single string, and returns its SHA-1/224/256/384/512 digest encoded as a Base64 string. It's important to note that the resulting string does B contain the padding characters typical of Base64 encodings. This omission is deliberate, and is done to maintain compatibility with the family of CPAN Digest modules. See L for details. =back I =over 4 =item B Returns a new Digest::SHA object. Allowed values for I<$alg> are 1, 224, 256, 384, or 512. It's also possible to use common string representations of the algorithm (e.g. "sha256", "SHA-384"). If the argument is missing, SHA-1 will be used by default. Invoking I as an instance method will not create a new object; instead, it will simply reset the object to the initial state associated with I<$alg>. If the argument is missing, the object will continue using the same algorithm that was selected at creation. =item B This method has exactly the same effect as I. In fact, I is just an alias for I. =item B Returns the number of digest bits for this object. The values are 160, 224, 256, 384, and 512 for SHA-1, SHA-224, SHA-256, SHA-384, and SHA-512, respectively. =item B Returns the digest algorithm for this object. The values are 1, 224, 256, 384, and 512 for SHA-1, SHA-224, SHA-256, SHA-384, and SHA-512, respectively. =item B Returns a duplicate copy of the object. =item B Logically joins the arguments into a single string, and uses it to update the current digest state. In other words, the following statements have the same effect: $sha->add("a"); $sha->add("b"); $sha->add("c"); $sha->add("a")->add("b")->add("c"); $sha->add("a", "b", "c"); $sha->add("abc"); The return value is the updated object itself. =item B =item B Updates the current digest state by appending bits to it. The return value is the updated object itself. The first form causes the most-significant I<$nbits> of I<$data> to be appended to the stream. The I<$data> argument is in the customary binary format used for Perl strings. The second form takes an ASCII string of "0" and "1" characters as its argument. It's equivalent to $sha->add_bits(pack("B*", $bits), length($bits)); So, the following two statements do the same thing: $sha->add_bits("111100001010"); $sha->add_bits("\xF0\xA0", 12); =item B Reads from I until EOF, and appends that data to the current state. The return value is the updated object itself. =item B Reads the contents of I<$filename>, and appends that data to the current state. The return value is the updated object itself. By default, I<$filename> is simply opened and read; no special modes or I/O disciplines are used. To change this, set the optional I<$mode> argument to one of the following values: "b" read file in binary mode "p" use portable mode The "p" mode is handy since it ensures that the digest value of I<$filename> will be the same when computed on different operating systems. It accomplishes this by internally translating all newlines in text files to UNIX format before calculating the digest. Binary files are read in raw mode with no translation whatsoever. For a fuller discussion of newline formats, refer to CPAN module L. Its "universal line separator" regex forms the basis of I's portable mode processing. =item B Provides persistent storage of intermediate SHA states by writing a portable, human-readable representation of the current state to I<$filename>. If the argument is missing, or equal to the empty string, the state information will be written to STDOUT. =item B Returns a Digest::SHA object representing the intermediate SHA state that was previously dumped to I<$filename>. If called as a class method, a new object is created; if called as an instance method, the object is reset to the state contained in I<$filename>. If the argument is missing, or equal to the empty string, the state information will be read from STDIN. =item B Returns the digest encoded as a binary string. Note that the I method is a read-once operation. Once it has been performed, the Digest::SHA object is automatically reset in preparation for calculating another digest value. Call I<$sha-Eclone-Edigest> if it's necessary to preserve the original digest state. =item B Returns the digest encoded as a hexadecimal string. Like I, this method is a read-once operation. Call I<$sha-Eclone-Ehexdigest> if it's necessary to preserve the original digest state. This method is inherited if L is installed on your system. Otherwise, a functionally equivalent substitute is used. =item B Returns the digest encoded as a Base64 string. Like I, this method is a read-once operation. Call I<$sha-Eclone-Eb64digest> if it's necessary to preserve the original digest state. This method is inherited if L is installed on your system. Otherwise, a functionally equivalent substitute is used. It's important to note that the resulting string does B contain the padding characters typical of Base64 encodings. This omission is deliberate, and is done to maintain compatibility with the family of CPAN Digest modules. See L for details. =back I =over 4 =item B =item B =item B =item B =item B Returns the HMAC-SHA-1/224/256/384/512 digest of I<$data>/I<$key>, with the result encoded as a binary string. Multiple I<$data> arguments are allowed, provided that I<$key> is the last argument in the list. =item B =item B =item B =item B =item B Returns the HMAC-SHA-1/224/256/384/512 digest of I<$data>/I<$key>, with the result encoded as a hexadecimal string. Multiple I<$data> arguments are allowed, provided that I<$key> is the last argument in the list. =item B =item B =item B =item B =item B Returns the HMAC-SHA-1/224/256/384/512 digest of I<$data>/I<$key>, with the result encoded as a Base64 string. Multiple I<$data> arguments are allowed, provided that I<$key> is the last argument in the list. It's important to note that the resulting string does B contain the padding characters typical of Base64 encodings. This omission is deliberate, and is done to maintain compatibility with the family of CPAN Digest modules. See L for details. =back =head1 SEE ALSO L, L The Secure Hash Standard (FIPS PUB 180-2) can be found at: L The Keyed-Hash Message Authentication Code (HMAC): L =head1 AUTHOR Mark Shelor =head1 ACKNOWLEDGMENTS The author is particularly grateful to Gisle Aas Chris Carey Alexandr Ciornii Jim Doble Julius Duque Jeffrey Friedl Robert Gilmour Brian Gladman Adam Kennedy Andy Lester Alex Muntada Steve Peters Chris Skiscim Martin Thurn Gunnar Wolf Adam Woodbury for their valuable comments and suggestions. =head1 COPYRIGHT AND LICENSE Copyright (C) 2003-2008 Mark Shelor This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. L =cut PK[[sl>)>)5.10.1/Digest/MD5.pmnuW+Apackage Digest::MD5; use strict; use vars qw($VERSION @ISA @EXPORT_OK); $VERSION = '2.39'; require Exporter; *import = \&Exporter::import; @EXPORT_OK = qw(md5 md5_hex md5_base64); eval { require Digest::base; push(@ISA, 'Digest::base'); }; if ($@) { my $err = $@; *add_bits = sub { die $err }; } eval { require XSLoader; XSLoader::load('Digest::MD5', $VERSION); }; if ($@) { my $olderr = $@; eval { # Try to load the pure perl version require Digest::Perl::MD5; Digest::Perl::MD5->import(qw(md5 md5_hex md5_base64)); push(@ISA, "Digest::Perl::MD5"); # make OO interface work }; if ($@) { # restore the original error die $olderr; } } else { *reset = \&new; } 1; __END__ =head1 NAME Digest::MD5 - Perl interface to the MD5 Algorithm =head1 SYNOPSIS # Functional style use Digest::MD5 qw(md5 md5_hex md5_base64); $digest = md5($data); $digest = md5_hex($data); $digest = md5_base64($data); # OO style use Digest::MD5; $ctx = Digest::MD5->new; $ctx->add($data); $ctx->addfile(*FILE); $digest = $ctx->digest; $digest = $ctx->hexdigest; $digest = $ctx->b64digest; =head1 DESCRIPTION The C module allows you to use the RSA Data Security Inc. MD5 Message Digest algorithm from within Perl programs. The algorithm takes as input a message of arbitrary length and produces as output a 128-bit "fingerprint" or "message digest" of the input. Note that the MD5 algorithm is not as strong as it used to be. It has since 2005 been easy to generate different messages that produce the same MD5 digest. It still seems hard to generate messages that produce a given digest, but it is probably wise to move to stronger algorithms for applications that depend on the digest to uniquely identify a message. The C module provide a procedural interface for simple use, as well as an object oriented interface that can handle messages of arbitrary length and which can read files directly. =head1 FUNCTIONS The following functions are provided by the C module. None of these functions are exported by default. =over 4 =item md5($data,...) This function will concatenate all arguments, calculate the MD5 digest of this "message", and return it in binary form. The returned string will be 16 bytes long. The result of md5("a", "b", "c") will be exactly the same as the result of md5("abc"). =item md5_hex($data,...) Same as md5(), but will return the digest in hexadecimal form. The length of the returned string will be 32 and it will only contain characters from this set: '0'..'9' and 'a'..'f'. =item md5_base64($data,...) Same as md5(), but will return the digest as a base64 encoded string. The length of the returned string will be 22 and it will only contain characters from this set: 'A'..'Z', 'a'..'z', '0'..'9', '+' and '/'. Note that the base64 encoded string returned is not padded to be a multiple of 4 bytes long. If you want interoperability with other base64 encoded md5 digests you might want to append the redundant string "==" to the result. =back =head1 METHODS The object oriented interface to C is described in this section. After a C object has been created, you will add data to it and finally ask for the digest in a suitable format. A single object can be used to calculate multiple digests. The following methods are provided: =over 4 =item $md5 = Digest::MD5->new The constructor returns a new C object which encapsulate the state of the MD5 message-digest algorithm. If called as an instance method (i.e. $md5->new) it will just reset the state the object to the state of a newly created object. No new object is created in this case. =item $md5->reset This is just an alias for $md5->new. =item $md5->clone This a copy of the $md5 object. It is useful when you do not want to destroy the digests state, but need an intermediate value of the digest, e.g. when calculating digests iteratively on a continuous data stream. Example: my $md5 = Digest::MD5->new; while (<>) { $md5->add($_); print "Line $.: ", $md5->clone->hexdigest, "\n"; } =item $md5->add($data,...) The $data provided as argument are appended to the message we calculate the digest for. The return value is the $md5 object itself. All these lines will have the same effect on the state of the $md5 object: $md5->add("a"); $md5->add("b"); $md5->add("c"); $md5->add("a")->add("b")->add("c"); $md5->add("a", "b", "c"); $md5->add("abc"); =item $md5->addfile($io_handle) The $io_handle will be read until EOF and its content appended to the message we calculate the digest for. The return value is the $md5 object itself. The addfile() method will croak() if it fails reading data for some reason. If it croaks it is unpredictable what the state of the $md5 object will be in. The addfile() method might have been able to read the file partially before it failed. It is probably wise to discard or reset the $md5 object if this occurs. In most cases you want to make sure that the $io_handle is in C before you pass it as argument to the addfile() method. =item $md5->add_bits($data, $nbits) =item $md5->add_bits($bitstring) Since the MD5 algorithm is byte oriented you might only add bits as multiples of 8, so you probably want to just use add() instead. The add_bits() method is provided for compatibility with other digest implementations. See L for description of the arguments that add_bits() take. =item $md5->digest Return the binary digest for the message. The returned string will be 16 bytes long. Note that the C operation is effectively a destructive, read-once operation. Once it has been performed, the C object is automatically C and can be used to calculate another digest value. Call $md5->clone->digest if you want to calculate the digest without resetting the digest state. =item $md5->hexdigest Same as $md5->digest, but will return the digest in hexadecimal form. The length of the returned string will be 32 and it will only contain characters from this set: '0'..'9' and 'a'..'f'. =item $md5->b64digest Same as $md5->digest, but will return the digest as a base64 encoded string. The length of the returned string will be 22 and it will only contain characters from this set: 'A'..'Z', 'a'..'z', '0'..'9', '+' and '/'. The base64 encoded string returned is not padded to be a multiple of 4 bytes long. If you want interoperability with other base64 encoded md5 digests you might want to append the string "==" to the result. =back =head1 EXAMPLES The simplest way to use this library is to import the md5_hex() function (or one of its cousins): use Digest::MD5 qw(md5_hex); print "Digest is ", md5_hex("foobarbaz"), "\n"; The above example would print out the message: Digest is 6df23dc03f9b54cc38a0fc1483df6e21 The same checksum can also be calculated in OO style: use Digest::MD5; $md5 = Digest::MD5->new; $md5->add('foo', 'bar'); $md5->add('baz'); $digest = $md5->hexdigest; print "Digest is $digest\n"; With OO style you can break the message arbitrary. This means that we are no longer limited to have space for the whole message in memory, i.e. we can handle messages of any size. This is useful when calculating checksum for files: use Digest::MD5; my $file = shift || "/etc/passwd"; open(FILE, $file) or die "Can't open '$file': $!"; binmode(FILE); $md5 = Digest::MD5->new; while () { $md5->add($_); } close(FILE); print $md5->b64digest, " $file\n"; Or we can use the addfile method for more efficient reading of the file: use Digest::MD5; my $file = shift || "/etc/passwd"; open(FILE, $file) or die "Can't open '$file': $!"; binmode(FILE); print Digest::MD5->new->addfile(*FILE)->hexdigest, " $file\n"; Perl 5.8 support Unicode characters in strings. Since the MD5 algorithm is only defined for strings of bytes, it can not be used on strings that contains chars with ordinal number above 255. The MD5 functions and methods will croak if you try to feed them such input data: use Digest::MD5 qw(md5_hex); my $str = "abc\x{300}"; print md5_hex($str), "\n"; # croaks # Wide character in subroutine entry What you can do is calculate the MD5 checksum of the UTF-8 representation of such strings. This is achieved by filtering the string through encode_utf8() function: use Digest::MD5 qw(md5_hex); use Encode qw(encode_utf8); my $str = "abc\x{300}"; print md5_hex(encode_utf8($str)), "\n"; # 8c2d46911f3f5a326455f0ed7a8ed3b3 =head1 SEE ALSO L, L, L, L L RFC 1321 http://en.wikipedia.org/wiki/MD5 The paper "How to Break MD5 and Other Hash Functions" by Xiaoyun Wang and Hongbo Yu. =head1 COPYRIGHT This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Copyright 1998-2003 Gisle Aas. Copyright 1995-1996 Neil Winton. Copyright 1991-1992 RSA Data Security, Inc. The MD5 algorithm is defined in RFC 1321. This implementation is derived from the reference C code in RFC 1321 which is covered by the following copyright statement: =over 4 =item Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All rights reserved. License to copy and use this software is granted provided that it is identified as the "RSA Data Security, Inc. MD5 Message-Digest Algorithm" in all material mentioning or referencing this software or this function. License is also granted to make and use derivative works provided that such works are identified as "derived from the RSA Data Security, Inc. MD5 Message-Digest Algorithm" in all material mentioning or referencing the derived work. RSA Data Security, Inc. makes no representations concerning either the merchantability of this software or the suitability of this software for any particular purpose. It is provided "as is" without express or implied warranty of any kind. These notices must be retained in any copies of any part of this documentation and/or software. =back This copyright does not prohibit distribution of any version of Perl containing this extension under the terms of the GNU or Artistic licenses. =head1 AUTHORS The original C interface was written by Neil Winton (C). The C module is written by Gisle Aas . =cut PK[[}5.10.1/Encode/KR.pmnuW+Apackage Encode::KR; BEGIN { if ( ord("A") == 193 ) { die "Encode::KR not supported on EBCDIC\n"; } } use strict; use warnings; use Encode; our $VERSION = do { my @r = ( q$Revision: 2.2 $ =~ /\d+/g ); sprintf "%d." . "%02d" x $#r, @r }; use XSLoader; XSLoader::load( __PACKAGE__, $VERSION ); use Encode::KR::2022_KR; 1; __END__ =head1 NAME Encode::KR - Korean Encodings =head1 SYNOPSIS use Encode qw/encode decode/; $euc_kr = encode("euc-kr", $utf8); # loads Encode::KR implicitly $utf8 = decode("euc-kr", $euc_kr); # ditto =head1 DESCRIPTION This module implements Korean charset encodings. Encodings supported are as follows. Canonical Alias Description -------------------------------------------------------------------- euc-kr /\beuc.*kr$/i EUC (Extended Unix Character) /\bkr.*euc$/i ksc5601-raw Korean standard code set (as is) cp949 /(?:x-)?uhc$/i /(?:x-)?windows-949$/i /\bks_c_5601-1987$/i Code Page 949 (EUC-KR + 8,822 (additional Hangul syllables) MacKorean EUC-KR + Apple Vendor Mappings johab JOHAB A supplementary encoding defined in Annex 3 of KS X 1001:1998 iso-2022-kr iso-2022-kr [RFC1557] -------------------------------------------------------------------- To find how to use this module in detail, see L. =head1 BUGS When you see C on mails and web pages, they really mean "cp949" encodings. To fix that, the following aliases are set; qr/(?:x-)?uhc$/i => '"cp949"' qr/(?:x-)?windows-949$/i => '"cp949"' qr/ks_c_5601-1987$/i => '"cp949"' The ASCII region (0x00-0x7f) is preserved for all encodings, even though this conflicts with mappings by the Unicode Consortium. See L to find out why it is implemented that way. =head1 SEE ALSO L =cut PK[[PM 5.10.1/Encode/Byte.pmnuW+Apackage Encode::Byte; use strict; use warnings; use Encode; our $VERSION = do { my @r = ( q$Revision: 2.3 $ =~ /\d+/g ); sprintf "%d." . "%02d" x $#r, @r }; use XSLoader; XSLoader::load( __PACKAGE__, $VERSION ); 1; __END__ =head1 NAME Encode::Byte - Single Byte Encodings =head1 SYNOPSIS use Encode qw/encode decode/; $greek = encode("iso-8859-7", $utf8); # loads Encode::Byte implicitly $utf8 = decode("iso-8859-7", $greek); # ditto =head1 ABSTRACT This module implements various single byte encodings. For most cases it uses \x80-\xff (upper half) to map non-ASCII characters. Encodings supported are as follows. Canonical Alias Description -------------------------------------------------------------------- # ISO 8859 series (iso-8859-1 is in built-in) iso-8859-2 latin2 [ISO] iso-8859-3 latin3 [ISO] iso-8859-4 latin4 [ISO] iso-8859-5 [ISO] iso-8859-6 [ISO] iso-8859-7 [ISO] iso-8859-8 [ISO] iso-8859-9 latin5 [ISO] iso-8859-10 latin6 [ISO] iso-8859-11 (iso-8859-12 is nonexistent) iso-8859-13 latin7 [ISO] iso-8859-14 latin8 [ISO] iso-8859-15 latin9 [ISO] iso-8859-16 latin10 [ISO] # Cyrillic koi8-f koi8-r cp878 [RFC1489] koi8-u [RFC2319] # Vietnamese viscii # all cp* are also available as ibm-*, ms-*, and windows-* # also see L cp424 cp437 cp737 cp775 cp850 cp852 cp855 cp856 cp857 cp860 cp861 cp862 cp863 cp864 cp865 cp866 cp869 cp874 cp1006 cp1250 WinLatin2 cp1251 WinCyrillic cp1252 WinLatin1 cp1253 WinGreek cp1254 WinTurkish cp1255 WinHebrew cp1256 WinArabic cp1257 WinBaltic cp1258 WinVietnamese # Macintosh # Also see L MacArabic MacCentralEurRoman MacCroatian MacCyrillic MacFarsi MacGreek MacHebrew MacIcelandic MacRoman MacRomanian MacRumanian MacSami MacThai MacTurkish MacUkrainian # More vendor encodings AdobeStandardEncoding nextstep hp-roman8 =head1 DESCRIPTION To find how to use this module in detail, see L. =head1 SEE ALSO L =cut PK[[VE1'1'5.10.1/Encode/Guess.pmnuW+Apackage Encode::Guess; use strict; use warnings; use Encode qw(:fallbacks find_encoding); our $VERSION = do { my @r = ( q$Revision: 2.3 $ =~ /\d+/g ); sprintf "%d." . "%02d" x $#r, @r }; my $Canon = 'Guess'; sub DEBUG () { 0 } our %DEF_SUSPECTS = map { $_ => find_encoding($_) } qw(ascii utf8); $Encode::Encoding{$Canon} = bless { Name => $Canon, Suspects => {%DEF_SUSPECTS}, } => __PACKAGE__; use base qw(Encode::Encoding); sub needs_lines { 1 } sub perlio_ok { 0 } our @EXPORT = qw(guess_encoding); our $NoUTFAutoGuess = 0; our $UTF8_BOM = pack( "C3", 0xef, 0xbb, 0xbf ); sub import { # Exporter not used so we do it on our own my $callpkg = caller; for my $item (@EXPORT) { no strict 'refs'; *{"$callpkg\::$item"} = \&{"$item"}; } set_suspects(@_); } sub set_suspects { my $class = shift; my $self = ref($class) ? $class : $Encode::Encoding{$Canon}; $self->{Suspects} = {%DEF_SUSPECTS}; $self->add_suspects(@_); } sub add_suspects { my $class = shift; my $self = ref($class) ? $class : $Encode::Encoding{$Canon}; for my $c (@_) { my $e = find_encoding($c) or die "Unknown encoding: $c"; $self->{Suspects}{ $e->name } = $e; DEBUG and warn "Added: ", $e->name; } } sub decode($$;$) { my ( $obj, $octet, $chk ) = @_; my $guessed = guess( $obj, $octet ); unless ( ref($guessed) ) { require Carp; Carp::croak($guessed); } my $utf8 = $guessed->decode( $octet, $chk ); $_[1] = $octet if $chk; return $utf8; } sub guess_encoding { guess( $Encode::Encoding{$Canon}, @_ ); } sub guess { my $class = shift; my $obj = ref($class) ? $class : $Encode::Encoding{$Canon}; my $octet = shift; # sanity check return "Empty string, empty guess" unless defined $octet and length $octet; # cheat 0: utf8 flag; if ( Encode::is_utf8($octet) ) { return find_encoding('utf8') unless $NoUTFAutoGuess; Encode::_utf8_off($octet); } # cheat 1: BOM use Encode::Unicode; unless ($NoUTFAutoGuess) { my $BOM = pack( 'C3', unpack( "C3", $octet ) ); return find_encoding('utf8') if ( defined $BOM and $BOM eq $UTF8_BOM ); $BOM = unpack( 'N', $octet ); return find_encoding('UTF-32') if ( defined $BOM and ( $BOM == 0xFeFF or $BOM == 0xFFFe0000 ) ); $BOM = unpack( 'n', $octet ); return find_encoding('UTF-16') if ( defined $BOM and ( $BOM == 0xFeFF or $BOM == 0xFFFe ) ); if ( $octet =~ /\x00/o ) { # if \x00 found, we assume UTF-(16|32)(BE|LE) my $utf; my ( $be, $le ) = ( 0, 0 ); if ( $octet =~ /\x00\x00/o ) { # UTF-32(BE|LE) assumed $utf = "UTF-32"; for my $char ( unpack( 'N*', $octet ) ) { $char & 0x0000ffff and $be++; $char & 0xffff0000 and $le++; } } else { # UTF-16(BE|LE) assumed $utf = "UTF-16"; for my $char ( unpack( 'n*', $octet ) ) { $char & 0x00ff and $be++; $char & 0xff00 and $le++; } } DEBUG and warn "$utf, be == $be, le == $le"; $be == $le and return "Encodings ambiguous between $utf BE and LE ($be, $le)"; $utf .= ( $be > $le ) ? 'BE' : 'LE'; return find_encoding($utf); } } my %try = %{ $obj->{Suspects} }; for my $c (@_) { my $e = find_encoding($c) or die "Unknown encoding: $c"; $try{ $e->name } = $e; DEBUG and warn "Added: ", $e->name; } my $nline = 1; for my $line ( split /\r\n?|\n/, $octet ) { # cheat 2 -- \e in the string if ( $line =~ /\e/o ) { my @keys = keys %try; delete @try{qw/utf8 ascii/}; for my $k (@keys) { ref( $try{$k} ) eq 'Encode::XS' and delete $try{$k}; } } my %ok = %try; # warn join(",", keys %try); for my $k ( keys %try ) { my $scratch = $line; $try{$k}->decode( $scratch, FB_QUIET ); if ( $scratch eq '' ) { DEBUG and warn sprintf( "%4d:%-24s ok\n", $nline, $k ); } else { use bytes (); DEBUG and warn sprintf( "%4d:%-24s not ok; %d bytes left\n", $nline, $k, bytes::length($scratch) ); delete $ok{$k}; } } %ok or return "No appropriate encodings found!"; if ( scalar( keys(%ok) ) == 1 ) { my ($retval) = values(%ok); return $retval; } %try = %ok; $nline++; } $try{ascii} or return "Encodings too ambiguous: ", join( " or ", keys %try ); return $try{ascii}; } 1; __END__ =head1 NAME Encode::Guess -- Guesses encoding from data =head1 SYNOPSIS # if you are sure $data won't contain anything bogus use Encode; use Encode::Guess qw/euc-jp shiftjis 7bit-jis/; my $utf8 = decode("Guess", $data); my $data = encode("Guess", $utf8); # this doesn't work! # more elaborate way use Encode::Guess; my $enc = guess_encoding($data, qw/euc-jp shiftjis 7bit-jis/); ref($enc) or die "Can't guess: $enc"; # trap error this way $utf8 = $enc->decode($data); # or $utf8 = decode($enc->name, $data) =head1 ABSTRACT Encode::Guess enables you to guess in what encoding a given data is encoded, or at least tries to. =head1 DESCRIPTION By default, it checks only ascii, utf8 and UTF-16/32 with BOM. use Encode::Guess; # ascii/utf8/BOMed UTF To use it more practically, you have to give the names of encodings to check (I as follows). The name of suspects can either be canonical names or aliases. CAVEAT: Unlike UTF-(16|32), BOM in utf8 is NOT AUTOMATICALLY STRIPPED. # tries all major Japanese Encodings as well use Encode::Guess qw/euc-jp shiftjis 7bit-jis/; If the C<$Encode::Guess::NoUTFAutoGuess> variable is set to a true value, no heuristics will be applied to UTF8/16/32, and the result will be limited to the suspects and C. =over 4 =item Encode::Guess->set_suspects You can also change the internal suspects list via C method. use Encode::Guess; Encode::Guess->set_suspects(qw/euc-jp shiftjis 7bit-jis/); =item Encode::Guess->add_suspects Or you can use C method. The difference is that C flushes the current suspects list while C adds. use Encode::Guess; Encode::Guess->add_suspects(qw/euc-jp shiftjis 7bit-jis/); # now the suspects are euc-jp,shiftjis,7bit-jis, AND # euc-kr,euc-cn, and big5-eten Encode::Guess->add_suspects(qw/euc-kr euc-cn big5-eten/); =item Encode::decode("Guess" ...) When you are content with suspects list, you can now my $utf8 = Encode::decode("Guess", $data); =item Encode::Guess->guess($data) But it will croak if: =over =item * Two or more suspects remain =item * No suspects left =back So you should instead try this; my $decoder = Encode::Guess->guess($data); On success, $decoder is an object that is documented in L. So you can now do this; my $utf8 = $decoder->decode($data); On failure, $decoder now contains an error message so the whole thing would be as follows; my $decoder = Encode::Guess->guess($data); die $decoder unless ref($decoder); my $utf8 = $decoder->decode($data); =item guess_encoding($data, [, I]) You can also try C function which is exported by default. It takes $data to check and it also takes the list of suspects by option. The optional suspect list is I to the internal suspects list. my $decoder = guess_encoding($data, qw/euc-jp euc-kr euc-cn/); die $decoder unless ref($decoder); my $utf8 = $decoder->decode($data); # check only ascii and utf8 my $decoder = guess_encoding($data); =back =head1 CAVEATS =over 4 =item * Because of the algorithm used, ISO-8859 series and other single-byte encodings do not work well unless either one of ISO-8859 is the only one suspect (besides ascii and utf8). use Encode::Guess; # perhaps ok my $decoder = guess_encoding($data, 'latin1'); # definitely NOT ok my $decoder = guess_encoding($data, qw/latin1 greek/); The reason is that Encode::Guess guesses encoding by trial and error. It first splits $data into lines and tries to decode the line for each suspect. It keeps it going until all but one encoding is eliminated out of suspects list. ISO-8859 series is just too successful for most cases (because it fills almost all code points in \x00-\xff). =item * Do not mix national standard encodings and the corresponding vendor encodings. # a very bad idea my $decoder = guess_encoding($data, qw/shiftjis MacJapanese cp932/); The reason is that vendor encoding is usually a superset of national standard so it becomes too ambiguous for most cases. =item * On the other hand, mixing various national standard encodings automagically works unless $data is too short to allow for guessing. # This is ok if $data is long enough my $decoder = guess_encoding($data, qw/euc-cn euc-jp shiftjis 7bit-jis euc-kr big5-eten/); =item * DO NOT PUT TOO MANY SUSPECTS! Don't you try something like this! my $decoder = guess_encoding($data, Encode->encodings(":all")); =back It is, after all, just a guess. You should alway be explicit when it comes to encodings. But there are some, especially Japanese, environment that guess-coding is a must. Use this module with care. =head1 TO DO Encode::Guess does not work on EBCDIC platforms. =head1 SEE ALSO L, L =cut PK[[R>hh5.10.1/Encode/CN.pmnuW+Apackage Encode::CN; BEGIN { if ( ord("A") == 193 ) { die "Encode::CN not supported on EBCDIC\n"; } } use strict; use warnings; use Encode; our $VERSION = do { my @r = ( q$Revision: 2.2 $ =~ /\d+/g ); sprintf "%d." . "%02d" x $#r, @r }; use XSLoader; XSLoader::load( __PACKAGE__, $VERSION ); # Relocated from Encode.pm use Encode::CN::HZ; # use Encode::CN::2022_CN; 1; __END__ =head1 NAME Encode::CN - China-based Chinese Encodings =head1 SYNOPSIS use Encode qw/encode decode/; $euc_cn = encode("euc-cn", $utf8); # loads Encode::CN implicitly $utf8 = decode("euc-cn", $euc_cn); # ditto =head1 DESCRIPTION This module implements China-based Chinese charset encodings. Encodings supported are as follows. Canonical Alias Description -------------------------------------------------------------------- euc-cn /\beuc.*cn$/i EUC (Extended Unix Character) /\bcn.*euc$/i /\bGB[-_ ]?2312(?:\D.*$|$)/i (see below) gb2312-raw The raw (low-bit) GB2312 character map gb12345-raw Traditional chinese counterpart to GB2312 (raw) iso-ir-165 GB2312 + GB6345 + GB8565 + additions MacChineseSimp GB2312 + Apple Additions cp936 Code Page 936, also known as GBK (Extended GuoBiao) hz 7-bit escaped GB2312 encoding -------------------------------------------------------------------- To find how to use this module in detail, see L. =head1 NOTES Due to size concerns, C (an extension to C) is distributed separately on CPAN, under the name L. That module also contains extra Taiwan-based encodings. =head1 BUGS When you see C on mails and web pages, they really mean C encodings. To fix that, C is aliased to C. Use C when you really mean it. The ASCII region (0x00-0x7f) is preserved for all encodings, even though this conflicts with mappings by the Unicode Consortium. See L to find out why it is implemented that way. =head1 SEE ALSO L =cut PK[[@OO5.10.1/Encode/Symbol.pmnuW+Apackage Encode::Symbol; use strict; use warnings; use Encode; our $VERSION = do { my @r = ( q$Revision: 2.2 $ =~ /\d+/g ); sprintf "%d." . "%02d" x $#r, @r }; use XSLoader; XSLoader::load( __PACKAGE__, $VERSION ); 1; __END__ =head1 NAME Encode::Symbol - Symbol Encodings =head1 SYNOPSIS use Encode qw/encode decode/; $symbol = encode("symbol", $utf8); # loads Encode::Symbol implicitly $utf8 = decode("", $symbol); # ditto =head1 ABSTRACT This module implements symbol and dingbats encodings. Encodings supported are as follows. Canonical Alias Description -------------------------------------------------------------------- symbol dingbats AdobeZDingbat AdobeSymbol MacDingbats =head1 DESCRIPTION To find out how to use this module in detail, see L. =head1 SEE ALSO L =cut PK[[$5.10.1/Encode/Encoder.pmnuW+A# # $Id: Encoder.pm,v 2.1 2006/05/03 18:24:10 dankogai Exp $ # package Encode::Encoder; use strict; use warnings; our $VERSION = do { my @r = ( q$Revision: 2.1 $ =~ /\d+/g ); sprintf "%d." . "%02d" x $#r, @r }; require Exporter; our @ISA = qw(Exporter); our @EXPORT_OK = qw ( encoder ); our $AUTOLOAD; sub DEBUG () { 0 } use Encode qw(encode decode find_encoding from_to); use Carp; sub new { my ( $class, $data, $encname ) = @_; unless ($encname) { $encname = Encode::is_utf8($data) ? 'utf8' : ''; } else { my $obj = find_encoding($encname) or croak __PACKAGE__, ": unknown encoding: $encname"; $encname = $obj->name; } my $self = { data => $data, encoding => $encname, }; bless $self => $class; } sub encoder { __PACKAGE__->new(@_) } sub data { my ( $self, $data ) = @_; if ( defined $data ) { $self->{data} = $data; return $data; } else { return $self->{data}; } } sub encoding { my ( $self, $encname ) = @_; if ($encname) { my $obj = find_encoding($encname) or confess __PACKAGE__, ": unknown encoding: $encname"; $self->{encoding} = $obj->name; return $self; } else { return $self->{encoding}; } } sub bytes { my ( $self, $encname ) = @_; $encname ||= $self->{encoding}; my $obj = find_encoding($encname) or confess __PACKAGE__, ": unknown encoding: $encname"; $self->{data} = $obj->decode( $self->{data}, 1 ); $self->{encoding} = ''; return $self; } sub DESTROY { # defined so it won't autoload. DEBUG and warn shift; } sub AUTOLOAD { my $self = shift; my $type = ref($self) or confess "$self is not an object"; my $myname = $AUTOLOAD; $myname =~ s/.*://; # strip fully-qualified portion my $obj = find_encoding($myname) or confess __PACKAGE__, ": unknown encoding: $myname"; DEBUG and warn $self->{encoding}, " => ", $obj->name; if ( $self->{encoding} ) { from_to( $self->{data}, $self->{encoding}, $obj->name, 1 ); } else { $self->{data} = $obj->encode( $self->{data}, 1 ); } $self->{encoding} = $obj->name; return $self; } use overload q("") => sub { $_[0]->{data} }, q(0+) => sub { use bytes(); bytes::length( $_[0]->{data} ) }, fallback => 1, ; 1; __END__ =head1 NAME Encode::Encoder -- Object Oriented Encoder =head1 SYNOPSIS use Encode::Encoder; # Encode::encode("ISO-8859-1", $data); Encode::Encoder->new($data)->iso_8859_1; # OOP way # shortcut use Encode::Encoder qw(encoder); encoder($data)->iso_8859_1; # you can stack them! encoder($data)->iso_8859_1->base64; # provided base64() is defined # you can use it as a decoder as well encoder($base64)->bytes('base64')->latin1; # stringified print encoder($data)->utf8->latin1; # prints the string in latin1 # numified encoder("\x{abcd}\x{ef}g")->utf8 == 6; # true. bytes::length($data) =head1 ABSTRACT B allows you to use Encode in an object-oriented style. This is not only more intuitive than a functional approach, but also handier when you want to stack encodings. Suppose you want your UTF-8 string converted to Latin1 then Base64: you can simply say my $base64 = encoder($utf8)->latin1->base64; instead of my $latin1 = encode("latin1", $utf8); my $base64 = encode_base64($utf8); or the lazier and more convoluted my $base64 = encode_base64(encode("latin1", $utf8)); =head1 Description Here is how to use this module. =over 4 =item * There are at least two instance variables stored in a hash reference, {data} and {encoding}. =item * When there is no method, it takes the method name as the name of the encoding and encodes the instance I with I. If successful, the instance I is set accordingly. =item * You can retrieve the result via -Edata but usually you don't have to because the stringify operator ("") is overridden to do exactly that. =back =head2 Predefined Methods This module predefines the methods below: =over 4 =item $e = Encode::Encoder-Enew([$data, $encoding]); returns an encoder object. Its data is initialized with $data if present, and its encoding is set to $encoding if present. When $encoding is omitted, it defaults to utf8 if $data is already in utf8 or "" (empty string) otherwise. =item encoder() is an alias of Encode::Encoder-Enew(). This one is exported on demand. =item $e-Edata([$data]) When $data is present, sets the instance data to $data and returns the object itself. Otherwise, the current instance data is returned. =item $e-Eencoding([$encoding]) When $encoding is present, sets the instance encoding to $encoding and returns the object itself. Otherwise, the current instance encoding is returned. =item $e-Ebytes([$encoding]) decodes instance data from $encoding, or the instance encoding if omitted. If the conversion is successful, the instance encoding will be set to "". The name I was deliberately picked to avoid namespace tainting -- this module may be used as a base class so method names that appear in Encode::Encoding are avoided. =back =head2 Example: base64 transcoder This module is designed to work with L. To make the Base64 transcoder example above really work, you could write a module like this: package Encode::Base64; use base 'Encode::Encoding'; __PACKAGE__->Define('base64'); use MIME::Base64; sub encode{ my ($obj, $data) = @_; return encode_base64($data); } sub decode{ my ($obj, $data) = @_; return decode_base64($data); } 1; __END__ And your caller module would be something like this: use Encode::Encoder; use Encode::Base64; # now you can really do the following encoder($data)->iso_8859_1->base64; encoder($base64)->bytes('base64')->latin1; =head2 Operator Overloading This module overloads two operators, stringify ("") and numify (0+). Stringify dumps the data inside the object. Numify returns the number of bytes in the instance data. They come in handy when you want to print or find the size of data. =head1 SEE ALSO L, L =cut PK[[U'+""5.10.1/Encode/Unicode.pmnuW+Apackage Encode::Unicode; use strict; use warnings; no warnings 'redefine'; our $VERSION = do { my @r = ( q$Revision: 2.6 $ =~ /\d+/g ); sprintf "%d." . "%02d" x $#r, @r }; use XSLoader; XSLoader::load( __PACKAGE__, $VERSION ); # # Object Generator 8 transcoders all at once! # require Encode; our %BOM_Unknown = map { $_ => 1 } qw(UTF-16 UTF-32); for my $name ( qw(UTF-16 UTF-16BE UTF-16LE UTF-32 UTF-32BE UTF-32LE UCS-2BE UCS-2LE) ) { my ( $size, $endian, $ucs2, $mask ); $name =~ /^(\w+)-(\d+)(\w*)$/o; if ( $ucs2 = ( $1 eq 'UCS' ) ) { $size = 2; } else { $size = $2 / 8; } $endian = ( $3 eq 'BE' ) ? 'n' : ( $3 eq 'LE' ) ? 'v' : ''; $size == 4 and $endian = uc($endian); $Encode::Encoding{$name} = bless { Name => $name, size => $size, endian => $endian, ucs2 => $ucs2, } => __PACKAGE__; } use base qw(Encode::Encoding); sub renew { my $self = shift; $BOM_Unknown{ $self->name } or return $self; my $clone = bless {%$self} => ref($self); $clone->{renewed}++; # so the caller knows it is renewed. return $clone; } # There used to be a perl implemntation of (en|de)code but with # XS version is ripe, perl version is zapped for optimal speed *decode = \&decode_xs; *encode = \&encode_xs; 1; __END__ =head1 NAME Encode::Unicode -- Various Unicode Transformation Formats =cut =head1 SYNOPSIS use Encode qw/encode decode/; $ucs2 = encode("UCS-2BE", $utf8); $utf8 = decode("UCS-2BE", $ucs2); =head1 ABSTRACT This module implements all Character Encoding Schemes of Unicode that are officially documented by Unicode Consortium (except, of course, for UTF-8, which is a native format in perl). =over 4 =item L says: I A character encoding form plus byte serialization. There are Seven character encoding schemes in Unicode: UTF-8, UTF-16, UTF-16BE, UTF-16LE, UTF-32 (UCS-4), UTF-32BE (UCS-4BE) and UTF-32LE (UCS-4LE), and UTF-7. Since UTF-7 is a 7-bit (re)encoded version of UTF-16BE, It is not part of Unicode's Character Encoding Scheme. It is separately implemented in Encode::Unicode::UTF7. For details see L. =item Quick Reference Decodes from ord(N) Encodes chr(N) to... octet/char BOM S.P d800-dfff ord > 0xffff \x{1abcd} == ---------------+-----------------+------------------------------ UCS-2BE 2 N N is bogus Not Available UCS-2LE 2 N N bogus Not Available UTF-16 2/4 Y Y is S.P S.P BE/LE UTF-16BE 2/4 N Y S.P S.P 0xd82a,0xdfcd UTF-16LE 2/4 N Y S.P S.P 0x2ad8,0xcddf UTF-32 4 Y - is bogus As is BE/LE UTF-32BE 4 N - bogus As is 0x0001abcd UTF-32LE 4 N - bogus As is 0xcdab0100 UTF-8 1-4 - - bogus >= 4 octets \xf0\x9a\af\8d ---------------+-----------------+------------------------------ =back =head1 Size, Endianness, and BOM You can categorize these CES by 3 criteria: size of each character, endianness, and Byte Order Mark. =head2 by size UCS-2 is a fixed-length encoding with each character taking 16 bits. It B support I. When a surrogate pair is encountered during decode(), its place is filled with \x{FFFD} if I is 0, or the routine croaks if I is 1. When a character whose ord value is larger than 0xFFFF is encountered, its place is filled with \x{FFFD} if I is 0, or the routine croaks if I is 1. UTF-16 is almost the same as UCS-2 but it supports I. When it encounters a high surrogate (0xD800-0xDBFF), it fetches the following low surrogate (0xDC00-0xDFFF) and Cs them to form a character. Bogus surrogates result in death. When \x{10000} or above is encountered during encode(), it Cs them and pushes the surrogate pair to the output stream. UTF-32 (UCS-4) is a fixed-length encoding with each character taking 32 bits. Since it is 32-bit, there is no need for I. =head2 by endianness The first (and now failed) goal of Unicode was to map all character repertoires into a fixed-length integer so that programmers are happy. Since each character is either a I or I in C, you have to pay attention to the endianness of each platform when you pass data to one another. Anything marked as BE is Big Endian (or network byte order) and LE is Little Endian (aka VAX byte order). For anything not marked either BE or LE, a character called Byte Order Mark (BOM) indicating the endianness is prepended to the string. CAVEAT: Though BOM in utf8 (\xEF\xBB\xBF) is valid, it is meaningless and as of this writing Encode suite just leave it as is (\x{FeFF}). =over 4 =item BOM as integer when fetched in network byte order 16 32 bits/char ------------------------- BE 0xFeFF 0x0000FeFF LE 0xFFFe 0xFFFe0000 ------------------------- =back This modules handles the BOM as follows. =over 4 =item * When BE or LE is explicitly stated as the name of encoding, BOM is simply treated as a normal character (ZERO WIDTH NO-BREAK SPACE). =item * When BE or LE is omitted during decode(), it checks if BOM is at the beginning of the string; if one is found, the endianness is set to what the BOM says. If no BOM is found, the routine dies. =item * When BE or LE is omitted during encode(), it returns a BE-encoded string with BOM prepended. So when you want to encode a whole text file, make sure you encode() the whole text at once, not line by line or each line, not file, will have a BOM prepended. =item * C is an exception. Unlike others, this is an alias of UCS-2BE. UCS-2 is already registered by IANA and others that way. =back =head1 Surrogate Pairs To say the least, surrogate pairs were the biggest mistake of the Unicode Consortium. But according to the late Douglas Adams in I Trilogy, C. Their mistake was not of this magnitude so let's forgive them. (I don't dare make any comparison with Unicode Consortium and the Vogons here ;) Or, comparing Encode to Babel Fish is completely appropriate -- if you can only stick this into your ear :) Surrogate pairs were born when the Unicode Consortium finally admitted that 16 bits were not big enough to hold all the world's character repertoires. But they already made UCS-2 16-bit. What do we do? Back then, the range 0xD800-0xDFFF was not allocated. Let's split that range in half and use the first half to represent the C and the second half to represent the C. That way, you can represent 1024 * 1024 = 1048576 more characters. Now we can store character ranges up to \x{10ffff} even with 16-bit encodings. This pair of half-character is now called a I and UTF-16 is the name of the encoding that embraces them. Here is a formula to ensurrogate a Unicode character \x{10000} and above; $hi = ($uni - 0x10000) / 0x400 + 0xD800; $lo = ($uni - 0x10000) % 0x400 + 0xDC00; And to desurrogate; $uni = 0x10000 + ($hi - 0xD800) * 0x400 + ($lo - 0xDC00); Note this move has made \x{D800}-\x{DFFF} into a forbidden zone but perl does not prohibit the use of characters within this range. To perl, every one of \x{0000_0000} up to \x{ffff_ffff} (*) is I. (*) or \x{ffff_ffff_ffff_ffff} if your perl is compiled with 64-bit integer support! =head1 Error Checking Unlike most encodings which accept various ways to handle errors, Unicode encodings simply croaks. % perl -MEncode -e'$_ = "\xfe\xff\xd8\xd9\xda\xdb\0\n"' \ -e'Encode::from_to($_, "utf16","shift_jis", 0); print' UTF-16:Malformed LO surrogate d8d9 at /path/to/Encode.pm line 184. % perl -MEncode -e'$a = "BOM missing"' \ -e' Encode::from_to($a, "utf16", "shift_jis", 0); print' UTF-16:Unrecognised BOM 424f at /path/to/Encode.pm line 184. Unlike other encodings where mappings are not one-to-one against Unicode, UTFs are supposed to map 100% against one another. So Encode is more strict on UTFs. Consider that "division by zero" of Encode :) =head1 SEE ALSO L, L, L, L, RFC 2781 L, The whole Unicode standard L Ch. 15, pp. 403 of C by Larry Wall, Tom Christiansen, Jon Orwant; O'Reilly & Associates; ISBN 0-596-00027-8 =cut PK[[Tjj5.10.1/Encode/KR/2022_KR.pmnuW+Apackage Encode::KR::2022_KR; use strict; use warnings; our $VERSION = do { my @r = ( q$Revision: 2.2 $ =~ /\d+/g ); sprintf "%d." . "%02d" x $#r, @r }; use Encode qw(:fallbacks); use base qw(Encode::Encoding); __PACKAGE__->Define('iso-2022-kr'); sub needs_lines { 1 } sub perlio_ok { return 0; # for the time being } sub decode { my ( $obj, $str, $chk ) = @_; my $res = $str; my $residue = iso_euc( \$res ); # This is for PerlIO $_[1] = $residue if $chk; return Encode::decode( 'euc-kr', $res, FB_PERLQQ ); } sub encode { my ( $obj, $utf8, $chk ) = @_; # empty the input string in the stack so perlio is ok $_[1] = '' if $chk; my $octet = Encode::encode( 'euc-kr', $utf8, FB_PERLQQ ); euc_iso( \$octet ); return $octet; } use Encode::CJKConstants qw(:all); # ISO<->EUC sub iso_euc { my $r_str = shift; $$r_str =~ s/$RE{'2022_KR'}//gox; # remove the designator $$r_str =~ s{ # replace characters in GL \x0e # between SO(\x0e) and SI(\x0f) ([^\x0f]*) # with characters in GR \x0f } { my $out= $1; $out =~ tr/\x21-\x7e/\xa1-\xfe/; $out; }geox; my ($residue) = ( $$r_str =~ s/(\e.*)$//so ); return $residue; } sub euc_iso { no warnings qw(uninitialized); my $r_str = shift; substr( $$r_str, 0, 0 ) = $ESC{'2022_KR'}; # put the designator at the beg. $$r_str =~ s{ # move KS X 1001 characters in GR to GL ($RE{EUC_C}+) # and enclose them with SO and SI }{ my $str = $1; $str =~ tr/\xA1-\xFE/\x21-\x7E/; "\x0e" . $str . "\x0f"; }geox; $$r_str; } 1; __END__ =head1 NAME Encode::KR::2022_KR -- internally used by Encode::KR =cut PK[[+b b 5.10.1/Encode/TW.pmnuW+Apackage Encode::TW; BEGIN { if ( ord("A") == 193 ) { die "Encode::TW not supported on EBCDIC\n"; } } use strict; use warnings; use Encode; our $VERSION = do { my @r = ( q$Revision: 2.2 $ =~ /\d+/g ); sprintf "%d." . "%02d" x $#r, @r }; use XSLoader; XSLoader::load( __PACKAGE__, $VERSION ); 1; __END__ =head1 NAME Encode::TW - Taiwan-based Chinese Encodings =head1 SYNOPSIS use Encode qw/encode decode/; $big5 = encode("big5", $utf8); # loads Encode::TW implicitly $utf8 = decode("big5", $big5); # ditto =head1 DESCRIPTION This module implements tradition Chinese charset encodings as used in Taiwan and Hong Kong. Encodings supported are as follows. Canonical Alias Description -------------------------------------------------------------------- big5-eten /\bbig-?5$/i Big5 encoding (with ETen extensions) /\bbig5-?et(en)?$/i /\btca-?big5$/i big5-hkscs /\bbig5-?hk(scs)?$/i /\bhk(scs)?-?big5$/i Big5 + Cantonese characters in Hong Kong MacChineseTrad Big5 + Apple Vendor Mappings cp950 Code Page 950 = Big5 + Microsoft vendor mappings -------------------------------------------------------------------- To find out how to use this module in detail, see L. =head1 NOTES Due to size concerns, C (Extended Unix Character), C (Chinese Character Code for Information Interchange), C (CMEX's Big5+) and C (CMEX's Big5e) are distributed separately on CPAN, under the name L. That module also contains extra China-based encodings. =head1 BUGS Since the original C encoding (1984) is not supported anywhere (glibc and DOS-based systems uses C to mean C; Microsoft uses C to mean C), a conscious decision was made to alias C to C, which is the de facto superset of the original big5. The C encoding files are not complete. For common C manipulation, please use C in L, which contains planes 1-7. The ASCII region (0x00-0x7f) is preserved for all encodings, even though this conflicts with mappings by the Unicode Consortium. See L to find out why it is implemented that way. =head1 SEE ALSO L =cut PK[[և##5.10.1/Encode/Encoding.pmnuW+Apackage Encode::Encoding; # Base class for classes which implement encodings use strict; use warnings; our $VERSION = do { my @r = ( q$Revision: 2.5 $ =~ /\d+/g ); sprintf "%d." . "%02d" x $#r, @r }; require Encode; sub DEBUG { 0 } sub Define { my $obj = shift; my $canonical = shift; $obj = bless { Name => $canonical }, $obj unless ref $obj; # warn "$canonical => $obj\n"; Encode::define_encoding( $obj, $canonical, @_ ); } sub name { return shift->{'Name'} } sub mime_name{ require Encode::MIME::Name; return Encode::MIME::Name::get_mime_name(shift->name); } # sub renew { return $_[0] } sub renew { my $self = shift; my $clone = bless {%$self} => ref($self); $clone->{renewed}++; # so the caller can see it DEBUG and warn $clone->{renewed}; return $clone; } sub renewed { return $_[0]->{renewed} || 0 } *new_sequence = \&renew; sub needs_lines { 0 } sub perlio_ok { eval { require PerlIO::encoding }; return $@ ? 0 : 1; } # (Temporary|legacy) methods sub toUnicode { shift->decode(@_) } sub fromUnicode { shift->encode(@_) } # # Needs to be overloaded or just croak # sub encode { require Carp; my $obj = shift; my $class = ref($obj) ? ref($obj) : $obj; Carp::croak( $class . "->encode() not defined!" ); } sub decode { require Carp; my $obj = shift; my $class = ref($obj) ? ref($obj) : $obj; Carp::croak( $class . "->encode() not defined!" ); } sub DESTROY { } 1; __END__ =head1 NAME Encode::Encoding - Encode Implementation Base Class =head1 SYNOPSIS package Encode::MyEncoding; use base qw(Encode::Encoding); __PACKAGE__->Define(qw(myCanonical myAlias)); =head1 DESCRIPTION As mentioned in L, encodings are (in the current implementation at least) defined as objects. The mapping of encoding name to object is via the C<%Encode::Encoding> hash. Though you can directly manipulate this hash, it is strongly encouraged to use this base class module and add encode() and decode() methods. =head2 Methods you should implement You are strongly encouraged to implement methods below, at least either encode() or decode(). =over 4 =item -Eencode($string [,$check]) MUST return the octet sequence representing I<$string>. =over 2 =item * If I<$check> is true, it SHOULD modify I<$string> in place to remove the converted part (i.e. the whole string unless there is an error). If perlio_ok() is true, SHOULD becomes MUST. =item * If an error occurs, it SHOULD return the octet sequence for the fragment of string that has been converted and modify $string in-place to remove the converted part leaving it starting with the problem fragment. If perlio_ok() is true, SHOULD becomes MUST. =item * If I<$check> is is false then C MUST make a "best effort" to convert the string - for example, by using a replacement character. =back =item -Edecode($octets [,$check]) MUST return the string that I<$octets> represents. =over 2 =item * If I<$check> is true, it SHOULD modify I<$octets> in place to remove the converted part (i.e. the whole sequence unless there is an error). If perlio_ok() is true, SHOULD becomes MUST. =item * If an error occurs, it SHOULD return the fragment of string that has been converted and modify $octets in-place to remove the converted part leaving it starting with the problem fragment. If perlio_ok() is true, SHOULD becomes MUST. =item * If I<$check> is false then C should make a "best effort" to convert the string - for example by using Unicode's "\x{FFFD}" as a replacement character. =back =back If you want your encoding to work with L pragma, you should also implement the method below. =over 4 =item -Ecat_decode($destination, $octets, $offset, $terminator [,$check]) MUST decode I<$octets> with I<$offset> and concatenate it to I<$destination>. Decoding will terminate when $terminator (a string) appears in output. I<$offset> will be modified to the last $octets position at end of decode. Returns true if $terminator appears output, else returns false. =back =head2 Other methods defined in Encode::Encodings You do not have to override methods shown below unless you have to. =over 4 =item -Ename Predefined As: sub name { return shift->{'Name'} } MUST return the string representing the canonical name of the encoding. =item -Emime_name Predefined As: sub mime_name{ require Encode::MIME::Name; return Encode::MIME::Name::get_mime_name(shift->name); } MUST return the string representing the IANA charset name of the encoding. =item -Erenew Predefined As: sub renew { my $self = shift; my $clone = bless { %$self } => ref($self); $clone->{renewed}++; return $clone; } This method reconstructs the encoding object if necessary. If you need to store the state during encoding, this is where you clone your object. PerlIO ALWAYS calls this method to make sure it has its own private encoding object. =item -Erenewed Predefined As: sub renewed { $_[0]->{renewed} || 0 } Tells whether the object is renewed (and how many times). Some modules emit C warning unless the value is numeric so return 0 for false. =item -Eperlio_ok() Predefined As: sub perlio_ok { eval{ require PerlIO::encoding }; return $@ ? 0 : 1; } If your encoding does not support PerlIO for some reasons, just; sub perlio_ok { 0 } =item -Eneeds_lines() Predefined As: sub needs_lines { 0 }; If your encoding can work with PerlIO but needs line buffering, you MUST define this method so it returns true. 7bit ISO-2022 encodings are one example that needs this. When this method is missing, false is assumed. =back =head2 Example: Encode::ROT13 package Encode::ROT13; use strict; use base qw(Encode::Encoding); __PACKAGE__->Define('rot13'); sub encode($$;$){ my ($obj, $str, $chk) = @_; $str =~ tr/A-Za-z/N-ZA-Mn-za-m/; $_[1] = '' if $chk; # this is what in-place edit means return $str; } # Jr pna or ynml yvxr guvf; *decode = \&encode; 1; =head1 Why the heck Encode API is different? It should be noted that the I<$check> behaviour is different from the outer public API. The logic is that the "unchecked" case is useful when the encoding is part of a stream which may be reporting errors (e.g. STDERR). In such cases, it is desirable to get everything through somehow without causing additional errors which obscure the original one. Also, the encoding is best placed to know what the correct replacement character is, so if that is the desired behaviour then letting low level code do it is the most efficient. By contrast, if I<$check> is true, the scheme above allows the encoding to do as much as it can and tell the layer above how much that was. What is lacking at present is a mechanism to report what went wrong. The most likely interface will be an additional method call to the object, or perhaps (to avoid forcing per-stream objects on otherwise stateless encodings) an additional parameter. It is also highly desirable that encoding classes inherit from C as a base class. This allows that class to define additional behaviour for all encoding objects. package Encode::MyEncoding; use base qw(Encode::Encoding); __PACKAGE__->Define(qw(myCanonical myAlias)); to create an object with C<< bless {Name => ...}, $class >>, and call define_encoding. They inherit their C method from C. =head2 Compiled Encodings For the sake of speed and efficiency, most of the encodings are now supported via a I: XS modules generated from UCM files. Encode provides the enc2xs tool to achieve that. Please see L for more details. =head1 SEE ALSO L, L =begin future =over 4 =item Scheme 1 The fixup routine gets passed the remaining fragment of string being processed. It modifies it in place to remove bytes/characters it can understand and returns a string used to represent them. For example: sub fixup { my $ch = substr($_[0],0,1,''); return sprintf("\x{%02X}",ord($ch); } This scheme is close to how the underlying C code for Encode works, but gives the fixup routine very little context. =item Scheme 2 The fixup routine gets passed the original string, an index into it of the problem area, and the output string so far. It appends what it wants to the output string and returns a new index into the original string. For example: sub fixup { # my ($s,$i,$d) = @_; my $ch = substr($_[0],$_[1],1); $_[2] .= sprintf("\x{%02X}",ord($ch); return $_[1]+1; } This scheme gives maximal control to the fixup routine but is more complicated to code, and may require that the internals of Encode be tweaked to keep the original string intact. =item Other Schemes Hybrids of the above. Multiple return values rather than in-place modifications. Index into the string could be C allowing C. =back =end future =cut PK[[--5.10.1/Encode/Alias.pmnuW+Apackage Encode::Alias; use strict; use warnings; no warnings 'redefine'; our $VERSION = do { my @r = ( q$Revision: 2.12 $ =~ /\d+/g ); sprintf "%d." . "%02d" x $#r, @r }; sub DEBUG () { 0 } use base qw(Exporter); # Public, encouraged API is exported by default our @EXPORT = qw ( define_alias find_alias ); our @Alias; # ordered matching list our %Alias; # cached known aliases sub find_alias { require Encode; my $class = shift; my $find = shift; unless ( exists $Alias{$find} ) { $Alias{$find} = undef; # Recursion guard for ( my $i = 0 ; $i < @Alias ; $i += 2 ) { my $alias = $Alias[$i]; my $val = $Alias[ $i + 1 ]; my $new; if ( ref($alias) eq 'Regexp' && $find =~ $alias ) { DEBUG and warn "eval $val"; $new = eval $val; DEBUG and $@ and warn "$val, $@"; } elsif ( ref($alias) eq 'CODE' ) { DEBUG and warn "$alias", "->", "($find)"; $new = $alias->($find); } elsif ( lc($find) eq lc($alias) ) { $new = $val; } if ( defined($new) ) { next if $new eq $find; # avoid (direct) recursion on bugs DEBUG and warn "$alias, $new"; my $enc = ( ref($new) ) ? $new : Encode::find_encoding($new); if ($enc) { $Alias{$find} = $enc; last; } } } # case insensitive search when canonical is not in all lowercase # RT ticket #7835 unless ( $Alias{$find} ) { my $lcfind = lc($find); for my $name ( keys %Encode::Encoding, keys %Encode::ExtModule ) { $lcfind eq lc($name) or next; $Alias{$find} = Encode::find_encoding($name); DEBUG and warn "$find => $name"; } } } if (DEBUG) { my $name; if ( my $e = $Alias{$find} ) { $name = $e->name; } else { $name = ""; } warn "find_alias($class, $find)->name = $name"; } return $Alias{$find}; } sub define_alias { while (@_) { my ( $alias, $name ) = splice( @_, 0, 2 ); unshift( @Alias, $alias => $name ); # newer one has precedence if ( ref($alias) ) { # clear %Alias cache to allow overrides my @a = keys %Alias; for my $k (@a) { if ( ref($alias) eq 'Regexp' && $k =~ $alias ) { DEBUG and warn "delete \$Alias\{$k\}"; delete $Alias{$k}; } elsif ( ref($alias) eq 'CODE' ) { DEBUG and warn "delete \$Alias\{$k\}"; delete $Alias{ $alias->($name) }; } } } else { DEBUG and warn "delete \$Alias\{$alias\}"; delete $Alias{$alias}; } } } # Allow latin-1 style names as well # 0 1 2 3 4 5 6 7 8 9 10 our @Latin2iso = ( 0, 1, 2, 3, 4, 9, 10, 13, 14, 15, 16 ); # Allow winlatin1 style names as well our %Winlatin2cp = ( 'latin1' => 1252, 'latin2' => 1250, 'cyrillic' => 1251, 'greek' => 1253, 'turkish' => 1254, 'hebrew' => 1255, 'arabic' => 1256, 'baltic' => 1257, 'vietnamese' => 1258, ); init_aliases(); sub undef_aliases { @Alias = (); %Alias = (); } sub init_aliases { require Encode; undef_aliases(); # Try all-lower-case version should all else fails define_alias( qr/^(.*)$/ => '"\L$1"' ); # UTF/UCS stuff define_alias( qr/^(unicode-1-1-)?UTF-?7$/i => '"UTF-7"' ); define_alias( qr/^UCS-?2-?LE$/i => '"UCS-2LE"' ); define_alias( qr/^UCS-?2-?(BE)?$/i => '"UCS-2BE"', qr/^UCS-?4-?(BE|LE)?$/i => 'uc("UTF-32$1")', qr/^iso-10646-1$/i => '"UCS-2BE"' ); define_alias( qr/^UTF-?(16|32)-?BE$/i => '"UTF-$1BE"', qr/^UTF-?(16|32)-?LE$/i => '"UTF-$1LE"', qr/^UTF-?(16|32)$/i => '"UTF-$1"', ); # ASCII define_alias( qr/^(?:US-?)ascii$/i => '"ascii"' ); define_alias( 'C' => 'ascii' ); define_alias( qr/\b(?:ISO[-_]?)?646(?:[-_]?US)?$/i => '"ascii"' ); # Allow variants of iso-8859-1 etc. define_alias( qr/\biso[-_]?(\d+)[-_](\d+)$/i => '"iso-$1-$2"' ); # At least HP-UX has these. define_alias( qr/\biso8859(\d+)$/i => '"iso-8859-$1"' ); # More HP stuff. define_alias( qr/\b(?:hp-)?(arabic|greek|hebrew|kana|roman|thai|turkish)8$/i => '"${1}8"' ); # The Official name of ASCII. define_alias( qr/\bANSI[-_]?X3\.4[-_]?1968$/i => '"ascii"' ); # This is a font issue, not an encoding issue. # (The currency symbol of the Latin 1 upper half # has been redefined as the euro symbol.) define_alias( qr/^(.+)\@euro$/i => '"$1"' ); define_alias( qr/\b(?:iso[-_]?)?latin[-_]?(\d+)$/i => 'defined $Encode::Alias::Latin2iso[$1] ? "iso-8859-$Encode::Alias::Latin2iso[$1]" : undef' ); define_alias( qr/\bwin(latin[12]|cyrillic|baltic|greek|turkish| hebrew|arabic|baltic|vietnamese)$/ix => '"cp" . $Encode::Alias::Winlatin2cp{lc($1)}' ); # Common names for non-latin preferred MIME names define_alias( 'ascii' => 'US-ascii', 'cyrillic' => 'iso-8859-5', 'arabic' => 'iso-8859-6', 'greek' => 'iso-8859-7', 'hebrew' => 'iso-8859-8', 'thai' => 'iso-8859-11', ); # RT #20781 define_alias(qr/\btis-?620\b/i => '"iso-8859-11"'); # At least AIX has IBM-NNN (surprisingly...) instead of cpNNN. # And Microsoft has their own naming (again, surprisingly). # And windows-* is registered in IANA! define_alias( qr/\b(?:cp|ibm|ms|windows)[-_ ]?(\d{2,4})$/i => '"cp$1"' ); # Sometimes seen with a leading zero. # define_alias( qr/\bcp037\b/i => '"cp37"'); # Mac Mappings # predefined in *.ucm; unneeded # define_alias( qr/\bmacIcelandic$/i => '"macIceland"'); define_alias( qr/^mac_(.*)$/i => '"mac$1"' ); # http://rt.cpan.org/Ticket/Display.html?id=36326 define_alias( qr/^macintosh$/i => '"MacRoman"' ); # Ououououou. gone. They are differente! # define_alias( qr/\bmacRomanian$/i => '"macRumanian"'); # Standardize on the dashed versions. define_alias( qr/\bkoi8[\s\-_]*([ru])$/i => '"koi8-$1"' ); unless ($Encode::ON_EBCDIC) { # for Encode::CN define_alias( qr/\beuc.*cn$/i => '"euc-cn"' ); define_alias( qr/\bcn.*euc$/i => '"euc-cn"' ); # define_alias( qr/\bGB[- ]?(\d+)$/i => '"euc-cn"' ) # CP936 doesn't have vendor-addon for GBK, so they're identical. define_alias( qr/^gbk$/i => '"cp936"' ); # This fixes gb2312 vs. euc-cn confusion, practically define_alias( qr/\bGB[-_ ]?2312(?!-?raw)/i => '"euc-cn"' ); # for Encode::JP define_alias( qr/\bjis$/i => '"7bit-jis"' ); define_alias( qr/\beuc.*jp$/i => '"euc-jp"' ); define_alias( qr/\bjp.*euc$/i => '"euc-jp"' ); define_alias( qr/\bujis$/i => '"euc-jp"' ); define_alias( qr/\bshift.*jis$/i => '"shiftjis"' ); define_alias( qr/\bsjis$/i => '"shiftjis"' ); define_alias( qr/\bwindows-31j$/i => '"cp932"' ); # for Encode::KR define_alias( qr/\beuc.*kr$/i => '"euc-kr"' ); define_alias( qr/\bkr.*euc$/i => '"euc-kr"' ); # This fixes ksc5601 vs. euc-kr confusion, practically define_alias( qr/(?:x-)?uhc$/i => '"cp949"' ); define_alias( qr/(?:x-)?windows-949$/i => '"cp949"' ); define_alias( qr/\bks_c_5601-1987$/i => '"cp949"' ); # for Encode::TW define_alias( qr/\bbig-?5$/i => '"big5-eten"' ); define_alias( qr/\bbig5-?et(?:en)?$/i => '"big5-eten"' ); define_alias( qr/\btca[-_]?big5$/i => '"big5-eten"' ); define_alias( qr/\bbig5-?hk(?:scs)?$/i => '"big5-hkscs"' ); define_alias( qr/\bhk(?:scs)?[-_]?big5$/i => '"big5-hkscs"' ); } # utf8 is blessed :) define_alias( qr/\bUTF-8$/i => '"utf-8-strict"' ); # At last, Map white space and _ to '-' define_alias( qr/^(\S+)[\s_]+(.*)$/i => '"$1-$2"' ); } 1; __END__ # TODO: HP-UX '8' encodings arabic8 greek8 hebrew8 kana8 thai8 turkish8 # TODO: HP-UX '15' encodings japanese15 korean15 roi15 # TODO: Cyrillic encoding ISO-IR-111 (useful?) # TODO: Armenian encoding ARMSCII-8 # TODO: Hebrew encoding ISO-8859-8-1 # TODO: Thai encoding TCVN # TODO: Vietnamese encodings VPS # TODO: Mac Asian+African encodings: Arabic Armenian Bengali Burmese # ChineseSimp ChineseTrad Devanagari Ethiopic ExtArabic # Farsi Georgian Gujarati Gurmukhi Hebrew Japanese # Kannada Khmer Korean Laotian Malayalam Mongolian # Oriya Sinhalese Symbol Tamil Telugu Tibetan Vietnamese =head1 NAME Encode::Alias - alias definitions to encodings =head1 SYNOPSIS use Encode; use Encode::Alias; define_alias( newName => ENCODING); =head1 DESCRIPTION Allows newName to be used as an alias for ENCODING. ENCODING may be either the name of an encoding or an encoding object (as described in L). Currently I can be specified in the following ways: =over 4 =item As a simple string. =item As a qr// compiled regular expression, e.g.: define_alias( qr/^iso8859-(\d+)$/i => '"iso-8859-$1"' ); In this case, if I is not a reference, it is C-ed in order to allow C<$1> etc. to be substituted. The example is one way to alias names as used in X11 fonts to the MIME names for the iso-8859-* family. Note the double quotes inside the single quotes. (or, you don't have to do this yourself because this example is predefined) If you are using a regex here, you have to use the quotes as shown or it won't work. Also note that regex handling is tricky even for the experienced. Use this feature with caution. =item As a code reference, e.g.: define_alias( sub {shift =~ /^iso8859-(\d+)$/i ? "iso-8859-$1" : undef } ); The same effect as the example above in a different way. The coderef takes the alias name as an argument and returns a canonical name on success or undef if not. Note the second argument is not required. Use this with even more caution than the regex version. =back =head3 Changes in code reference aliasing As of Encode 1.87, the older form define_alias( sub { return /^iso8859-(\d+)$/i ? "iso-8859-$1" : undef } ); no longer works. Encode up to 1.86 internally used "local $_" to implement ths older form. But consider the code below; use Encode; $_ = "eeeee" ; while (/(e)/g) { my $utf = decode('aliased-encoding-name', $1); print "position:",pos,"\n"; } Prior to Encode 1.86 this fails because of "local $_". =head2 Alias overloading You can override predefined aliases by simply applying define_alias(). The new alias is always evaluated first, and when necessary, define_alias() flushes the internal cache to make the new definition available. # redirect SHIFT_JIS to MS/IBM Code Page 932, which is a # superset of SHIFT_JIS define_alias( qr/shift.*jis$/i => '"cp932"' ); define_alias( qr/sjis$/i => '"cp932"' ); If you want to zap all predefined aliases, you can use Encode::Alias->undef_aliases; to do so. And Encode::Alias->init_aliases; gets the factory settings back. =head1 SEE ALSO L, L =cut PK[[n-n-5.10.1/Encode/GSM0338.pmnuW+A# # $Id: GSM0338.pm,v 2.1 2008/05/07 20:56:05 dankogai Exp $ # package Encode::GSM0338; use strict; use warnings; use Carp; use vars qw($VERSION); $VERSION = do { my @r = ( q$Revision: 2.1 $ =~ /\d+/g ); sprintf "%d." . "%02d" x $#r, @r }; use Encode qw(:fallbacks); use base qw(Encode::Encoding); __PACKAGE__->Define('gsm0338'); sub needs_lines { 1 } sub perlio_ok { 0 } use utf8; our %UNI2GSM = ( "\x{0040}" => "\x00", # COMMERCIAL AT "\x{000A}" => "\x0A", # LINE FEED "\x{000C}" => "\x1B\x0A", # FORM FEED "\x{000D}" => "\x0D", # CARRIAGE RETURN "\x{0020}" => "\x20", # SPACE "\x{0021}" => "\x21", # EXCLAMATION MARK "\x{0022}" => "\x22", # QUOTATION MARK "\x{0023}" => "\x23", # NUMBER SIGN "\x{0024}" => "\x02", # DOLLAR SIGN "\x{0025}" => "\x25", # PERCENT SIGN "\x{0026}" => "\x26", # AMPERSAND "\x{0027}" => "\x27", # APOSTROPHE "\x{0028}" => "\x28", # LEFT PARENTHESIS "\x{0029}" => "\x29", # RIGHT PARENTHESIS "\x{002A}" => "\x2A", # ASTERISK "\x{002B}" => "\x2B", # PLUS SIGN "\x{002C}" => "\x2C", # COMMA "\x{002D}" => "\x2D", # HYPHEN-MINUS "\x{002E}" => "\x2E", # FULL STOP "\x{002F}" => "\x2F", # SOLIDUS "\x{0030}" => "\x30", # DIGIT ZERO "\x{0031}" => "\x31", # DIGIT ONE "\x{0032}" => "\x32", # DIGIT TWO "\x{0033}" => "\x33", # DIGIT THREE "\x{0034}" => "\x34", # DIGIT FOUR "\x{0035}" => "\x35", # DIGIT FIVE "\x{0036}" => "\x36", # DIGIT SIX "\x{0037}" => "\x37", # DIGIT SEVEN "\x{0038}" => "\x38", # DIGIT EIGHT "\x{0039}" => "\x39", # DIGIT NINE "\x{003A}" => "\x3A", # COLON "\x{003B}" => "\x3B", # SEMICOLON "\x{003C}" => "\x3C", # LESS-THAN SIGN "\x{003D}" => "\x3D", # EQUALS SIGN "\x{003E}" => "\x3E", # GREATER-THAN SIGN "\x{003F}" => "\x3F", # QUESTION MARK "\x{0041}" => "\x41", # LATIN CAPITAL LETTER A "\x{0042}" => "\x42", # LATIN CAPITAL LETTER B "\x{0043}" => "\x43", # LATIN CAPITAL LETTER C "\x{0044}" => "\x44", # LATIN CAPITAL LETTER D "\x{0045}" => "\x45", # LATIN CAPITAL LETTER E "\x{0046}" => "\x46", # LATIN CAPITAL LETTER F "\x{0047}" => "\x47", # LATIN CAPITAL LETTER G "\x{0048}" => "\x48", # LATIN CAPITAL LETTER H "\x{0049}" => "\x49", # LATIN CAPITAL LETTER I "\x{004A}" => "\x4A", # LATIN CAPITAL LETTER J "\x{004B}" => "\x4B", # LATIN CAPITAL LETTER K "\x{004C}" => "\x4C", # LATIN CAPITAL LETTER L "\x{004D}" => "\x4D", # LATIN CAPITAL LETTER M "\x{004E}" => "\x4E", # LATIN CAPITAL LETTER N "\x{004F}" => "\x4F", # LATIN CAPITAL LETTER O "\x{0050}" => "\x50", # LATIN CAPITAL LETTER P "\x{0051}" => "\x51", # LATIN CAPITAL LETTER Q "\x{0052}" => "\x52", # LATIN CAPITAL LETTER R "\x{0053}" => "\x53", # LATIN CAPITAL LETTER S "\x{0054}" => "\x54", # LATIN CAPITAL LETTER T "\x{0055}" => "\x55", # LATIN CAPITAL LETTER U "\x{0056}" => "\x56", # LATIN CAPITAL LETTER V "\x{0057}" => "\x57", # LATIN CAPITAL LETTER W "\x{0058}" => "\x58", # LATIN CAPITAL LETTER X "\x{0059}" => "\x59", # LATIN CAPITAL LETTER Y "\x{005A}" => "\x5A", # LATIN CAPITAL LETTER Z "\x{005F}" => "\x11", # LOW LINE "\x{0061}" => "\x61", # LATIN SMALL LETTER A "\x{0062}" => "\x62", # LATIN SMALL LETTER B "\x{0063}" => "\x63", # LATIN SMALL LETTER C "\x{0064}" => "\x64", # LATIN SMALL LETTER D "\x{0065}" => "\x65", # LATIN SMALL LETTER E "\x{0066}" => "\x66", # LATIN SMALL LETTER F "\x{0067}" => "\x67", # LATIN SMALL LETTER G "\x{0068}" => "\x68", # LATIN SMALL LETTER H "\x{0069}" => "\x69", # LATIN SMALL LETTER I "\x{006A}" => "\x6A", # LATIN SMALL LETTER J "\x{006B}" => "\x6B", # LATIN SMALL LETTER K "\x{006C}" => "\x6C", # LATIN SMALL LETTER L "\x{006D}" => "\x6D", # LATIN SMALL LETTER M "\x{006E}" => "\x6E", # LATIN SMALL LETTER N "\x{006F}" => "\x6F", # LATIN SMALL LETTER O "\x{0070}" => "\x70", # LATIN SMALL LETTER P "\x{0071}" => "\x71", # LATIN SMALL LETTER Q "\x{0072}" => "\x72", # LATIN SMALL LETTER R "\x{0073}" => "\x73", # LATIN SMALL LETTER S "\x{0074}" => "\x74", # LATIN SMALL LETTER T "\x{0075}" => "\x75", # LATIN SMALL LETTER U "\x{0076}" => "\x76", # LATIN SMALL LETTER V "\x{0077}" => "\x77", # LATIN SMALL LETTER W "\x{0078}" => "\x78", # LATIN SMALL LETTER X "\x{0079}" => "\x79", # LATIN SMALL LETTER Y "\x{007A}" => "\x7A", # LATIN SMALL LETTER Z "\x{000C}" => "\x1B\x0A", # FORM FEED "\x{005B}" => "\x1B\x3C", # LEFT SQUARE BRACKET "\x{005C}" => "\x1B\x2F", # REVERSE SOLIDUS "\x{005D}" => "\x1B\x3E", # RIGHT SQUARE BRACKET "\x{005E}" => "\x1B\x14", # CIRCUMFLEX ACCENT "\x{007B}" => "\x1B\x28", # LEFT CURLY BRACKET "\x{007C}" => "\x1B\x40", # VERTICAL LINE "\x{007D}" => "\x1B\x29", # RIGHT CURLY BRACKET "\x{007E}" => "\x1B\x3D", # TILDE "\x{00A0}" => "\x1B", # NO-BREAK SPACE "\x{00A1}" => "\x40", # INVERTED EXCLAMATION MARK "\x{00A3}" => "\x01", # POUND SIGN "\x{00A4}" => "\x24", # CURRENCY SIGN "\x{00A5}" => "\x03", # YEN SIGN "\x{00A7}" => "\x5F", # SECTION SIGN "\x{00BF}" => "\x60", # INVERTED QUESTION MARK "\x{00C4}" => "\x5B", # LATIN CAPITAL LETTER A WITH DIAERESIS "\x{00C5}" => "\x0E", # LATIN CAPITAL LETTER A WITH RING ABOVE "\x{00C6}" => "\x1C", # LATIN CAPITAL LETTER AE "\x{00C9}" => "\x1F", # LATIN CAPITAL LETTER E WITH ACUTE "\x{00D1}" => "\x5D", # LATIN CAPITAL LETTER N WITH TILDE "\x{00D6}" => "\x5C", # LATIN CAPITAL LETTER O WITH DIAERESIS "\x{00D8}" => "\x0B", # LATIN CAPITAL LETTER O WITH STROKE "\x{00DC}" => "\x5E", # LATIN CAPITAL LETTER U WITH DIAERESIS "\x{00DF}" => "\x1E", # LATIN SMALL LETTER SHARP S "\x{00E0}" => "\x7F", # LATIN SMALL LETTER A WITH GRAVE "\x{00E4}" => "\x7B", # LATIN SMALL LETTER A WITH DIAERESIS "\x{00E5}" => "\x0F", # LATIN SMALL LETTER A WITH RING ABOVE "\x{00E6}" => "\x1D", # LATIN SMALL LETTER AE "\x{00E7}" => "\x09", # LATIN SMALL LETTER C WITH CEDILLA "\x{00E8}" => "\x04", # LATIN SMALL LETTER E WITH GRAVE "\x{00E9}" => "\x05", # LATIN SMALL LETTER E WITH ACUTE "\x{00EC}" => "\x07", # LATIN SMALL LETTER I WITH GRAVE "\x{00F1}" => "\x7D", # LATIN SMALL LETTER N WITH TILDE "\x{00F2}" => "\x08", # LATIN SMALL LETTER O WITH GRAVE "\x{00F6}" => "\x7C", # LATIN SMALL LETTER O WITH DIAERESIS "\x{00F8}" => "\x0C", # LATIN SMALL LETTER O WITH STROKE "\x{00F9}" => "\x06", # LATIN SMALL LETTER U WITH GRAVE "\x{00FC}" => "\x7E", # LATIN SMALL LETTER U WITH DIAERESIS "\x{0393}" => "\x13", # GREEK CAPITAL LETTER GAMMA "\x{0394}" => "\x10", # GREEK CAPITAL LETTER DELTA "\x{0398}" => "\x19", # GREEK CAPITAL LETTER THETA "\x{039B}" => "\x14", # GREEK CAPITAL LETTER LAMDA "\x{039E}" => "\x1A", # GREEK CAPITAL LETTER XI "\x{03A0}" => "\x16", # GREEK CAPITAL LETTER PI "\x{03A3}" => "\x18", # GREEK CAPITAL LETTER SIGMA "\x{03A6}" => "\x12", # GREEK CAPITAL LETTER PHI "\x{03A8}" => "\x17", # GREEK CAPITAL LETTER PSI "\x{03A9}" => "\x15", # GREEK CAPITAL LETTER OMEGA "\x{20AC}" => "\x1B\x65", # EURO SIGN ); our %GSM2UNI = reverse %UNI2GSM; our $ESC = "\x1b"; our $ATMARK = "\x40"; our $FBCHAR = "\x3F"; our $NBSP = "\x{00A0}"; #define ERR_DECODE_NOMAP "%s \"\\x%02" UVXf "\" does not map to Unicode" sub decode ($$;$) { my ( $obj, $bytes, $chk ) = @_; my $str; while ( length $bytes ) { my $c = substr( $bytes, 0, 1, '' ); my $u; if ( $c eq "\x00" ) { my $c2 = substr( $bytes, 0, 1, '' ); $u = !length $c2 ? $ATMARK : $c2 eq "\x00" ? "\x{0000}" : exists $GSM2UNI{$c2} ? $ATMARK . $GSM2UNI{$c2} : $chk ? croak sprintf( "\\x%02X\\x%02X does not map to Unicode", ord($c), ord($c2) ) : $ATMARK . $FBCHAR; } elsif ( $c eq $ESC ) { my $c2 = substr( $bytes, 0, 1, '' ); $u = exists $GSM2UNI{ $c . $c2 } ? $GSM2UNI{ $c . $c2 } : exists $GSM2UNI{$c2} ? $NBSP . $GSM2UNI{$c2} : $chk ? croak sprintf( "\\x%02X\\x%02X does not map to Unicode", ord($c), ord($c2) ) : $NBSP . $FBCHAR; } else { $u = exists $GSM2UNI{$c} ? $GSM2UNI{$c} : $chk ? ref $chk eq 'CODE' ? $chk->( ord $c ) : croak sprintf( "\\x%02X does not map to Unicode", ord($c) ) : $FBCHAR; } $str .= $u; } $_[1] = $bytes if $chk; return $str; } #define ERR_ENCODE_NOMAP "\"\\x{%04" UVxf "}\" does not map to %s" sub encode($$;$) { my ( $obj, $str, $chk ) = @_; my $bytes; while ( length $str ) { my $u = substr( $str, 0, 1, '' ); my $c; $bytes .= exists $UNI2GSM{$u} ? $UNI2GSM{$u} : $chk ? ref $chk eq 'CODE' ? $chk->( ord($u) ) : croak sprintf( "\\x{%04x} does not map to %s", ord($u), $obj->name ) : $FBCHAR; } $_[1] = $str if $chk; return $bytes; } 1; __END__ =head1 NAME Encode::GSM0338 -- ESTI GSM 03.38 Encoding =head1 SYNOPSIS use Encode qw/encode decode/; $gsm0338 = encode("gsm0338", $utf8); # loads Encode::GSM0338 implicitly $utf8 = decode("gsm0338", $gsm0338); # ditto =head1 DESCRIPTION GSM0338 is for GSM handsets. Though it shares alphanumerals with ASCII, control character ranges and other parts are mapped very differently, mainly to store Greek characters. There are also escape sequences (starting with 0x1B) to cover e.g. the Euro sign. This was once handled by L but because of all those unusual specifications, Encode 2.20 has relocated the support to this module. =head1 NOTES Unlike most other encodings, the following aways croaks on error for any $chk that evaluates to true. $gsm0338 = encode("gsm0338", $utf8 $chk); $utf8 = decode("gsm0338", $gsm0338, $chk); So if you want to check the validity of the encoding, surround the expression with C block as follows; eval { $utf8 = decode("gsm0338", $gsm0338, $chk); }; if ($@){ # handle exception here } =head1 BUGS ESTI GSM 03.38 Encoding itself. Mapping \x00 to '@' causes too much pain everywhere. Its use of \x1b (escape) is also very questionable. Because of those two, the code paging approach used use in ucm-based Encoding SOMETIMES fails so this module was written. =head1 SEE ALSO L =cut PK[[l""5.10.1/Encode/Unicode/UTF7.pmnuW+A# # $Id: UTF7.pm,v 2.4 2006/06/03 20:28:48 dankogai Exp $ # package Encode::Unicode::UTF7; use strict; use warnings; no warnings 'redefine'; use base qw(Encode::Encoding); __PACKAGE__->Define('UTF-7'); our $VERSION = do { my @r = ( q$Revision: 2.4 $ =~ /\d+/g ); sprintf "%d." . "%02d" x $#r, @r }; use MIME::Base64; use Encode; # # Algorithms taken from Unicode::String by Gisle Aas # our $OPTIONAL_DIRECT_CHARS = 1; my $specials = quotemeta "\'(),-./:?"; $OPTIONAL_DIRECT_CHARS and $specials .= quotemeta "!\"#$%&*;<=>@[]^_`{|}"; # \s will not work because it matches U+3000 DEOGRAPHIC SPACE # We use qr/[\n\r\t\ ] instead my $re_asis = qr/(?:[\n\r\t\ A-Za-z0-9$specials])/; my $re_encoded = qr/(?:[^\n\r\t\ A-Za-z0-9$specials])/; my $e_utf16 = find_encoding("UTF-16BE"); sub needs_lines { 1 } sub encode($$;$) { my ( $obj, $str, $chk ) = @_; my $len = length($str); pos($str) = 0; my $bytes = ''; while ( pos($str) < $len ) { if ( $str =~ /\G($re_asis+)/ogc ) { $bytes .= $1; } elsif ( $str =~ /\G($re_encoded+)/ogsc ) { if ( $1 eq "+" ) { $bytes .= "+-"; } else { my $s = $1; my $base64 = encode_base64( $e_utf16->encode($s), '' ); $base64 =~ s/=+$//; $bytes .= "+$base64-"; } } else { die "This should not happen! (pos=" . pos($str) . ")"; } } $_[1] = '' if $chk; return $bytes; } sub decode($$;$) { my ( $obj, $bytes, $chk ) = @_; my $len = length($bytes); my $str = ""; no warnings 'uninitialized'; while ( pos($bytes) < $len ) { if ( $bytes =~ /\G([^+]+)/ogc ) { $str .= $1; } elsif ( $bytes =~ /\G\+-/ogc ) { $str .= "+"; } elsif ( $bytes =~ /\G\+([A-Za-z0-9+\/]+)-?/ogsc ) { my $base64 = $1; my $pad = length($base64) % 4; $base64 .= "=" x ( 4 - $pad ) if $pad; $str .= $e_utf16->decode( decode_base64($base64) ); } elsif ( $bytes =~ /\G\+/ogc ) { $^W and warn "Bad UTF7 data escape"; $str .= "+"; } else { die "This should not happen " . pos($bytes); } } $_[1] = '' if $chk; return $str; } 1; __END__ =head1 NAME Encode::Unicode::UTF7 -- UTF-7 encoding =head1 SYNOPSIS use Encode qw/encode decode/; $utf7 = encode("UTF-7", $utf8); $utf8 = decode("UTF-7", $ucs2); =head1 ABSTRACT This module implements UTF-7 encoding documented in RFC 2152. UTF-7, as its name suggests, is a 7-bit re-encoded version of UTF-16BE. It is designed to be MTA-safe and expected to be a standard way to exchange Unicoded mails via mails. But with the advent of UTF-8 and 8-bit compliant MTAs, UTF-7 is hardly ever used. UTF-7 was not supported by Encode until version 1.95 because of that. But Unicode::String, a module by Gisle Aas which adds Unicode supports to non-utf8-savvy perl did support UTF-7, the UTF-7 support was added so Encode can supersede Unicode::String 100%. =head1 In Practice When you want to encode Unicode for mails and web pages, however, do not use UTF-7 unless you are sure your recipients and readers can handle it. Very few MUAs and WWW Browsers support these days (only Mozilla seems to support one). For general cases, use UTF-8 for message body and MIME-Header for header instead. =head1 SEE ALSO L, L, L RFC 2781 L =cut PK[[hHaa5.10.1/Encode/EBCDIC.pmnuW+Apackage Encode::EBCDIC; use strict; use warnings; use Encode; our $VERSION = do { my @r = ( q$Revision: 2.2 $ =~ /\d+/g ); sprintf "%d." . "%02d" x $#r, @r }; use XSLoader; XSLoader::load( __PACKAGE__, $VERSION ); 1; __END__ =head1 NAME Encode::EBCDIC - EBCDIC Encodings =head1 SYNOPSIS use Encode qw/encode decode/; $posix_bc = encode("posix-bc", $utf8); # loads Encode::EBCDIC implicitly $utf8 = decode("", $posix_bc); # ditto =head1 ABSTRACT This module implements various EBCDIC-Based encodings. Encodings supported are as follows. Canonical Alias Description -------------------------------------------------------------------- cp37 cp500 cp875 cp1026 cp1047 posix-bc =head1 DESCRIPTION To find how to use this module in detail, see L. =head1 SEE ALSO L, L =cut PK[[\5.10.1/Encode/CN/HZ.pmnuW+Apackage Encode::CN::HZ; use strict; use warnings; use utf8 (); use vars qw($VERSION); $VERSION = do { my @r = ( q$Revision: 2.5 $ =~ /\d+/g ); sprintf "%d." . "%02d" x $#r, @r }; use Encode qw(:fallbacks); use base qw(Encode::Encoding); __PACKAGE__->Define('hz'); # HZ is a combination of ASCII and escaped GB, so we implement it # with the GB2312(raw) encoding here. Cf. RFCs 1842 & 1843. # not ported for EBCDIC. Which should be used, "~" or "\x7E"? sub needs_lines { 1 } sub decode ($$;$) { my ( $obj, $str, $chk ) = @_; my $GB = Encode::find_encoding('gb2312-raw'); my $ret = ''; my $in_ascii = 1; # default mode is ASCII. while ( length $str ) { if ($in_ascii) { # ASCII mode if ( $str =~ s/^([\x00-\x7D\x7F]+)// ) { # no '~' => ASCII $ret .= $1; # EBCDIC should need ascii2native, but not ported. } elsif ( $str =~ s/^\x7E\x7E// ) { # escaped tilde $ret .= '~'; } elsif ( $str =~ s/^\x7E\cJ// ) { # '\cJ' == LF in ASCII 1; # no-op } elsif ( $str =~ s/^\x7E\x7B// ) { # '~{' $in_ascii = 0; # to GB } else { # encounters an invalid escape, \x80 or greater last; } } else { # GB mode; the byte ranges are as in RFC 1843. no warnings 'uninitialized'; if ( $str =~ s/^((?:[\x21-\x77][\x21-\x7E])+)// ) { $ret .= $GB->decode( $1, $chk ); } elsif ( $str =~ s/^\x7E\x7D// ) { # '~}' $in_ascii = 1; } else { # invalid last; } } } $_[1] = '' if $chk; # needs_lines guarantees no partial character return $ret; } sub cat_decode { my ( $obj, undef, $src, $pos, $trm, $chk ) = @_; my ( $rdst, $rsrc, $rpos ) = \@_[ 1 .. 3 ]; my $GB = Encode::find_encoding('gb2312-raw'); my $ret = ''; my $in_ascii = 1; # default mode is ASCII. my $ini_pos = pos($$rsrc); substr( $src, 0, $pos ) = ''; my $ini_len = bytes::length($src); # $trm is the first of the pair '~~', then 2nd tilde is to be removed. # XXX: Is better C<$src =~ s/^\x7E// or die if ...>? $src =~ s/^\x7E// if $trm eq "\x7E"; while ( length $src ) { my $now; if ($in_ascii) { # ASCII mode if ( $src =~ s/^([\x00-\x7D\x7F])// ) { # no '~' => ASCII $now = $1; } elsif ( $src =~ s/^\x7E\x7E// ) { # escaped tilde $now = '~'; } elsif ( $src =~ s/^\x7E\cJ// ) { # '\cJ' == LF in ASCII next; } elsif ( $src =~ s/^\x7E\x7B// ) { # '~{' $in_ascii = 0; # to GB next; } else { # encounters an invalid escape, \x80 or greater last; } } else { # GB mode; the byte ranges are as in RFC 1843. if ( $src =~ s/^((?:[\x21-\x77][\x21-\x7F])+)// ) { $now = $GB->decode( $1, $chk ); } elsif ( $src =~ s/^\x7E\x7D// ) { # '~}' $in_ascii = 1; next; } else { # invalid last; } } next if !defined $now; $ret .= $now; if ( $now eq $trm ) { $$rdst .= $ret; $$rpos = $ini_pos + $pos + $ini_len - bytes::length($src); pos($$rsrc) = $ini_pos; return 1; } } $$rdst .= $ret; $$rpos = $ini_pos + $pos + $ini_len - bytes::length($src); pos($$rsrc) = $ini_pos; return ''; # terminator not found } sub encode($$;$) { my ( $obj, $str, $chk ) = @_; my $GB = Encode::find_encoding('gb2312-raw'); my $ret = ''; my $in_ascii = 1; # default mode is ASCII. no warnings 'utf8'; # $str may be malformed UTF8 at the end of a chunk. while ( length $str ) { if ( $str =~ s/^([[:ascii:]]+)// ) { my $tmp = $1; $tmp =~ s/~/~~/g; # escapes tildes if ( !$in_ascii ) { $ret .= "\x7E\x7D"; # '~}' $in_ascii = 1; } $ret .= pack 'a*', $tmp; # remove UTF8 flag. } elsif ( $str =~ s/(.)// ) { my $s = $1; my $tmp = $GB->encode( $s, $chk ); last if !defined $tmp; if ( length $tmp == 2 ) { # maybe a valid GB char (XXX) if ($in_ascii) { $ret .= "\x7E\x7B"; # '~{' $in_ascii = 0; } $ret .= $tmp; } elsif ( length $tmp ) { # maybe FALLBACK in ASCII (XXX) if ( !$in_ascii ) { $ret .= "\x7E\x7D"; # '~}' $in_ascii = 1; } $ret .= $tmp; } } else { # if $str is malformed UTF8 *and* if length $str != 0. last; } } $_[1] = $str if $chk; # The state at the end of the chunk is discarded, even if in GB mode. # That results in the combination of GB-OUT and GB-IN, i.e. "~}~{". # Parhaps it is harmless, but further investigations may be required... if ( !$in_ascii ) { $ret .= "\x7E\x7D"; # '~}' $in_ascii = 1; } utf8::encode($ret); # https://rt.cpan.org/Ticket/Display.html?id=35120 return $ret; } 1; __END__ =head1 NAME Encode::CN::HZ -- internally used by Encode::CN =cut PK[[{45.10.1/Encode/JP/H2Z.pmnuW+A# # $Id: H2Z.pm,v 2.2 2006/06/03 20:28:48 dankogai Exp $ # package Encode::JP::H2Z; use strict; use warnings; our $RCSID = q$Id: H2Z.pm,v 2.2 2006/06/03 20:28:48 dankogai Exp $; our $VERSION = do { my @r = ( q$Revision: 2.2 $ =~ /\d+/g ); sprintf "%d." . "%02d" x $#r, @r }; use Encode::CJKConstants qw(:all); use vars qw(%_D2Z $_PAT_D2Z %_Z2D $_PAT_Z2D %_H2Z $_PAT_H2Z %_Z2H $_PAT_Z2H); %_H2Z = ( "\x8e\xa1" => "\xa1\xa3", # "\x8e\xa2" => "\xa1\xd6", # "\x8e\xa3" => "\xa1\xd7", # "\x8e\xa4" => "\xa1\xa2", # "\x8e\xa5" => "\xa1\xa6", # "\x8e\xa6" => "\xa5\xf2", # "\x8e\xa7" => "\xa5\xa1", # "\x8e\xa8" => "\xa5\xa3", # "\x8e\xa9" => "\xa5\xa5", # "\x8e\xaa" => "\xa5\xa7", # "\x8e\xab" => "\xa5\xa9", # "\x8e\xac" => "\xa5\xe3", # "\x8e\xad" => "\xa5\xe5", # "\x8e\xae" => "\xa5\xe7", # "\x8e\xaf" => "\xa5\xc3", # "\x8e\xb0" => "\xa1\xbc", # "\x8e\xb1" => "\xa5\xa2", # "\x8e\xb2" => "\xa5\xa4", # "\x8e\xb3" => "\xa5\xa6", # "\x8e\xb4" => "\xa5\xa8", # "\x8e\xb5" => "\xa5\xaa", # "\x8e\xb6" => "\xa5\xab", # "\x8e\xb7" => "\xa5\xad", # "\x8e\xb8" => "\xa5\xaf", # "\x8e\xb9" => "\xa5\xb1", # "\x8e\xba" => "\xa5\xb3", # "\x8e\xbb" => "\xa5\xb5", # "\x8e\xbc" => "\xa5\xb7", # "\x8e\xbd" => "\xa5\xb9", # "\x8e\xbe" => "\xa5\xbb", # "\x8e\xbf" => "\xa5\xbd", # "\x8e\xc0" => "\xa5\xbf", # "\x8e\xc1" => "\xa5\xc1", # "\x8e\xc2" => "\xa5\xc4", # "\x8e\xc3" => "\xa5\xc6", # "\x8e\xc4" => "\xa5\xc8", # "\x8e\xc5" => "\xa5\xca", # "\x8e\xc6" => "\xa5\xcb", # "\x8e\xc7" => "\xa5\xcc", # "\x8e\xc8" => "\xa5\xcd", # "\x8e\xc9" => "\xa5\xce", # "\x8e\xca" => "\xa5\xcf", # "\x8e\xcb" => "\xa5\xd2", # "\x8e\xcc" => "\xa5\xd5", # "\x8e\xcd" => "\xa5\xd8", # "\x8e\xce" => "\xa5\xdb", # "\x8e\xcf" => "\xa5\xde", # "\x8e\xd0" => "\xa5\xdf", # "\x8e\xd1" => "\xa5\xe0", # "\x8e\xd2" => "\xa5\xe1", # "\x8e\xd3" => "\xa5\xe2", # "\x8e\xd4" => "\xa5\xe4", # "\x8e\xd5" => "\xa5\xe6", # "\x8e\xd6" => "\xa5\xe8", # "\x8e\xd7" => "\xa5\xe9", # "\x8e\xd8" => "\xa5\xea", # "\x8e\xd9" => "\xa5\xeb", # "\x8e\xda" => "\xa5\xec", # "\x8e\xdb" => "\xa5\xed", # "\x8e\xdc" => "\xa5\xef", # "\x8e\xdd" => "\xa5\xf3", # "\x8e\xde" => "\xa1\xab", # "\x8e\xdf" => "\xa1\xac", # ); %_D2Z = ( "\x8e\xb6\x8e\xde" => "\xa5\xac", # "\x8e\xb7\x8e\xde" => "\xa5\xae", # "\x8e\xb8\x8e\xde" => "\xa5\xb0", # "\x8e\xb9\x8e\xde" => "\xa5\xb2", # "\x8e\xba\x8e\xde" => "\xa5\xb4", # "\x8e\xbb\x8e\xde" => "\xa5\xb6", # "\x8e\xbc\x8e\xde" => "\xa5\xb8", # "\x8e\xbd\x8e\xde" => "\xa5\xba", # "\x8e\xbe\x8e\xde" => "\xa5\xbc", # "\x8e\xbf\x8e\xde" => "\xa5\xbe", # "\x8e\xc0\x8e\xde" => "\xa5\xc0", # "\x8e\xc1\x8e\xde" => "\xa5\xc2", # "\x8e\xc2\x8e\xde" => "\xa5\xc5", # "\x8e\xc3\x8e\xde" => "\xa5\xc7", # "\x8e\xc4\x8e\xde" => "\xa5\xc9", # "\x8e\xca\x8e\xde" => "\xa5\xd0", # "\x8e\xcb\x8e\xde" => "\xa5\xd3", # "\x8e\xcc\x8e\xde" => "\xa5\xd6", # "\x8e\xcd\x8e\xde" => "\xa5\xd9", # "\x8e\xce\x8e\xde" => "\xa5\xdc", # "\x8e\xca\x8e\xdf" => "\xa5\xd1", # "\x8e\xcb\x8e\xdf" => "\xa5\xd4", # "\x8e\xcc\x8e\xdf" => "\xa5\xd7", # "\x8e\xcd\x8e\xdf" => "\xa5\xda", # "\x8e\xce\x8e\xdf" => "\xa5\xdd", # "\x8e\xb3\x8e\xde" => "\xa5\xf4", # ); # init only once; #$_PAT_D2Z = join("|", keys %_D2Z); #$_PAT_H2Z = join("|", keys %_H2Z); %_Z2H = reverse %_H2Z; %_Z2D = reverse %_D2Z; #$_PAT_Z2H = join("|", keys %_Z2H); #$_PAT_Z2D = join("|", keys %_Z2D); sub h2z { no warnings qw(uninitialized); my $r_str = shift; my ($keep_dakuten) = @_; my $n = 0; unless ($keep_dakuten) { $n = ( $$r_str =~ s( ($RE{EUC_KANA} (?:\x8e[\xde\xdf])?) ){ my $str = $1; $_D2Z{$str} || $_H2Z{$str} || # in case dakuten and handakuten are side-by-side! $_H2Z{substr($str,0,2)} . $_H2Z{substr($str,2,2)}; }eogx ); } else { $n = ( $$r_str =~ s( ($RE{EUC_KANA}) ){ $_H2Z{$1}; }eogx ); } $n; } sub z2h { my $r_str = shift; my $n = ( $$r_str =~ s( ($RE{EUC_C}|$RE{EUC_0212}|$RE{EUC_KANA}) ){ $_Z2D{$1} || $_Z2H{$1} || $1; }eogx ); $n; } 1; __END__ =head1 NAME Encode::JP::H2Z -- internally used by Encode::JP::2022_JP* =cut PK[[6995.10.1/Encode/JP/JIS7.pmnuW+Apackage Encode::JP::JIS7; use strict; use warnings; our $VERSION = do { my @r = ( q$Revision: 2.4 $ =~ /\d+/g ); sprintf "%d." . "%02d" x $#r, @r }; use Encode qw(:fallbacks); for my $name ( '7bit-jis', 'iso-2022-jp', 'iso-2022-jp-1' ) { my $h2z = ( $name eq '7bit-jis' ) ? 0 : 1; my $jis0212 = ( $name eq 'iso-2022-jp' ) ? 0 : 1; $Encode::Encoding{$name} = bless { Name => $name, h2z => $h2z, jis0212 => $jis0212, } => __PACKAGE__; } use base qw(Encode::Encoding); # we override this to 1 so PerlIO works sub needs_lines { 1 } use Encode::CJKConstants qw(:all); # # decode is identical for all 2022 variants # sub decode($$;$) { my ( $obj, $str, $chk ) = @_; my $residue = ''; if ($chk) { $str =~ s/([^\x00-\x7f].*)$//so and $residue = $1; } $residue .= jis_euc( \$str ); $_[1] = $residue if $chk; return Encode::decode( 'euc-jp', $str, FB_PERLQQ ); } # # encode is different # sub encode($$;$) { require Encode::JP::H2Z; my ( $obj, $utf8, $chk ) = @_; # empty the input string in the stack so perlio is ok $_[1] = '' if $chk; my ( $h2z, $jis0212 ) = @$obj{qw(h2z jis0212)}; my $octet = Encode::encode( 'euc-jp', $utf8, $chk ); $h2z and &Encode::JP::H2Z::h2z( \$octet ); euc_jis( \$octet, $jis0212 ); return $octet; } # # cat_decode # my $re_scan_jis_g = qr{ \G ( ($RE{JIS_0212}) | $RE{JIS_0208} | ($RE{ISO_ASC}) | ($RE{JIS_KANA}) | ) ([^\e]*) }x; sub cat_decode { # ($obj, $dst, $src, $pos, $trm, $chk) my ( $obj, undef, undef, $pos, $trm ) = @_; # currently ignores $chk my ( $rdst, $rsrc, $rpos ) = \@_[ 1, 2, 3 ]; local ${^ENCODING}; use bytes; my $opos = pos($$rsrc); pos($$rsrc) = $pos; while ( $$rsrc =~ /$re_scan_jis_g/gc ) { my ( $esc, $esc_0212, $esc_asc, $esc_kana, $chunk ) = ( $1, $2, $3, $4, $5 ); unless ($chunk) { $esc or last; next; } if ( $esc && !$esc_asc ) { $chunk =~ tr/\x21-\x7e/\xa1-\xfe/; if ($esc_kana) { $chunk =~ s/([\xa1-\xdf])/\x8e$1/og; } elsif ($esc_0212) { $chunk =~ s/([\xa1-\xfe][\xa1-\xfe])/\x8f$1/og; } $chunk = Encode::decode( 'euc-jp', $chunk, 0 ); } elsif ( ( my $npos = index( $chunk, $trm ) ) >= 0 ) { $$rdst .= substr( $chunk, 0, $npos + length($trm) ); $$rpos += length($esc) + $npos + length($trm); pos($$rsrc) = $opos; return 1; } $$rdst .= $chunk; $$rpos = pos($$rsrc); } $$rpos = pos($$rsrc); pos($$rsrc) = $opos; return ''; } # JIS<->EUC my $re_scan_jis = qr{ (?:($RE{JIS_0212})|$RE{JIS_0208}|($RE{ISO_ASC})|($RE{JIS_KANA}))([^\e]*) }x; sub jis_euc { local ${^ENCODING}; my $r_str = shift; $$r_str =~ s($re_scan_jis) { my ($esc_0212, $esc_asc, $esc_kana, $chunk) = ($1, $2, $3, $4); if (!$esc_asc) { $chunk =~ tr/\x21-\x7e/\xa1-\xfe/; if ($esc_kana) { $chunk =~ s/([\xa1-\xdf])/\x8e$1/og; } elsif ($esc_0212) { $chunk =~ s/([\xa1-\xfe][\xa1-\xfe])/\x8f$1/og; } } $chunk; }geox; my ($residue) = ( $$r_str =~ s/(\e.*)$//so ); return $residue; } sub euc_jis { no warnings qw(uninitialized); local ${^ENCODING}; my $r_str = shift; my $jis0212 = shift; $$r_str =~ s{ ((?:$RE{EUC_C})+|(?:$RE{EUC_KANA})+|(?:$RE{EUC_0212})+) }{ my $chunk = $1; my $esc = ( $chunk =~ tr/\x8E//d ) ? $ESC{KANA} : ( $chunk =~ tr/\x8F//d ) ? $ESC{JIS_0212} : $ESC{JIS_0208}; if ($esc eq $ESC{JIS_0212} && !$jis0212){ # fallback to '?' $chunk =~ tr/\xA1-\xFE/\x3F/; }else{ $chunk =~ tr/\xA1-\xFE/\x21-\x7E/; } $esc . $chunk . $ESC{ASC}; }geox; $$r_str =~ s/\Q$ESC{ASC}\E (\Q$ESC{KANA}\E|\Q$ESC{JIS_0212}\E|\Q$ESC{JIS_0208}\E)/$1/gox; $$r_str; } 1; __END__ =head1 NAME Encode::JP::JIS7 -- internally used by Encode::JP =cut PK[[O15.10.1/Encode/Config.pmnuW+A# # Demand-load module list # package Encode::Config; our $VERSION = do { my @r = ( q$Revision: 2.5 $ =~ /\d+/g ); sprintf "%d." . "%02d" x $#r, @r }; use strict; use warnings; our %ExtModule = ( # Encode::Byte #iso-8859-1 is in Encode.pm itself 'iso-8859-2' => 'Encode::Byte', 'iso-8859-3' => 'Encode::Byte', 'iso-8859-4' => 'Encode::Byte', 'iso-8859-5' => 'Encode::Byte', 'iso-8859-6' => 'Encode::Byte', 'iso-8859-7' => 'Encode::Byte', 'iso-8859-8' => 'Encode::Byte', 'iso-8859-9' => 'Encode::Byte', 'iso-8859-10' => 'Encode::Byte', 'iso-8859-11' => 'Encode::Byte', 'iso-8859-13' => 'Encode::Byte', 'iso-8859-14' => 'Encode::Byte', 'iso-8859-15' => 'Encode::Byte', 'iso-8859-16' => 'Encode::Byte', 'koi8-f' => 'Encode::Byte', 'koi8-r' => 'Encode::Byte', 'koi8-u' => 'Encode::Byte', 'viscii' => 'Encode::Byte', 'cp424' => 'Encode::Byte', 'cp437' => 'Encode::Byte', 'cp737' => 'Encode::Byte', 'cp775' => 'Encode::Byte', 'cp850' => 'Encode::Byte', 'cp852' => 'Encode::Byte', 'cp855' => 'Encode::Byte', 'cp856' => 'Encode::Byte', 'cp857' => 'Encode::Byte', 'cp858' => 'Encode::Byte', 'cp860' => 'Encode::Byte', 'cp861' => 'Encode::Byte', 'cp862' => 'Encode::Byte', 'cp863' => 'Encode::Byte', 'cp864' => 'Encode::Byte', 'cp865' => 'Encode::Byte', 'cp866' => 'Encode::Byte', 'cp869' => 'Encode::Byte', 'cp874' => 'Encode::Byte', 'cp1006' => 'Encode::Byte', 'cp1250' => 'Encode::Byte', 'cp1251' => 'Encode::Byte', 'cp1252' => 'Encode::Byte', 'cp1253' => 'Encode::Byte', 'cp1254' => 'Encode::Byte', 'cp1255' => 'Encode::Byte', 'cp1256' => 'Encode::Byte', 'cp1257' => 'Encode::Byte', 'cp1258' => 'Encode::Byte', 'AdobeStandardEncoding' => 'Encode::Byte', 'MacArabic' => 'Encode::Byte', 'MacCentralEurRoman' => 'Encode::Byte', 'MacCroatian' => 'Encode::Byte', 'MacCyrillic' => 'Encode::Byte', 'MacFarsi' => 'Encode::Byte', 'MacGreek' => 'Encode::Byte', 'MacHebrew' => 'Encode::Byte', 'MacIcelandic' => 'Encode::Byte', 'MacRoman' => 'Encode::Byte', 'MacRomanian' => 'Encode::Byte', 'MacRumanian' => 'Encode::Byte', 'MacSami' => 'Encode::Byte', 'MacThai' => 'Encode::Byte', 'MacTurkish' => 'Encode::Byte', 'MacUkrainian' => 'Encode::Byte', 'nextstep' => 'Encode::Byte', 'hp-roman8' => 'Encode::Byte', #'gsm0338' => 'Encode::Byte', 'gsm0338' => 'Encode::GSM0338', # Encode::EBCDIC 'cp37' => 'Encode::EBCDIC', 'cp500' => 'Encode::EBCDIC', 'cp875' => 'Encode::EBCDIC', 'cp1026' => 'Encode::EBCDIC', 'cp1047' => 'Encode::EBCDIC', 'posix-bc' => 'Encode::EBCDIC', # Encode::Symbol 'dingbats' => 'Encode::Symbol', 'symbol' => 'Encode::Symbol', 'AdobeSymbol' => 'Encode::Symbol', 'AdobeZdingbat' => 'Encode::Symbol', 'MacDingbats' => 'Encode::Symbol', 'MacSymbol' => 'Encode::Symbol', # Encode::Unicode 'UCS-2BE' => 'Encode::Unicode', 'UCS-2LE' => 'Encode::Unicode', 'UTF-16' => 'Encode::Unicode', 'UTF-16BE' => 'Encode::Unicode', 'UTF-16LE' => 'Encode::Unicode', 'UTF-32' => 'Encode::Unicode', 'UTF-32BE' => 'Encode::Unicode', 'UTF-32LE' => 'Encode::Unicode', 'UTF-7' => 'Encode::Unicode::UTF7', ); unless ( ord("A") == 193 ) { %ExtModule = ( %ExtModule, 'euc-cn' => 'Encode::CN', 'gb12345-raw' => 'Encode::CN', 'gb2312-raw' => 'Encode::CN', 'hz' => 'Encode::CN', 'iso-ir-165' => 'Encode::CN', 'cp936' => 'Encode::CN', 'MacChineseSimp' => 'Encode::CN', '7bit-jis' => 'Encode::JP', 'euc-jp' => 'Encode::JP', 'iso-2022-jp' => 'Encode::JP', 'iso-2022-jp-1' => 'Encode::JP', 'jis0201-raw' => 'Encode::JP', 'jis0208-raw' => 'Encode::JP', 'jis0212-raw' => 'Encode::JP', 'cp932' => 'Encode::JP', 'MacJapanese' => 'Encode::JP', 'shiftjis' => 'Encode::JP', 'euc-kr' => 'Encode::KR', 'iso-2022-kr' => 'Encode::KR', 'johab' => 'Encode::KR', 'ksc5601-raw' => 'Encode::KR', 'cp949' => 'Encode::KR', 'MacKorean' => 'Encode::KR', 'big5-eten' => 'Encode::TW', 'big5-hkscs' => 'Encode::TW', 'cp950' => 'Encode::TW', 'MacChineseTrad' => 'Encode::TW', #'big5plus' => 'Encode::HanExtra', #'euc-tw' => 'Encode::HanExtra', #'gb18030' => 'Encode::HanExtra', 'MIME-Header' => 'Encode::MIME::Header', 'MIME-B' => 'Encode::MIME::Header', 'MIME-Q' => 'Encode::MIME::Header', 'MIME-Header-ISO_2022_JP' => 'Encode::MIME::Header::ISO_2022_JP', ); } # # Why not export ? to keep ConfigLocal Happy! # while ( my ( $enc, $mod ) = each %ExtModule ) { $Encode::ExtModule{$enc} = $mod; } 1; __END__ =head1 NAME Encode::Config -- internally used by Encode =cut PK[[s 5.10.1/Encode/JP.pmnuW+Apackage Encode::JP; BEGIN { if ( ord("A") == 193 ) { die "Encode::JP not supported on EBCDIC\n"; } } use strict; use warnings; use Encode; our $VERSION = do { my @r = ( q$Revision: 2.3 $ =~ /\d+/g ); sprintf "%d." . "%02d" x $#r, @r }; use XSLoader; XSLoader::load( __PACKAGE__, $VERSION ); use Encode::JP::JIS7; 1; __END__ =head1 NAME Encode::JP - Japanese Encodings =head1 SYNOPSIS use Encode qw/encode decode/; $euc_jp = encode("euc-jp", $utf8); # loads Encode::JP implicitly $utf8 = decode("euc-jp", $euc_jp); # ditto =head1 ABSTRACT This module implements Japanese charset encodings. Encodings supported are as follows. Canonical Alias Description -------------------------------------------------------------------- euc-jp /\beuc.*jp$/i EUC (Extended Unix Character) /\bjp.*euc/i /\bujis$/i shiftjis /\bshift.*jis$/i Shift JIS (aka MS Kanji) /\bsjis$/i 7bit-jis /\bjis$/i 7bit JIS iso-2022-jp ISO-2022-JP [RFC1468] = 7bit JIS with all Halfwidth Kana converted to Fullwidth iso-2022-jp-1 ISO-2022-JP-1 [RFC2237] = ISO-2022-JP with JIS X 0212-1990 support. See below MacJapanese Shift JIS + Apple vendor mappings cp932 /\bwindows-31j$/i Code Page 932 = Shift JIS + MS/IBM vendor mappings jis0201-raw JIS0201, raw format jis0208-raw JIS0201, raw format jis0212-raw JIS0201, raw format -------------------------------------------------------------------- =head1 DESCRIPTION To find out how to use this module in detail, see L. =head1 Note on ISO-2022-JP(-1)? ISO-2022-JP-1 (RFC2237) is a superset of ISO-2022-JP (RFC1468) which adds support for JIS X 0212-1990. That means you can use the same code to decode to utf8 but not vice versa. $utf8 = decode('iso-2022-jp-1', $stream); and $utf8 = decode('iso-2022-jp', $stream); yield the same result but $with_0212 = encode('iso-2022-jp-1', $utf8); is now different from $without_0212 = encode('iso-2022-jp', $utf8 ); In the latter case, characters that map to 0212 are first converted to U+3013 (0xA2AE in EUC-JP; a white square also known as 'Tofu' or 'geta mark') then fed to the decoding engine. U+FFFD is not used, in order to preserve text layout as much as possible. =head1 BUGS The ASCII region (0x00-0x7f) is preserved for all encodings, even though this conflicts with mappings by the Unicode Consortium. See L to find out why it is implemented that way. =head1 SEE ALSO L =cut PK[[`̡! ! (5.10.1/Encode/MIME/Header/ISO_2022_JP.pmnuW+Apackage Encode::MIME::Header::ISO_2022_JP; use strict; use warnings; use base qw(Encode::MIME::Header); $Encode::Encoding{'MIME-Header-ISO_2022_JP'} = bless { encode => 'B', bpl => 76, Name => 'MIME-Header-ISO_2022_JP' } => __PACKAGE__; use constant HEAD => '=?ISO-2022-JP?B?'; use constant TAIL => '?='; use Encode::CJKConstants qw(%RE); our $VERSION = do { my @r = ( q$Revision: 1.3 $ =~ /\d+/g ); sprintf "%d." . "%02d" x $#r, @r }; # I owe the below codes totally to # Jcode by Dan Kogai & http://www.din.or.jp/~ohzaki/perl.htm#JP_Base64 sub encode { my $self = shift; my $str = shift; utf8::encode($str) if ( Encode::is_utf8($str) ); Encode::from_to( $str, 'utf8', 'euc-jp' ); my ($trailing_crlf) = ( $str =~ /(\n|\r|\x0d\x0a)$/o ); $str = _mime_unstructured_header( $str, $self->{bpl} ); not $trailing_crlf and $str =~ s/(\n|\r|\x0d\x0a)$//o; return $str; } sub _mime_unstructured_header { my ( $oldheader, $bpl ) = @_; my $crlf = $oldheader =~ /\n$/; my ( $header, @words, @wordstmp, $i ) = (''); $oldheader =~ s/\s+$//; @wordstmp = split /\s+/, $oldheader; for ( $i = 0 ; $i < $#wordstmp ; $i++ ) { if ( $wordstmp[$i] !~ /^[\x21-\x7E]+$/ and $wordstmp[ $i + 1 ] !~ /^[\x21-\x7E]+$/ ) { $wordstmp[ $i + 1 ] = "$wordstmp[$i] $wordstmp[$i + 1]"; } else { push( @words, $wordstmp[$i] ); } } push( @words, $wordstmp[-1] ); for my $word (@words) { if ( $word =~ /^[\x21-\x7E]+$/ ) { $header =~ /(?:.*\n)*(.*)/; if ( length($1) + length($word) > $bpl ) { $header .= "\n $word"; } else { $header .= $word; } } else { $header = _add_encoded_word( $word, $header, $bpl ); } $header =~ /(?:.*\n)*(.*)/; if ( length($1) == $bpl ) { $header .= "\n "; } else { $header .= ' '; } } $header =~ s/\n? $//mg; $crlf ? "$header\n" : $header; } sub _add_encoded_word { my ( $str, $line, $bpl ) = @_; my $result = ''; while ( length($str) ) { my $target = $str; $str = ''; if ( length($line) + 22 + ( $target =~ /^(?:$RE{EUC_0212}|$RE{EUC_C})/o ) * 8 > $bpl ) { $line =~ s/[ \t\n\r]*$/\n/; $result .= $line; $line = ' '; } while (1) { my $iso_2022_jp = $target; Encode::from_to( $iso_2022_jp, 'euc-jp', 'iso-2022-jp' ); my $encoded = HEAD . MIME::Base64::encode_base64( $iso_2022_jp, '' ) . TAIL; if ( length($encoded) + length($line) > $bpl ) { $target =~ s/($RE{EUC_0212}|$RE{EUC_KANA}|$RE{EUC_C}|$RE{ASCII})$//o; $str = $1 . $str; } else { $line .= $encoded; last; } } } $result . $line; } 1; __END__ PK[[կr5.10.1/Encode/MIME/Header.pmnuW+Apackage Encode::MIME::Header; use strict; use warnings; no warnings 'redefine'; our $VERSION = do { my @r = ( q$Revision: 2.11 $ =~ /\d+/g ); sprintf "%d." . "%02d" x $#r, @r }; use Encode qw(find_encoding encode_utf8 decode_utf8); use MIME::Base64; use Carp; my %seed = ( decode_b => '1', # decodes 'B' encoding ? decode_q => '1', # decodes 'Q' encoding ? encode => 'B', # encode with 'B' or 'Q' ? bpl => 75, # bytes per line ); $Encode::Encoding{'MIME-Header'} = bless { %seed, Name => 'MIME-Header', } => __PACKAGE__; $Encode::Encoding{'MIME-B'} = bless { %seed, decode_q => 0, Name => 'MIME-B', } => __PACKAGE__; $Encode::Encoding{'MIME-Q'} = bless { %seed, decode_q => 1, encode => 'Q', Name => 'MIME-Q', } => __PACKAGE__; use base qw(Encode::Encoding); sub needs_lines { 1 } sub perlio_ok { 0 } sub decode($$;$) { use utf8; my ( $obj, $str, $chk ) = @_; # zap spaces between encoded words $str =~ s/\?=\s+=\?/\?==\?/gos; # multi-line header to single line $str =~ s/(?:\r\n|[\r\n])[ \t]//gos; 1 while ( $str =~ s/(=\?[-0-9A-Za-z_]+\?[Qq]\?)(.*?)\?=\1(.*?\?=)/$1$2$3/ ) ; # Concat consecutive QP encoded mime headers # Fixes breaking inside multi-byte characters $str =~ s{ =\? # begin encoded word ([-0-9A-Za-z_]+) # charset (encoding) (?:\*[A-Za-z]{1,8}(?:-[A-Za-z]{1,8})*)? # language (RFC 2231) \?([QqBb])\? # delimiter (.*?) # Base64-encodede contents \?= # end encoded word }{ if (uc($2) eq 'B'){ $obj->{decode_b} or croak qq(MIME "B" unsupported); decode_b($1, $3, $chk); } elsif (uc($2) eq 'Q'){ $obj->{decode_q} or croak qq(MIME "Q" unsupported); decode_q($1, $3, $chk); } else { croak qq(MIME "$2" encoding is nonexistent!); } }egox; $_[1] = $str if $chk; return $str; } sub decode_b { my $enc = shift; my $d = find_encoding($enc) or croak qq(Unknown encoding "$enc"); my $db64 = decode_base64(shift); my $chk = shift; return $d->name eq 'utf8' ? Encode::decode_utf8($db64) : $d->decode( $db64, $chk || Encode::FB_PERLQQ ); } sub decode_q { my ( $enc, $q, $chk ) = @_; my $d = find_encoding($enc) or croak qq(Unknown encoding "$enc"); $q =~ s/_/ /go; $q =~ s/=([0-9A-Fa-f]{2})/pack("C", hex($1))/ego; return $d->name eq 'utf8' ? Encode::decode_utf8($q) : $d->decode( $q, $chk || Encode::FB_PERLQQ ); } my $especials = join( '|' => map { quotemeta( chr($_) ) } unpack( "C*", qq{()<>@,;:"'/[]?.=} ) ); my $re_encoded_word = qr{ =\? # begin encoded word (?:[-0-9A-Za-z_]+) # charset (encoding) (?:\*[A-Za-z]{1,8}(?:-[A-Za-z]{1,8})*)? # language (RFC 2231) \?(?:[QqBb])\? # delimiter (?:.*?) # Base64-encodede contents \?= # end encoded word }xo; my $re_especials = qr{$re_encoded_word|$especials}xo; sub encode($$;$) { my ( $obj, $str, $chk ) = @_; my @line = (); for my $line ( split /\r\n|[\r\n]/o, $str ) { my ( @word, @subline ); for my $word ( split /($re_especials)/o, $line ) { if ( $word =~ /[^\x00-\x7f]/o or $word =~ /^$re_encoded_word$/o ) { push @word, $obj->_encode($word); } else { push @word, $word; } } my $subline = ''; for my $word (@word) { use bytes (); if ( bytes::length($subline) + bytes::length($word) > $obj->{bpl} ) { push @subline, $subline; $subline = ''; } $subline .= $word; } $subline and push @subline, $subline; push @line, join( "\n " => @subline ); } $_[1] = '' if $chk; return join( "\n", @line ); } use constant HEAD => '=?UTF-8?'; use constant TAIL => '?='; use constant SINGLE => { B => \&_encode_b, Q => \&_encode_q, }; sub _encode { my ( $o, $str ) = @_; my $enc = $o->{encode}; my $llen = ( $o->{bpl} - length(HEAD) - 2 - length(TAIL) ); # to coerce a floating-point arithmetics, the following contains # .0 in numbers -- dankogai $llen *= $enc eq 'B' ? 3.0 / 4.0 : 1.0 / 3.0; my @result = (); my $chunk = ''; while ( length( my $chr = substr( $str, 0, 1, '' ) ) ) { use bytes (); if ( bytes::length($chunk) + bytes::length($chr) > $llen ) { push @result, SINGLE->{$enc}($chunk); $chunk = ''; } $chunk .= $chr; } length($chunk) and push @result, SINGLE->{$enc}($chunk); return @result; } sub _encode_b { HEAD . 'B?' . encode_base64( encode_utf8(shift), '' ) . TAIL; } sub _encode_q { my $chunk = shift; $chunk = encode_utf8($chunk); $chunk =~ s{ ([^0-9A-Za-z]) }{ join("" => map {sprintf "=%02X", $_} unpack("C*", $1)) }egox; return HEAD . 'Q?' . $chunk . TAIL; } 1; __END__ =head1 NAME Encode::MIME::Header -- MIME 'B' and 'Q' header encoding =head1 SYNOPSIS use Encode qw/encode decode/; $utf8 = decode('MIME-Header', $header); $header = encode('MIME-Header', $utf8); =head1 ABSTRACT This module implements RFC 2047 Mime Header Encoding. There are 3 variant encoding names; C, C and C. The difference is described below decode() encode() ---------------------------------------------- MIME-Header Both B and Q =?UTF-8?B?....?= MIME-B B only; Q croaks =?UTF-8?B?....?= MIME-Q Q only; B croaks =?UTF-8?Q?....?= =head1 DESCRIPTION When you decode(=?I?I?I?=), I is extracted and decoded for I encoding (B for Base64, Q for Quoted-Printable). Then the decoded chunk is fed to decode(I). So long as I is supported by Encode, any source encoding is fine. When you encode, it just encodes UTF-8 string with I encoding then quoted with =?UTF-8?I?....?= . The parts that RFC 2047 forbids to encode are left as is and long lines are folded within 76 bytes per line. =head1 BUGS It would be nice to support encoding to non-UTF8, such as =?ISO-2022-JP? and =?ISO-8859-1?= but that makes the implementation too complicated. These days major mail agents all support =?UTF-8? so I think it is just good enough. Due to popular demand, 'MIME-Header-ISO_2022_JP' was introduced by Makamaka. Thre are still too many MUAs especially cellular phone handsets which does not grok UTF-8. =head1 SEE ALSO L RFC 2047, L and many other locations. =cut PK[[#^ 5.10.1/Encode/MIME/Name.pmnuW+Apackage Encode::MIME::Name; use strict; use warnings; our $VERSION = do { my @r = ( q$Revision: 1.1 $ =~ /\d+/g ); sprintf "%d." . "%02d" x $#r, @r }; our %MIME_NAME_OF = ( 'AdobeStandardEncoding' => 'Adobe-Standard-Encoding', 'AdobeSymbol' => 'Adobe-Symbol-Encoding', 'ascii' => 'US-ASCII', 'big5-hkscs' => 'Big5-HKSCS', 'cp1026' => 'IBM1026', 'cp1047' => 'IBM1047', 'cp1250' => 'windows-1250', 'cp1251' => 'windows-1251', 'cp1252' => 'windows-1252', 'cp1253' => 'windows-1253', 'cp1254' => 'windows-1254', 'cp1255' => 'windows-1255', 'cp1256' => 'windows-1256', 'cp1257' => 'windows-1257', 'cp1258' => 'windows-1258', 'cp37' => 'IBM037', 'cp424' => 'IBM424', 'cp437' => 'IBM437', 'cp500' => 'IBM500', 'cp775' => 'IBM775', 'cp850' => 'IBM850', 'cp852' => 'IBM852', 'cp855' => 'IBM855', 'cp857' => 'IBM857', 'cp860' => 'IBM860', 'cp861' => 'IBM861', 'cp862' => 'IBM862', 'cp863' => 'IBM863', 'cp864' => 'IBM864', 'cp865' => 'IBM865', 'cp866' => 'IBM866', 'cp869' => 'IBM869', 'cp936' => 'GBK', 'euc-jp' => 'EUC-JP', 'euc-kr' => 'EUC-KR', #'gb2312-raw' => 'GB2312', # no, you're wrong, I18N::Charset 'hp-roman8' => 'hp-roman8', 'hz' => 'HZ-GB-2312', 'iso-2022-jp' => 'ISO-2022-JP', 'iso-2022-jp-1' => 'ISO-2022-JP', 'iso-2022-kr' => 'ISO-2022-KR', 'iso-8859-1' => 'ISO-8859-1', 'iso-8859-10' => 'ISO-8859-10', 'iso-8859-13' => 'ISO-8859-13', 'iso-8859-14' => 'ISO-8859-14', 'iso-8859-15' => 'ISO-8859-15', 'iso-8859-16' => 'ISO-8859-16', 'iso-8859-2' => 'ISO-8859-2', 'iso-8859-3' => 'ISO-8859-3', 'iso-8859-4' => 'ISO-8859-4', 'iso-8859-5' => 'ISO-8859-5', 'iso-8859-6' => 'ISO-8859-6', 'iso-8859-7' => 'ISO-8859-7', 'iso-8859-8' => 'ISO-8859-8', 'iso-8859-9' => 'ISO-8859-9', #'jis0201-raw' => 'JIS_X0201', #'jis0208-raw' => 'JIS_C6226-1983', #'jis0212-raw' => 'JIS_X0212-1990', 'koi8-r' => 'KOI8-R', 'koi8-u' => 'KOI8-U', #'ksc5601-raw' => 'KS_C_5601-1987', 'shiftjis' => 'Shift_JIS', 'UTF-16' => 'UTF-16', 'UTF-16BE' => 'UTF-16BE', 'UTF-16LE' => 'UTF-16LE', 'UTF-32' => 'UTF-32', 'UTF-32BE' => 'UTF-32BE', 'UTF-32LE' => 'UTF-32LE', 'UTF-7' => 'UTF-7', 'utf8' => 'UTF-8', 'utf-8-strict' => 'UTF-8', 'viscii' => 'VISCII', ); sub get_mime_name($) { $MIME_NAME_OF{$_[0]} }; 1; __END__ =head1 NAME Encode::MIME::NAME -- internally used by Encode =head1 SEE ALSO L =cut PK[[!5.10.1/Encode/CJKConstants.pmnuW+A# # $Id: CJKConstants.pm,v 2.2 2006/06/03 20:28:48 dankogai Exp $ # package Encode::CJKConstants; use strict; use warnings; our $RCSID = q$Id: CJKConstants.pm,v 2.2 2006/06/03 20:28:48 dankogai Exp $; our $VERSION = do { my @r = ( q$Revision: 2.2 $ =~ /\d+/g ); sprintf "%d." . "%02d" x $#r, @r }; use Carp; require Exporter; our @ISA = qw(Exporter); our @EXPORT = qw(); our @EXPORT_OK = qw(%CHARCODE %ESC %RE); our %EXPORT_TAGS = ( 'all' => [ @EXPORT_OK, @EXPORT ] ); my %_0208 = ( 1978 => '\e\$\@', 1983 => '\e\$B', 1990 => '\e&\@\e\$B', ); our %CHARCODE = ( UNDEF_EUC => "\xa2\xae", # in EUC UNDEF_SJIS => "\x81\xac", # in SJIS UNDEF_JIS => "\xa2\xf7", # -- used in unicode UNDEF_UNICODE => "\x20\x20", # -- used in unicode ); our %ESC = ( GB_2312 => "\e\$A", JIS_0208 => "\e\$B", JIS_0212 => "\e\$(D", KSC_5601 => "\e\$(C", ASC => "\e\(B", KANA => "\e\(I", '2022_KR' => "\e\$)C", ); our %RE = ( ASCII => '[\x00-\x7f]', BIN => '[\x00-\x06\x7f\xff]', EUC_0212 => '\x8f[\xa1-\xfe][\xa1-\xfe]', EUC_C => '[\xa1-\xfe][\xa1-\xfe]', EUC_KANA => '\x8e[\xa1-\xdf]', JIS_0208 => "$_0208{1978}|$_0208{1983}|$_0208{1990}", JIS_0212 => "\e" . '\$\(D', ISO_ASC => "\e" . '\([BJ]', JIS_KANA => "\e" . '\(I', '2022_KR' => "\e" . '\$\)C', SJIS_C => '[\x81-\x9f\xe0-\xfc][\x40-\x7e\x80-\xfc]', SJIS_KANA => '[\xa1-\xdf]', UTF8 => '[\xc0-\xdf][\x80-\xbf]|[\xe0-\xef][\x80-\xbf][\x80-\xbf]' ); 1; =head1 NAME Encode::CJKConstants.pm -- Internally used by Encode::??::ISO_2022_* =cut PK[[xy 5.10.1/IO.pmnuW+A# package IO; use XSLoader (); use Carp; use strict; use warnings; our $VERSION = "1.25"; XSLoader::load 'IO', $VERSION; sub import { shift; warnings::warnif('deprecated', qq{Parameterless "use IO" deprecated}) if @_ == 0 ; my @l = @_ ? @_ : qw(Handle Seekable File Pipe Socket Dir); eval join("", map { "require IO::" . (/(\w+)/)[0] . ";\n" } @l) or croak $@; } 1; __END__ PK[[VV5.10.1/syscall.phnuW+Arequire '_h2ph_pre.ph'; no warnings qw(redefine misc); require 'sys/syscall.ph'; 1; PK[[MD}UU5.10.1/syslog.phnuW+Arequire '_h2ph_pre.ph'; no warnings qw(redefine misc); require 'sys/syslog.ph'; 1; PK[[WMK5.10.1/sys/select.phnuW+Arequire '_h2ph_pre.ph'; no warnings qw(redefine misc); unless(defined(&_SYS_SELECT_H)) { eval 'sub _SYS_SELECT_H () {1;}' unless defined(&_SYS_SELECT_H); require 'features.ph'; require 'bits/types.ph'; require 'bits/select.ph'; require 'bits/sigset.ph'; unless(defined(&__sigset_t_defined)) { eval 'sub __sigset_t_defined () {1;}' unless defined(&__sigset_t_defined); } eval 'sub __need_time_t () {1;}' unless defined(&__need_time_t); eval 'sub __need_timespec () {1;}' unless defined(&__need_timespec); require 'time.ph'; eval 'sub __need_timeval () {1;}' unless defined(&__need_timeval); require 'bits/time.ph'; unless(defined(&__suseconds_t_defined)) { eval 'sub __suseconds_t_defined () {1;}' unless defined(&__suseconds_t_defined); } undef(&__NFDBITS) if defined(&__NFDBITS); undef(&__FDELT) if defined(&__FDELT); undef(&__FDMASK) if defined(&__FDMASK); eval 'sub __NFDBITS () {(8* $sizeof{ &__fd_mask});}' unless defined(&__NFDBITS); eval 'sub __FDELT { my($d) = @_; eval q((($d) / &__NFDBITS)); }' unless defined(&__FDELT); eval 'sub __FDMASK { my($d) = @_; eval q((( &__fd_mask) 1<< (($d) % &__NFDBITS))); }' unless defined(&__FDMASK); if(defined(&__USE_XOPEN)) { eval 'sub __FDS_BITS { my($set) = @_; eval q((($set)-> &fds_bits)); }' unless defined(&__FDS_BITS); } else { eval 'sub __FDS_BITS { my($set) = @_; eval q((($set)-> &__fds_bits)); }' unless defined(&__FDS_BITS); } eval 'sub FD_SETSIZE () { &__FD_SETSIZE;}' unless defined(&FD_SETSIZE); if(defined(&__USE_MISC)) { eval 'sub NFDBITS () { &__NFDBITS;}' unless defined(&NFDBITS); } eval 'sub FD_SET { my($fd, $fdsetp) = @_; eval q( &__FD_SET ($fd, $fdsetp)); }' unless defined(&FD_SET); eval 'sub FD_CLR { my($fd, $fdsetp) = @_; eval q( &__FD_CLR ($fd, $fdsetp)); }' unless defined(&FD_CLR); eval 'sub FD_ISSET { my($fd, $fdsetp) = @_; eval q( &__FD_ISSET ($fd, $fdsetp)); }' unless defined(&FD_ISSET); eval 'sub FD_ZERO { my($fdsetp) = @_; eval q( &__FD_ZERO ($fdsetp)); }' unless defined(&FD_ZERO); if(defined(&__USE_XOPEN2K)) { } } 1; PK[[:`5.10.1/sys/syscall.phnuW+Arequire '_h2ph_pre.ph'; no warnings qw(redefine misc); unless(defined(&_SYSCALL_H)) { eval 'sub _SYSCALL_H () {1;}' unless defined(&_SYSCALL_H); require 'asm/unistd.ph'; unless(defined(&_LIBC)) { require 'bits/syscall.ph'; } } 1; PK[[H),,5.10.1/sys/syslog.phnuW+Arequire '_h2ph_pre.ph'; no warnings qw(redefine misc); unless(defined(&_SYS_SYSLOG_H)) { eval 'sub _SYS_SYSLOG_H () {1;}' unless defined(&_SYS_SYSLOG_H); require 'features.ph'; eval 'sub __need___va_list () {1;}' unless defined(&__need___va_list); require 'stdarg.ph'; require 'bits/syslog-path.ph'; eval 'sub LOG_EMERG () {0;}' unless defined(&LOG_EMERG); eval 'sub LOG_ALERT () {1;}' unless defined(&LOG_ALERT); eval 'sub LOG_CRIT () {2;}' unless defined(&LOG_CRIT); eval 'sub LOG_ERR () {3;}' unless defined(&LOG_ERR); eval 'sub LOG_WARNING () {4;}' unless defined(&LOG_WARNING); eval 'sub LOG_NOTICE () {5;}' unless defined(&LOG_NOTICE); eval 'sub LOG_INFO () {6;}' unless defined(&LOG_INFO); eval 'sub LOG_DEBUG () {7;}' unless defined(&LOG_DEBUG); eval 'sub LOG_PRIMASK () {0x7;}' unless defined(&LOG_PRIMASK); eval 'sub LOG_PRI { my($p) = @_; eval q((($p) & &LOG_PRIMASK)); }' unless defined(&LOG_PRI); eval 'sub LOG_MAKEPRI { my($fac, $pri) = @_; eval q(((($fac) << 3) | ($pri))); }' unless defined(&LOG_MAKEPRI); if(defined(&SYSLOG_NAMES)) { eval 'sub INTERNAL_NOPRI () {0x10;}' unless defined(&INTERNAL_NOPRI); eval 'sub INTERNAL_MARK () { &LOG_MAKEPRI( &LOG_NFACILITIES, 0);}' unless defined(&INTERNAL_MARK); } eval 'sub LOG_KERN () {(0<<3);}' unless defined(&LOG_KERN); eval 'sub LOG_USER () {(1<<3);}' unless defined(&LOG_USER); eval 'sub LOG_MAIL () {(2<<3);}' unless defined(&LOG_MAIL); eval 'sub LOG_DAEMON () {(3<<3);}' unless defined(&LOG_DAEMON); eval 'sub LOG_AUTH () {(4<<3);}' unless defined(&LOG_AUTH); eval 'sub LOG_SYSLOG () {(5<<3);}' unless defined(&LOG_SYSLOG); eval 'sub LOG_LPR () {(6<<3);}' unless defined(&LOG_LPR); eval 'sub LOG_NEWS () {(7<<3);}' unless defined(&LOG_NEWS); eval 'sub LOG_UUCP () {(8<<3);}' unless defined(&LOG_UUCP); eval 'sub LOG_CRON () {(9<<3);}' unless defined(&LOG_CRON); eval 'sub LOG_AUTHPRIV () {(10<<3);}' unless defined(&LOG_AUTHPRIV); eval 'sub LOG_FTP () {(11<<3);}' unless defined(&LOG_FTP); eval 'sub LOG_LOCAL0 () {(16<<3);}' unless defined(&LOG_LOCAL0); eval 'sub LOG_LOCAL1 () {(17<<3);}' unless defined(&LOG_LOCAL1); eval 'sub LOG_LOCAL2 () {(18<<3);}' unless defined(&LOG_LOCAL2); eval 'sub LOG_LOCAL3 () {(19<<3);}' unless defined(&LOG_LOCAL3); eval 'sub LOG_LOCAL4 () {(20<<3);}' unless defined(&LOG_LOCAL4); eval 'sub LOG_LOCAL5 () {(21<<3);}' unless defined(&LOG_LOCAL5); eval 'sub LOG_LOCAL6 () {(22<<3);}' unless defined(&LOG_LOCAL6); eval 'sub LOG_LOCAL7 () {(23<<3);}' unless defined(&LOG_LOCAL7); eval 'sub LOG_NFACILITIES () {24;}' unless defined(&LOG_NFACILITIES); eval 'sub LOG_FACMASK () {0x3f8;}' unless defined(&LOG_FACMASK); eval 'sub LOG_FAC { my($p) = @_; eval q(((($p) & &LOG_FACMASK) >> 3)); }' unless defined(&LOG_FAC); if(defined(&SYSLOG_NAMES)) { } eval 'sub LOG_MASK { my($pri) = @_; eval q((1<< ($pri))); }' unless defined(&LOG_MASK); eval 'sub LOG_UPTO { my($pri) = @_; eval q(((1<< (($pri)+1)) - 1)); }' unless defined(&LOG_UPTO); eval 'sub LOG_PID () {0x1;}' unless defined(&LOG_PID); eval 'sub LOG_CONS () {0x2;}' unless defined(&LOG_CONS); eval 'sub LOG_ODELAY () {0x4;}' unless defined(&LOG_ODELAY); eval 'sub LOG_NDELAY () {0x8;}' unless defined(&LOG_NDELAY); eval 'sub LOG_NOWAIT () {0x10;}' unless defined(&LOG_NOWAIT); eval 'sub LOG_PERROR () {0x20;}' unless defined(&LOG_PERROR); if(defined(&__USE_BSD)) { } if((defined(&__USE_FORTIFY_LEVEL) ? &__USE_FORTIFY_LEVEL : undef) > 0 && defined (defined(&__extern_always_inline) ? &__extern_always_inline : undef)) { require 'bits/syslog.ph'; } if(defined(&__LDBL_COMPAT)) { require 'bits/syslog-ldbl.ph'; } } 1; PK[[#qq5.10.1/sys/socket.phnuW+Arequire '_h2ph_pre.ph'; no warnings qw(redefine misc); unless(defined(&_SYS_SOCKET_H)) { eval 'sub _SYS_SOCKET_H () {1;}' unless defined(&_SYS_SOCKET_H); require 'features.ph'; require 'sys/uio.ph'; eval 'sub __need_size_t () {1;}' unless defined(&__need_size_t); require 'stddef.ph'; if(defined(&__USE_GNU)) { require 'bits/sigset.ph'; } require 'bits/socket.ph'; if(defined(&__USE_BSD)) { } eval("sub SHUT_RD () { 0; }") unless defined(&SHUT_RD); eval("sub SHUT_WR () { 1; }") unless defined(&SHUT_WR); eval("sub SHUT_RDWR () { 2; }") unless defined(&SHUT_RDWR); if(defined (defined(&__cplusplus) ? &__cplusplus : undef) || ! &__GNUC_PREREQ (2, 7) || !defined (defined(&__USE_GNU) ? &__USE_GNU : undef)) { eval 'sub __SOCKADDR_ARG () {1;}' unless defined(&__SOCKADDR_ARG); eval 'sub __CONST_SOCKADDR_ARG () { 1;}' unless defined(&__CONST_SOCKADDR_ARG); } else { eval 'sub __SOCKADDR_ALLTYPES () { &__SOCKADDR_ONETYPE ( &sockaddr) &__SOCKADDR_ONETYPE ( &sockaddr_at) &__SOCKADDR_ONETYPE ( &sockaddr_ax25) &__SOCKADDR_ONETYPE ( &sockaddr_dl) &__SOCKADDR_ONETYPE ( &sockaddr_eon) &__SOCKADDR_ONETYPE ( &sockaddr_in) &__SOCKADDR_ONETYPE ( &sockaddr_in6) &__SOCKADDR_ONETYPE ( &sockaddr_inarp) &__SOCKADDR_ONETYPE ( &sockaddr_ipx) &__SOCKADDR_ONETYPE ( &sockaddr_iso) &__SOCKADDR_ONETYPE ( &sockaddr_ns) &__SOCKADDR_ONETYPE ( &sockaddr_un) &__SOCKADDR_ONETYPE ( &sockaddr_x25);}' unless defined(&__SOCKADDR_ALLTYPES); eval 'sub __SOCKADDR_ONETYPE { my($type) = @_; eval q(1;); }' unless defined(&__SOCKADDR_ONETYPE); undef(&__SOCKADDR_ONETYPE) if defined(&__SOCKADDR_ONETYPE); eval 'sub __SOCKADDR_ONETYPE { my($type) = @_; eval q( 1;); }' unless defined(&__SOCKADDR_ONETYPE); undef(&__SOCKADDR_ONETYPE) if defined(&__SOCKADDR_ONETYPE); } if(defined(&__USE_GNU)) { } if(defined(&__USE_XOPEN2K)) { } if(defined(&__USE_MISC)) { } if((defined(&__USE_FORTIFY_LEVEL) ? &__USE_FORTIFY_LEVEL : undef) > 0 && defined (defined(&__extern_always_inline) ? &__extern_always_inline : undef)) { require 'bits/socket2.ph'; } } 1; PK[[45.10.1/sys/wait.phnuW+Arequire '_h2ph_pre.ph'; no warnings qw(redefine misc); unless(defined(&_SYS_WAIT_H)) { eval 'sub _SYS_WAIT_H () {1;}' unless defined(&_SYS_WAIT_H); require 'features.ph'; require 'signal.ph'; require 'sys/resource.ph'; if(!defined (defined(&_STDLIB_H) ? &_STDLIB_H : undef) || !defined (defined(&__USE_XOPEN) ? &__USE_XOPEN : undef)) { require 'bits/waitflags.ph'; if(defined(&__USE_BSD)) { if(defined (defined(&__GNUC__) ? &__GNUC__ : undef) && !defined (defined(&__cplusplus) ? &__cplusplus : undef)) { eval 'sub __WAIT_INT { my($status) = @_; eval q(( &__extension__ (((\'union union\' { &__typeof($status) &__in; \'int\' &__i; }) { . &__in = ($status) }). &__i))); }' unless defined(&__WAIT_INT); } else { eval 'sub __WAIT_INT { my($status) = @_; eval q((*( &__const \'int\' *) ($status))); }' unless defined(&__WAIT_INT); } if(!defined (defined(&__GNUC__) ? &__GNUC__ : undef) || (defined(&__GNUC__) ? &__GNUC__ : undef) < 2|| defined (defined(&__cplusplus) ? &__cplusplus : undef)) { eval 'sub __WAIT_STATUS () { &void *;}' unless defined(&__WAIT_STATUS); eval 'sub __WAIT_STATUS_DEFN () { &void *;}' unless defined(&__WAIT_STATUS_DEFN); } else { eval 'sub __WAIT_STATUS_DEFN () {\'int\' *;}' unless defined(&__WAIT_STATUS_DEFN); } } else { eval 'sub __WAIT_INT { my($status) = @_; eval q(($status)); }' unless defined(&__WAIT_INT); eval 'sub __WAIT_STATUS () {\'int\' *;}' unless defined(&__WAIT_STATUS); eval 'sub __WAIT_STATUS_DEFN () {\'int\' *;}' unless defined(&__WAIT_STATUS_DEFN); } require 'bits/waitstatus.ph'; eval 'sub WEXITSTATUS { my($status) = @_; eval q( &__WEXITSTATUS ( &__WAIT_INT ($status))); }' unless defined(&WEXITSTATUS); eval 'sub WTERMSIG { my($status) = @_; eval q( &__WTERMSIG ( &__WAIT_INT ($status))); }' unless defined(&WTERMSIG); eval 'sub WSTOPSIG { my($status) = @_; eval q( &__WSTOPSIG ( &__WAIT_INT ($status))); }' unless defined(&WSTOPSIG); eval 'sub WIFEXITED { my($status) = @_; eval q( &__WIFEXITED ( &__WAIT_INT ($status))); }' unless defined(&WIFEXITED); eval 'sub WIFSIGNALED { my($status) = @_; eval q( &__WIFSIGNALED ( &__WAIT_INT ($status))); }' unless defined(&WIFSIGNALED); eval 'sub WIFSTOPPED { my($status) = @_; eval q( &__WIFSTOPPED ( &__WAIT_INT ($status))); }' unless defined(&WIFSTOPPED); if(defined(&__WIFCONTINUED)) { eval 'sub WIFCONTINUED { my($status) = @_; eval q( &__WIFCONTINUED ( &__WAIT_INT ($status))); }' unless defined(&WIFCONTINUED); } } if(defined(&__USE_BSD)) { eval 'sub WCOREFLAG () { &__WCOREFLAG;}' unless defined(&WCOREFLAG); eval 'sub WCOREDUMP { my($status) = @_; eval q( &__WCOREDUMP ( &__WAIT_INT ($status))); }' unless defined(&WCOREDUMP); eval 'sub W_EXITCODE { my($ret, $sig) = @_; eval q( &__W_EXITCODE ($ret, $sig)); }' unless defined(&W_EXITCODE); eval 'sub W_STOPCODE { my($sig) = @_; eval q( &__W_STOPCODE ($sig)); }' unless defined(&W_STOPCODE); } if(defined (defined(&__USE_SVID) ? &__USE_SVID : undef) || defined (defined(&__USE_XOPEN) ? &__USE_XOPEN : undef)) { eval("sub P_ALL () { 0; }") unless defined(&P_ALL); eval("sub P_PID () { 1; }") unless defined(&P_PID); eval("sub P_PGID () { 2; }") unless defined(&P_PGID); } if(defined(&__USE_BSD)) { eval 'sub WAIT_ANY () {(-1);}' unless defined(&WAIT_ANY); eval 'sub WAIT_MYPGRP () {0;}' unless defined(&WAIT_MYPGRP); } if(defined (defined(&__USE_SVID) ? &__USE_SVID : undef) || defined (defined(&__USE_XOPEN) ? &__USE_XOPEN : undef)) { eval 'sub __need_siginfo_t () {1;}' unless defined(&__need_siginfo_t); require 'bits/siginfo.ph'; } if(defined (defined(&__USE_BSD) ? &__USE_BSD : undef) || defined (defined(&__USE_XOPEN_EXTENDED) ? &__USE_XOPEN_EXTENDED : undef)) { } if(defined(&__USE_BSD)) { } } 1; PK[[Rn5.10.1/sys/types.phnuW+Arequire '_h2ph_pre.ph'; no warnings qw(redefine misc); unless(defined(&_SYS_TYPES_H)) { eval 'sub _SYS_TYPES_H () {1;}' unless defined(&_SYS_TYPES_H); require 'features.ph'; require 'bits/types.ph'; if(defined(&__USE_BSD)) { unless(defined(&__u_char_defined)) { eval 'sub __u_char_defined () {1;}' unless defined(&__u_char_defined); } } unless(defined(&__ino_t_defined)) { unless(defined(&__USE_FILE_OFFSET64)) { } else { } eval 'sub __ino_t_defined () {1;}' unless defined(&__ino_t_defined); } if(defined (defined(&__USE_LARGEFILE64) ? &__USE_LARGEFILE64 : undef) && !defined (defined(&__ino64_t_defined) ? &__ino64_t_defined : undef)) { eval 'sub __ino64_t_defined () {1;}' unless defined(&__ino64_t_defined); } unless(defined(&__dev_t_defined)) { eval 'sub __dev_t_defined () {1;}' unless defined(&__dev_t_defined); } unless(defined(&__gid_t_defined)) { eval 'sub __gid_t_defined () {1;}' unless defined(&__gid_t_defined); } unless(defined(&__mode_t_defined)) { eval 'sub __mode_t_defined () {1;}' unless defined(&__mode_t_defined); } unless(defined(&__nlink_t_defined)) { eval 'sub __nlink_t_defined () {1;}' unless defined(&__nlink_t_defined); } unless(defined(&__uid_t_defined)) { eval 'sub __uid_t_defined () {1;}' unless defined(&__uid_t_defined); } unless(defined(&__off_t_defined)) { unless(defined(&__USE_FILE_OFFSET64)) { } else { } eval 'sub __off_t_defined () {1;}' unless defined(&__off_t_defined); } if(defined (defined(&__USE_LARGEFILE64) ? &__USE_LARGEFILE64 : undef) && !defined (defined(&__off64_t_defined) ? &__off64_t_defined : undef)) { eval 'sub __off64_t_defined () {1;}' unless defined(&__off64_t_defined); } unless(defined(&__pid_t_defined)) { eval 'sub __pid_t_defined () {1;}' unless defined(&__pid_t_defined); } if((defined (defined(&__USE_SVID) ? &__USE_SVID : undef) || defined (defined(&__USE_XOPEN) ? &__USE_XOPEN : undef)) && !defined (defined(&__id_t_defined) ? &__id_t_defined : undef)) { eval 'sub __id_t_defined () {1;}' unless defined(&__id_t_defined); } unless(defined(&__ssize_t_defined)) { eval 'sub __ssize_t_defined () {1;}' unless defined(&__ssize_t_defined); } if(defined(&__USE_BSD)) { unless(defined(&__daddr_t_defined)) { eval 'sub __daddr_t_defined () {1;}' unless defined(&__daddr_t_defined); } } if((defined (defined(&__USE_SVID) ? &__USE_SVID : undef) || defined (defined(&__USE_XOPEN) ? &__USE_XOPEN : undef)) && !defined (defined(&__key_t_defined) ? &__key_t_defined : undef)) { eval 'sub __key_t_defined () {1;}' unless defined(&__key_t_defined); } if(defined(&__USE_XOPEN)) { eval 'sub __need_clock_t () {1;}' unless defined(&__need_clock_t); } eval 'sub __need_time_t () {1;}' unless defined(&__need_time_t); eval 'sub __need_timer_t () {1;}' unless defined(&__need_timer_t); eval 'sub __need_clockid_t () {1;}' unless defined(&__need_clockid_t); require 'time.ph'; if(defined(&__USE_XOPEN)) { unless(defined(&__useconds_t_defined)) { eval 'sub __useconds_t_defined () {1;}' unless defined(&__useconds_t_defined); } unless(defined(&__suseconds_t_defined)) { eval 'sub __suseconds_t_defined () {1;}' unless defined(&__suseconds_t_defined); } } eval 'sub __need_size_t () {1;}' unless defined(&__need_size_t); require 'stddef.ph'; if(defined(&__USE_MISC)) { } if(! &__GNUC_PREREQ (2, 7)) { unless(defined(&__int8_t_defined)) { eval 'sub __int8_t_defined () {1;}' unless defined(&__int8_t_defined); if((defined(&__WORDSIZE) ? &__WORDSIZE : undef) == 64) { } elsif((defined(&__GLIBC_HAVE_LONG_LONG) ? &__GLIBC_HAVE_LONG_LONG : undef)) { } } if((defined(&__WORDSIZE) ? &__WORDSIZE : undef) == 64) { } elsif((defined(&__GLIBC_HAVE_LONG_LONG) ? &__GLIBC_HAVE_LONG_LONG : undef)) { } } else { eval 'sub __intN_t { my($N, $MODE) = @_; eval q( &typedef \'int\' \'int\'$N &_t &__attribute__ (( &__mode__ ($MODE)))); }' unless defined(&__intN_t); eval 'sub __u_intN_t { my($N, $MODE) = @_; eval q( &typedef \'unsigned int u_int\'$N &_t &__attribute__ (( &__mode__ ($MODE)))); }' unless defined(&__u_intN_t); unless(defined(&__int8_t_defined)) { eval 'sub __int8_t_defined () {1;}' unless defined(&__int8_t_defined); } } eval 'sub __BIT_TYPES_DEFINED__ () {1;}' unless defined(&__BIT_TYPES_DEFINED__); if(defined(&__USE_BSD)) { require 'endian.ph'; require 'sys/select.ph'; require 'sys/sysmacros.ph'; } if(defined (defined(&__USE_UNIX98) ? &__USE_UNIX98 : undef) && !defined (defined(&__blksize_t_defined) ? &__blksize_t_defined : undef)) { eval 'sub __blksize_t_defined () {1;}' unless defined(&__blksize_t_defined); } unless(defined(&__USE_FILE_OFFSET64)) { unless(defined(&__blkcnt_t_defined)) { eval 'sub __blkcnt_t_defined () {1;}' unless defined(&__blkcnt_t_defined); } unless(defined(&__fsblkcnt_t_defined)) { eval 'sub __fsblkcnt_t_defined () {1;}' unless defined(&__fsblkcnt_t_defined); } unless(defined(&__fsfilcnt_t_defined)) { eval 'sub __fsfilcnt_t_defined () {1;}' unless defined(&__fsfilcnt_t_defined); } } else { unless(defined(&__blkcnt_t_defined)) { eval 'sub __blkcnt_t_defined () {1;}' unless defined(&__blkcnt_t_defined); } unless(defined(&__fsblkcnt_t_defined)) { eval 'sub __fsblkcnt_t_defined () {1;}' unless defined(&__fsblkcnt_t_defined); } unless(defined(&__fsfilcnt_t_defined)) { eval 'sub __fsfilcnt_t_defined () {1;}' unless defined(&__fsfilcnt_t_defined); } } if(defined(&__USE_LARGEFILE64)) { } if(defined (defined(&__USE_POSIX199506) ? &__USE_POSIX199506 : undef) || defined (defined(&__USE_UNIX98) ? &__USE_UNIX98 : undef)) { require 'bits/pthreadtypes.ph'; } } 1; PK[[8  5.10.1/sys/sysmacros.phnuW+Arequire '_h2ph_pre.ph'; no warnings qw(redefine misc); unless(defined(&_SYS_SYSMACROS_H)) { eval 'sub _SYS_SYSMACROS_H () {1;}' unless defined(&_SYS_SYSMACROS_H); require 'features.ph'; if(defined(&__GLIBC_HAVE_LONG_LONG)) { if(defined (defined(&__GNUC__) ? &__GNUC__ : undef) && (defined(&__GNUC__) ? &__GNUC__ : undef) >= 2 && defined (defined(&__USE_EXTERN_INLINES) ? &__USE_EXTERN_INLINES : undef)) { } eval 'sub major { my($dev) = @_; eval q( &gnu_dev_major ($dev)); }' unless defined(&major); eval 'sub minor { my($dev) = @_; eval q( &gnu_dev_minor ($dev)); }' unless defined(&minor); eval 'sub makedev { my($maj, $min) = @_; eval q( &gnu_dev_makedev ($maj, $min)); }' unless defined(&makedev); } } 1; PK[[dm5.10.1/sys/resource.phnuW+Arequire '_h2ph_pre.ph'; no warnings qw(redefine misc); unless(defined(&_SYS_RESOURCE_H)) { eval 'sub _SYS_RESOURCE_H () {1;}' unless defined(&_SYS_RESOURCE_H); require 'features.ph'; require 'bits/resource.ph'; unless(defined(&__id_t_defined)) { eval 'sub __id_t_defined () {1;}' unless defined(&__id_t_defined); } if(defined (defined(&__USE_GNU) ? &__USE_GNU : undef) && !defined (defined(&__cplusplus) ? &__cplusplus : undef)) { } else { } unless(defined(&__USE_FILE_OFFSET64)) { } else { if(defined(&__REDIRECT_NTH)) { } else { eval 'sub getrlimit () { &getrlimit64;}' unless defined(&getrlimit); } } if(defined(&__USE_LARGEFILE64)) { } unless(defined(&__USE_FILE_OFFSET64)) { } else { if(defined(&__REDIRECT_NTH)) { } else { eval 'sub setrlimit () { &setrlimit64;}' unless defined(&setrlimit); } } if(defined(&__USE_LARGEFILE64)) { } } 1; PK[[0'  5.10.1/sys/ioctl.phnuW+Arequire '_h2ph_pre.ph'; no warnings qw(redefine misc); unless(defined(&_SYS_IOCTL_H)) { eval 'sub _SYS_IOCTL_H () {1;}' unless defined(&_SYS_IOCTL_H); require 'features.ph'; require 'bits/ioctls.ph'; require 'bits/ioctl-types.ph'; require 'sys/ttydefaults.ph'; } 1; PK[[UU 5.10.1/sys/ttydefaults.phnuW+Arequire '_h2ph_pre.ph'; no warnings qw(redefine misc); unless(defined(&_SYS_TTYDEFAULTS_H_)) { eval 'sub _SYS_TTYDEFAULTS_H_ () {1;}' unless defined(&_SYS_TTYDEFAULTS_H_); eval 'sub TTYDEF_IFLAG () {( &BRKINT | &ISTRIP | &ICRNL | &IMAXBEL | &IXON | &IXANY);}' unless defined(&TTYDEF_IFLAG); eval 'sub TTYDEF_OFLAG () {( &OPOST | &ONLCR | &XTABS);}' unless defined(&TTYDEF_OFLAG); eval 'sub TTYDEF_LFLAG () {( &ECHO | &ICANON | &ISIG | &IEXTEN | &ECHOE| &ECHOKE| &ECHOCTL);}' unless defined(&TTYDEF_LFLAG); eval 'sub TTYDEF_CFLAG () {( &CREAD | &CS7 | &PARENB | &HUPCL);}' unless defined(&TTYDEF_CFLAG); eval 'sub TTYDEF_SPEED () {( &B9600);}' unless defined(&TTYDEF_SPEED); eval 'sub CTRL { my($x) = @_; eval q(($x&037)); }' unless defined(&CTRL); eval 'sub CEOF () { &CTRL(ord(\'d\'));}' unless defined(&CEOF); if(defined(&_POSIX_VDISABLE)) { eval 'sub CEOL () { &_POSIX_VDISABLE;}' unless defined(&CEOL); } else { eval 'sub CEOL () {ord(\'\\0\');}' unless defined(&CEOL); } eval 'sub CERASE () {0177;}' unless defined(&CERASE); eval 'sub CINTR () { &CTRL(ord(\'c\'));}' unless defined(&CINTR); if(defined(&_POSIX_VDISABLE)) { eval 'sub CSTATUS () { &_POSIX_VDISABLE;}' unless defined(&CSTATUS); } else { eval 'sub CSTATUS () {ord(\'\\0\');}' unless defined(&CSTATUS); } eval 'sub CKILL () { &CTRL(ord(\'u\'));}' unless defined(&CKILL); eval 'sub CMIN () {1;}' unless defined(&CMIN); eval 'sub CQUIT () {034;}' unless defined(&CQUIT); eval 'sub CSUSP () { &CTRL(ord(\'z\'));}' unless defined(&CSUSP); eval 'sub CTIME () {0;}' unless defined(&CTIME); eval 'sub CDSUSP () { &CTRL(ord(\'y\'));}' unless defined(&CDSUSP); eval 'sub CSTART () { &CTRL(ord(\'q\'));}' unless defined(&CSTART); eval 'sub CSTOP () { &CTRL(ord(\'s\'));}' unless defined(&CSTOP); eval 'sub CLNEXT () { &CTRL(ord(\'v\'));}' unless defined(&CLNEXT); eval 'sub CDISCARD () { &CTRL(ord(\'o\'));}' unless defined(&CDISCARD); eval 'sub CWERASE () { &CTRL(ord(\'w\'));}' unless defined(&CWERASE); eval 'sub CREPRINT () { &CTRL(ord(\'r\'));}' unless defined(&CREPRINT); eval 'sub CEOT () { &CEOF;}' unless defined(&CEOT); eval 'sub CBRK () { &CEOL;}' unless defined(&CBRK); eval 'sub CRPRNT () { &CREPRINT;}' unless defined(&CRPRNT); eval 'sub CFLUSH () { &CDISCARD;}' unless defined(&CFLUSH); } if(defined(&TTYDEFCHARS)) { undef(&TTYDEFCHARS) if defined(&TTYDEFCHARS); } 1; PK[[ֹZ""5.10.1/sys/uio.phnuW+Arequire '_h2ph_pre.ph'; no warnings qw(redefine misc); unless(defined(&_SYS_UIO_H)) { eval 'sub _SYS_UIO_H () {1;}' unless defined(&_SYS_UIO_H); require 'features.ph'; require 'sys/types.ph'; require 'bits/uio.ph'; if(defined(&__USE_BSD)) { unless(defined(&__USE_FILE_OFFSET64)) { } else { if(defined(&__REDIRECT)) { } else { eval 'sub preadv () { &preadv64;}' unless defined(&preadv); eval 'sub pwritev () { &pwritev64;}' unless defined(&pwritev); } } if(defined(&__USE_LARGEFILE64)) { } } } 1; PK[[، 5.10.1/sys/time.phnuW+Arequire '_h2ph_pre.ph'; no warnings qw(redefine misc); unless(defined(&_SYS_TIME_H)) { eval 'sub _SYS_TIME_H () {1;}' unless defined(&_SYS_TIME_H); require 'features.ph'; require 'bits/types.ph'; eval 'sub __need_time_t () {1;}' unless defined(&__need_time_t); require 'time.ph'; eval 'sub __need_timeval () {1;}' unless defined(&__need_timeval); require 'bits/time.ph'; require 'sys/select.ph'; unless(defined(&__suseconds_t_defined)) { eval 'sub __suseconds_t_defined () {1;}' unless defined(&__suseconds_t_defined); } if(defined(&__USE_GNU)) { eval 'sub TIMEVAL_TO_TIMESPEC { my($tv, $ts) = @_; eval q({ ($ts)-> &tv_sec = ($tv)-> &tv_sec; ($ts)-> &tv_nsec = ($tv)-> &tv_usec * 1000; }); }' unless defined(&TIMEVAL_TO_TIMESPEC); eval 'sub TIMESPEC_TO_TIMEVAL { my($tv, $ts) = @_; eval q({ ($tv)-> &tv_sec = ($ts)-> &tv_sec; ($tv)-> &tv_usec = ($ts)-> &tv_nsec / 1000; }); }' unless defined(&TIMESPEC_TO_TIMEVAL); } if(defined(&__USE_BSD)) { } else { } if(defined(&__USE_BSD)) { } eval("sub ITIMER_REAL () { 0; }") unless defined(&ITIMER_REAL); eval("sub ITIMER_VIRTUAL () { 1; }") unless defined(&ITIMER_VIRTUAL); eval("sub ITIMER_PROF () { 2; }") unless defined(&ITIMER_PROF); if(defined (defined(&__USE_GNU) ? &__USE_GNU : undef) && !defined (defined(&__cplusplus) ? &__cplusplus : undef)) { } else { } if(defined(&__USE_BSD)) { } if(defined(&__USE_GNU)) { } if(defined(&__USE_BSD)) { eval 'sub timerisset { my($tvp) = @_; eval q((($tvp)-> &tv_sec || ($tvp)-> &tv_usec)); }' unless defined(&timerisset); eval 'sub timerclear { my($tvp) = @_; eval q((($tvp)-> &tv_sec = ($tvp)-> &tv_usec = 0)); }' unless defined(&timerclear); eval 'sub timercmp { my($a, $b, $CMP) = @_; eval q(((($a)-> &tv_sec == ($b)-> &tv_sec) ? (($a)-> &tv_usec $CMP ($b)-> &tv_usec) : (($a)-> &tv_sec $CMP ($b)-> &tv_sec))); }' unless defined(&timercmp); eval 'sub timeradd { my($a, $b, $result) = @_; eval q( &do { ($result)-> &tv_sec = ($a)-> &tv_sec + ($b)-> &tv_sec; ($result)-> &tv_usec = ($a)-> &tv_usec + ($b)-> &tv_usec; &if (($result)-> &tv_usec >= 1000000) { ++($result)-> &tv_sec; ($result)-> &tv_usec -= 1000000; } } &while (0)); }' unless defined(&timeradd); eval 'sub timersub { my($a, $b, $result) = @_; eval q( &do { ($result)-> &tv_sec = ($a)-> &tv_sec - ($b)-> &tv_sec; ($result)-> &tv_usec = ($a)-> &tv_usec - ($b)-> &tv_usec; &if (($result)-> &tv_usec < 0) { --($result)-> &tv_sec; ($result)-> &tv_usec += 1000000; } } &while (0)); }' unless defined(&timersub); } } 1; PK[[ǦH::5.10.1/sys/cdefs.phnuW+Arequire '_h2ph_pre.ph'; no warnings qw(redefine misc); unless(defined(&_SYS_CDEFS_H)) { eval 'sub _SYS_CDEFS_H () {1;}' unless defined(&_SYS_CDEFS_H); unless(defined(&_FEATURES_H)) { require 'features.ph'; } if(defined (defined(&__GNUC__) ? &__GNUC__ : undef) && !defined (defined(&__STDC__) ? &__STDC__ : undef)) { die("You need a ISO C conforming compiler to use the glibc headers"); } undef(&__P) if defined(&__P); undef(&__PMT) if defined(&__PMT); if(defined(&__GNUC__)) { if(!defined (defined(&__cplusplus) ? &__cplusplus : undef) && &__GNUC_PREREQ (3, 3)) { eval 'sub __THROW () { &__attribute__ (( &__nothrow__));}' unless defined(&__THROW); eval 'sub __NTH { my($fct) = @_; eval q( &__attribute__ (( &__nothrow__)) $fct); }' unless defined(&__NTH); } else { if(defined (defined(&__cplusplus) ? &__cplusplus : undef) && &__GNUC_PREREQ (2,8)) { eval 'sub __THROW () { &throw ();}' unless defined(&__THROW); eval 'sub __NTH { my($fct) = @_; eval q($fct &throw ()); }' unless defined(&__NTH); } else { eval 'sub __THROW () {1;}' unless defined(&__THROW); eval 'sub __NTH { my($fct) = @_; eval q($fct); }' unless defined(&__NTH); } } } else { eval 'sub __inline () {1;}' unless defined(&__inline); eval 'sub __THROW () {1;}' unless defined(&__THROW); eval 'sub __NTH { my($fct) = @_; eval q($fct); }' unless defined(&__NTH); eval 'sub __const () { &const;}' unless defined(&__const); eval 'sub __signed () {\'signed\';}' unless defined(&__signed); eval 'sub __volatile () { &volatile;}' unless defined(&__volatile); } eval 'sub __P { my($args) = @_; eval q($args); }' unless defined(&__P); eval 'sub __PMT { my($args) = @_; eval q($args); }' unless defined(&__PMT); eval 'sub __CONCAT { my($x,$y) = @_; eval q($x $y); }' unless defined(&__CONCAT); eval 'sub __STRING { my($x) = @_; eval q($x); }' unless defined(&__STRING); eval 'sub __ptr_t () { &void *;}' unless defined(&__ptr_t); eval 'sub __long_double_t () {\'long double\';}' unless defined(&__long_double_t); if(defined(&__cplusplus)) { eval 'sub __BEGIN_DECLS () { &extern "C" {;}' unless defined(&__BEGIN_DECLS); eval 'sub __END_DECLS () {};}' unless defined(&__END_DECLS); } else { eval 'sub __BEGIN_DECLS () {1;}' unless defined(&__BEGIN_DECLS); eval 'sub __END_DECLS () {1;}' unless defined(&__END_DECLS); } if(defined (defined(&__cplusplus) ? &__cplusplus : undef) && defined (defined(&_GLIBCPP_USE_NAMESPACES) ? &_GLIBCPP_USE_NAMESPACES : undef)) { eval 'sub __BEGIN_NAMESPACE_STD () { &namespace &std {;}' unless defined(&__BEGIN_NAMESPACE_STD); eval 'sub __END_NAMESPACE_STD () {};}' unless defined(&__END_NAMESPACE_STD); eval 'sub __USING_NAMESPACE_STD { my($name) = @_; eval q( &using &std::$name;); }' unless defined(&__USING_NAMESPACE_STD); eval 'sub __BEGIN_NAMESPACE_C99 () { &namespace &__c99 {;}' unless defined(&__BEGIN_NAMESPACE_C99); eval 'sub __END_NAMESPACE_C99 () {};}' unless defined(&__END_NAMESPACE_C99); eval 'sub __USING_NAMESPACE_C99 { my($name) = @_; eval q( &using &__c99::$name;); }' unless defined(&__USING_NAMESPACE_C99); } else { eval 'sub __BEGIN_NAMESPACE_STD () {1;}' unless defined(&__BEGIN_NAMESPACE_STD); eval 'sub __END_NAMESPACE_STD () {1;}' unless defined(&__END_NAMESPACE_STD); eval 'sub __USING_NAMESPACE_STD { my($name) = @_; eval q(); }' unless defined(&__USING_NAMESPACE_STD); eval 'sub __BEGIN_NAMESPACE_C99 () {1;}' unless defined(&__BEGIN_NAMESPACE_C99); eval 'sub __END_NAMESPACE_C99 () {1;}' unless defined(&__END_NAMESPACE_C99); eval 'sub __USING_NAMESPACE_C99 { my($name) = @_; eval q(); }' unless defined(&__USING_NAMESPACE_C99); } unless(defined(&__BOUNDED_POINTERS__)) { eval 'sub __bounded () {1;}' unless defined(&__bounded); eval 'sub __unbounded () {1;}' unless defined(&__unbounded); eval 'sub __ptrvalue () {1;}' unless defined(&__ptrvalue); } eval 'sub __bos { my($ptr) = @_; eval q( &__builtin_object_size ($ptr, &__USE_FORTIFY_LEVEL > 1)); }' unless defined(&__bos); eval 'sub __bos0 { my($ptr) = @_; eval q( &__builtin_object_size ($ptr, 0)); }' unless defined(&__bos0); if( &__GNUC_PREREQ (4,3)) { eval 'sub __warndecl { my($name, $msg) = @_; eval q( &extern &void $name ( &void) &__attribute__(( &__warning__ ($msg)))); }' unless defined(&__warndecl); eval 'sub __warnattr { my($msg) = @_; eval q( &__attribute__(( &__warning__ ($msg)))); }' unless defined(&__warnattr); eval 'sub __errordecl { my($name, $msg) = @_; eval q( &extern &void $name ( &void) &__attribute__(( &__error__ ($msg)))); }' unless defined(&__errordecl); } else { eval 'sub __warndecl { my($name, $msg) = @_; eval q( &extern &void $name ( &void)); }' unless defined(&__warndecl); eval 'sub __warnattr { my($msg) = @_; eval q(); }' unless defined(&__warnattr); eval 'sub __errordecl { my($name, $msg) = @_; eval q( &extern &void $name ( &void)); }' unless defined(&__errordecl); } if( &__GNUC_PREREQ (2,97)) { eval 'sub __flexarr () {[];}' unless defined(&__flexarr); } else { if(defined(&__GNUC__)) { eval 'sub __flexarr () {[0];}' unless defined(&__flexarr); } else { if(defined (defined(&__STDC_VERSION__) ? &__STDC_VERSION__ : undef) && (defined(&__STDC_VERSION__) ? &__STDC_VERSION__ : undef) >= 199901) { eval 'sub __flexarr () {[];}' unless defined(&__flexarr); } else { eval 'sub __flexarr () {[1];}' unless defined(&__flexarr); } } } if(defined (defined(&__GNUC__) ? &__GNUC__ : undef) && (defined(&__GNUC__) ? &__GNUC__ : undef) >= 2) { eval 'sub __REDIRECT { my($name, $proto, $alias) = @_; eval q(\\"(assembly code)\\"); }' unless defined(&__REDIRECT); if(defined(&__cplusplus)) { eval 'sub __REDIRECT_NTH { my($name, $proto, $alias) = @_; eval q(\\"(assembly code)\\"); }' unless defined(&__REDIRECT_NTH); } else { eval 'sub __REDIRECT_NTH { my($name, $proto, $alias) = @_; eval q(\\"(assembly code)\\"); }' unless defined(&__REDIRECT_NTH); } eval 'sub __ASMNAME { my($cname) = @_; eval q( &__ASMNAME2 ( &__USER_LABEL_PREFIX__, $cname)); }' unless defined(&__ASMNAME); eval 'sub __ASMNAME2 { my($prefix, $cname) = @_; eval q( &__STRING ($prefix) $cname); }' unless defined(&__ASMNAME2); } if(!defined (defined(&__GNUC__) ? &__GNUC__ : undef) || (defined(&__GNUC__) ? &__GNUC__ : undef) < 2) { eval 'sub __attribute__ { my($xyz) = @_; eval q(); }' unless defined(&__attribute__); } if( &__GNUC_PREREQ (2,96)) { eval 'sub __attribute_malloc__ () { &__attribute__ (( &__malloc__));}' unless defined(&__attribute_malloc__); } else { eval 'sub __attribute_malloc__ () {1;}' unless defined(&__attribute_malloc__); } if( &__GNUC_PREREQ (2,96)) { eval 'sub __attribute_pure__ () { &__attribute__ (( &__pure__));}' unless defined(&__attribute_pure__); } else { eval 'sub __attribute_pure__ () {1;}' unless defined(&__attribute_pure__); } if( &__GNUC_PREREQ (3,1)) { eval 'sub __attribute_used__ () { &__attribute__ (( &__used__));}' unless defined(&__attribute_used__); eval 'sub __attribute_noinline__ () { &__attribute__ (( &__noinline__));}' unless defined(&__attribute_noinline__); } else { eval 'sub __attribute_used__ () { &__attribute__ (( &__unused__));}' unless defined(&__attribute_used__); eval 'sub __attribute_noinline__ () {1;}' unless defined(&__attribute_noinline__); } if( &__GNUC_PREREQ (3,2)) { eval 'sub __attribute_deprecated__ () { &__attribute__ (( &__deprecated__));}' unless defined(&__attribute_deprecated__); } else { eval 'sub __attribute_deprecated__ () {1;}' unless defined(&__attribute_deprecated__); } if( &__GNUC_PREREQ (2,8)) { eval 'sub __attribute_format_arg__ { my($x) = @_; eval q( &__attribute__ (( &__format_arg__ ($x)))); }' unless defined(&__attribute_format_arg__); } else { eval 'sub __attribute_format_arg__ { my($x) = @_; eval q(); }' unless defined(&__attribute_format_arg__); } if( &__GNUC_PREREQ (2,97)) { eval 'sub __attribute_format_strfmon__ { my($a,$b) = @_; eval q( &__attribute__ (( &__format__ ( &__strfmon__, $a, $b)))); }' unless defined(&__attribute_format_strfmon__); } else { eval 'sub __attribute_format_strfmon__ { my($a,$b) = @_; eval q(); }' unless defined(&__attribute_format_strfmon__); } if( &__GNUC_PREREQ (3,3)) { eval 'sub __nonnull { my($params) = @_; eval q( &__attribute__ (( &__nonnull__ $params))); }' unless defined(&__nonnull); } else { eval 'sub __nonnull { my($params) = @_; eval q(); }' unless defined(&__nonnull); } if( &__GNUC_PREREQ (3,4)) { eval 'sub __attribute_warn_unused_result__ () { &__attribute__ (( &__warn_unused_result__));}' unless defined(&__attribute_warn_unused_result__); if((defined(&__USE_FORTIFY_LEVEL) ? &__USE_FORTIFY_LEVEL : undef) > 0) { eval 'sub __wur () { &__attribute_warn_unused_result__;}' unless defined(&__wur); } } else { eval 'sub __attribute_warn_unused_result__ () {1;}' unless defined(&__attribute_warn_unused_result__); } unless(defined(&__wur)) { eval 'sub __wur () {1;}' unless defined(&__wur); } if( &__GNUC_PREREQ (3,2)) { eval 'sub __always_inline () { &__inline &__attribute__ (( &__always_inline__));}' unless defined(&__always_inline); } else { eval 'sub __always_inline () { &__inline;}' unless defined(&__always_inline); } if(!defined (defined(&__cplusplus) ? &__cplusplus : undef) || &__GNUC_PREREQ (4,3)) { if(defined (defined(&__GNUC_STDC_INLINE__) ? &__GNUC_STDC_INLINE__ : undef) || defined (defined(&__cplusplus) ? &__cplusplus : undef)) { eval 'sub __extern_inline () { &extern &__inline &__attribute__ (( &__gnu_inline__));}' unless defined(&__extern_inline); if( &__GNUC_PREREQ (4,3)) { eval 'sub __extern_always_inline () { &extern &__always_inline &__attribute__ (( &__gnu_inline__, &__artificial__));}' unless defined(&__extern_always_inline); } else { eval 'sub __extern_always_inline () { &extern &__always_inline &__attribute__ (( &__gnu_inline__));}' unless defined(&__extern_always_inline); } } else { eval 'sub __extern_inline () { &extern &__inline;}' unless defined(&__extern_inline); if( &__GNUC_PREREQ (4,3)) { eval 'sub __extern_always_inline () { &extern &__always_inline &__attribute__ (( &__artificial__));}' unless defined(&__extern_always_inline); } else { eval 'sub __extern_always_inline () { &extern &__always_inline;}' unless defined(&__extern_always_inline); } } } if( &__GNUC_PREREQ (4,3)) { eval 'sub __va_arg_pack () { eval q( &__builtin_va_arg_pack ()); }' unless defined(&__va_arg_pack); eval 'sub __va_arg_pack_len () { eval q( &__builtin_va_arg_pack_len ()); }' unless defined(&__va_arg_pack_len); } if(! &__GNUC_PREREQ (2,8)) { eval 'sub __extension__ () {1;}' unless defined(&__extension__); } if(! &__GNUC_PREREQ (2,92)) { eval 'sub __restrict () {1;}' unless defined(&__restrict); } if( &__GNUC_PREREQ (3,1) && !defined (defined(&__GNUG__) ? &__GNUG__ : undef)) { eval 'sub __restrict_arr () { &__restrict;}' unless defined(&__restrict_arr); } else { if(defined(&__GNUC__)) { eval 'sub __restrict_arr () {1;}' unless defined(&__restrict_arr); } else { if(defined (defined(&__STDC_VERSION__) ? &__STDC_VERSION__ : undef) && (defined(&__STDC_VERSION__) ? &__STDC_VERSION__ : undef) >= 199901) { eval 'sub __restrict_arr () { &restrict;}' unless defined(&__restrict_arr); } else { eval 'sub __restrict_arr () {1;}' unless defined(&__restrict_arr); } } } require 'bits/wordsize.ph'; if(defined (defined(&__LONG_DOUBLE_MATH_OPTIONAL) ? &__LONG_DOUBLE_MATH_OPTIONAL : undef) && defined (defined(&__NO_LONG_DOUBLE_MATH) ? &__NO_LONG_DOUBLE_MATH : undef)) { eval 'sub __LDBL_COMPAT () {1;}' unless defined(&__LDBL_COMPAT); if(defined(&__REDIRECT)) { eval 'sub __LDBL_REDIR1 { my($name, $proto, $alias) = @_; eval q( &__REDIRECT ($name, $proto, $alias)); }' unless defined(&__LDBL_REDIR1); eval 'sub __LDBL_REDIR { my($name, $proto) = @_; eval q( &__LDBL_REDIR1 ($name, $proto, &__nldbl_$name)); }' unless defined(&__LDBL_REDIR); eval 'sub __LDBL_REDIR1_NTH { my($name, $proto, $alias) = @_; eval q( &__REDIRECT_NTH ($name, $proto, $alias)); }' unless defined(&__LDBL_REDIR1_NTH); eval 'sub __LDBL_REDIR_NTH { my($name, $proto) = @_; eval q( &__LDBL_REDIR1_NTH ($name, $proto, &__nldbl_$name)); }' unless defined(&__LDBL_REDIR_NTH); eval 'sub __LDBL_REDIR1_DECL { my($name, $alias) = @_; eval q( &extern &__typeof ($name) $name &__asm ( &__ASMNAME ($alias));); }' unless defined(&__LDBL_REDIR1_DECL); eval 'sub __LDBL_REDIR_DECL { my($name) = @_; eval q( &extern &__typeof ($name) $name &__asm ( &__ASMNAME (\\"__nldbl_\\" $name));); }' unless defined(&__LDBL_REDIR_DECL); eval 'sub __REDIRECT_LDBL { my($name, $proto, $alias) = @_; eval q( &__LDBL_REDIR1 ($name, $proto, &__nldbl_$alias)); }' unless defined(&__REDIRECT_LDBL); eval 'sub __REDIRECT_NTH_LDBL { my($name, $proto, $alias) = @_; eval q( &__LDBL_REDIR1_NTH ($name, $proto, &__nldbl_$alias)); }' unless defined(&__REDIRECT_NTH_LDBL); } } if(!defined (defined(&__LDBL_COMPAT) ? &__LDBL_COMPAT : undef) || !defined (defined(&__REDIRECT) ? &__REDIRECT : undef)) { eval 'sub __LDBL_REDIR1 { my($name, $proto, $alias) = @_; eval q($name $proto); }' unless defined(&__LDBL_REDIR1); eval 'sub __LDBL_REDIR { my($name, $proto) = @_; eval q($name $proto); }' unless defined(&__LDBL_REDIR); eval 'sub __LDBL_REDIR1_NTH { my($name, $proto, $alias) = @_; eval q($name $proto &__THROW); }' unless defined(&__LDBL_REDIR1_NTH); eval 'sub __LDBL_REDIR_NTH { my($name, $proto) = @_; eval q($name $proto &__THROW); }' unless defined(&__LDBL_REDIR_NTH); eval 'sub __LDBL_REDIR_DECL { my($name) = @_; eval q(); }' unless defined(&__LDBL_REDIR_DECL); if(defined(&__REDIRECT)) { eval 'sub __REDIRECT_LDBL { my($name, $proto, $alias) = @_; eval q( &__REDIRECT ($name, $proto, $alias)); }' unless defined(&__REDIRECT_LDBL); eval 'sub __REDIRECT_NTH_LDBL { my($name, $proto, $alias) = @_; eval q( &__REDIRECT_NTH ($name, $proto, $alias)); }' unless defined(&__REDIRECT_NTH_LDBL); } } } 1; PK[[C7 7 5.10.1/sys/ucontext.phnuW+Arequire '_h2ph_pre.ph'; no warnings qw(redefine misc); unless(defined(&_SYS_UCONTEXT_H)) { eval 'sub _SYS_UCONTEXT_H () {1;}' unless defined(&_SYS_UCONTEXT_H); require 'features.ph'; require 'signal.ph'; require 'bits/wordsize.ph'; require 'bits/sigcontext.ph'; if((defined(&__WORDSIZE) ? &__WORDSIZE : undef) == 64) { eval 'sub NGREG () {23;}' unless defined(&NGREG); if(defined(&__USE_GNU)) { eval("sub REG_R8 () { 0; }") unless defined(®_R8); eval("sub REG_R9 () { 1; }") unless defined(®_R9); eval("sub REG_R10 () { 2; }") unless defined(®_R10); eval("sub REG_R11 () { 3; }") unless defined(®_R11); eval("sub REG_R12 () { 4; }") unless defined(®_R12); eval("sub REG_R13 () { 5; }") unless defined(®_R13); eval("sub REG_R14 () { 6; }") unless defined(®_R14); eval("sub REG_R15 () { 7; }") unless defined(®_R15); eval("sub REG_RDI () { 8; }") unless defined(®_RDI); eval("sub REG_RSI () { 9; }") unless defined(®_RSI); eval("sub REG_RBP () { 10; }") unless defined(®_RBP); eval("sub REG_RBX () { 11; }") unless defined(®_RBX); eval("sub REG_RDX () { 12; }") unless defined(®_RDX); eval("sub REG_RAX () { 13; }") unless defined(®_RAX); eval("sub REG_RCX () { 14; }") unless defined(®_RCX); eval("sub REG_RSP () { 15; }") unless defined(®_RSP); eval("sub REG_RIP () { 16; }") unless defined(®_RIP); eval("sub REG_EFL () { 17; }") unless defined(®_EFL); eval("sub REG_CSGSFS () { 18; }") unless defined(®_CSGSFS); eval("sub REG_ERR () { 19; }") unless defined(®_ERR); eval("sub REG_TRAPNO () { 20; }") unless defined(®_TRAPNO); eval("sub REG_OLDMASK () { 21; }") unless defined(®_OLDMASK); eval("sub REG_CR2 () { 22; }") unless defined(®_CR2); } } else { eval 'sub NGREG () {19;}' unless defined(&NGREG); if(defined(&__USE_GNU)) { eval("sub REG_GS () { 0; }") unless defined(®_GS); eval("sub REG_FS () { 1; }") unless defined(®_FS); eval("sub REG_ES () { 2; }") unless defined(®_ES); eval("sub REG_DS () { 3; }") unless defined(®_DS); eval("sub REG_EDI () { 4; }") unless defined(®_EDI); eval("sub REG_ESI () { 5; }") unless defined(®_ESI); eval("sub REG_EBP () { 6; }") unless defined(®_EBP); eval("sub REG_ESP () { 7; }") unless defined(®_ESP); eval("sub REG_EBX () { 8; }") unless defined(®_EBX); eval("sub REG_EDX () { 9; }") unless defined(®_EDX); eval("sub REG_ECX () { 10; }") unless defined(®_ECX); eval("sub REG_EAX () { 11; }") unless defined(®_EAX); eval("sub REG_TRAPNO () { 12; }") unless defined(®_TRAPNO); eval("sub REG_ERR () { 13; }") unless defined(®_ERR); eval("sub REG_EIP () { 14; }") unless defined(®_EIP); eval("sub REG_CS () { 15; }") unless defined(®_CS); eval("sub REG_EFL () { 16; }") unless defined(®_EFL); eval("sub REG_UESP () { 17; }") unless defined(®_UESP); eval("sub REG_SS () { 18; }") unless defined(®_SS); } } } 1; PK[[U 5.10.1/NDBM_File.pmnuW+Apackage NDBM_File; use strict; use warnings; require Tie::Hash; use XSLoader (); our @ISA = qw(Tie::Hash); our $VERSION = "1.08"; XSLoader::load 'NDBM_File', $VERSION; 1; __END__ =head1 NAME NDBM_File - Tied access to ndbm files =head1 SYNOPSIS use Fcntl; # For O_RDWR, O_CREAT, etc. use NDBM_File; tie(%h, 'NDBM_File', 'filename', O_RDWR|O_CREAT, 0666) or die "Couldn't tie NDBM file 'filename': $!; aborting"; # Now read and change the hash $h{newkey} = newvalue; print $h{oldkey}; ... untie %h; =head1 DESCRIPTION C establishes a connection between a Perl hash variable and a file in NDBM_File format;. You can manipulate the data in the file just as if it were in a Perl hash, but when your program exits, the data will remain in the file, to be used the next time your program runs. Use C with the Perl built-in C function to establish the connection between the variable and the file. The arguments to C should be: =over 4 =item 1. The hash variable you want to tie. =item 2. The string C<"NDBM_File">. (Ths tells Perl to use the C package to perform the functions of the hash.) =item 3. The name of the file you want to tie to the hash. =item 4. Flags. Use one of: =over 2 =item C Read-only access to the data in the file. =item C Write-only access to the data in the file. =item C Both read and write access. =back If you want to create the file if it does not exist, add C to any of these, as in the example. If you omit C and the file does not already exist, the C call will fail. =item 5. The default permissions to use if a new file is created. The actual permissions will be modified by the user's umask, so you should probably use 0666 here. (See L.) =back =head1 DIAGNOSTICS On failure, the C call returns an undefined value and probably sets C<$!> to contain the reason the file could not be tied. =head2 C This warning is emitted when you try to store a key or a value that is too long. It means that the change was not recorded in the database. See BUGS AND WARNINGS below. =head1 BUGS AND WARNINGS There are a number of limits on the size of the data that you can store in the NDBM file. The most important is that the length of a key, plus the length of its associated value, may not exceed 1008 bytes. See L, L, L =cut PK[[9MM5.10.1/encoding.pmnuW+A# $Id: encoding.pm,v 2.8 2009/02/15 17:44:13 dankogai Exp $ package encoding; our $VERSION = '2.6_01'; use Encode; use strict; use warnings; sub DEBUG () { 0 } BEGIN { if ( ord("A") == 193 ) { require Carp; Carp::croak("encoding: pragma does not support EBCDIC platforms"); } } our $HAS_PERLIO = 0; eval { require PerlIO::encoding }; unless ($@) { $HAS_PERLIO = ( PerlIO::encoding->VERSION >= 0.02 ); } sub _exception { my $name = shift; $] > 5.008 and return 0; # 5.8.1 or higher then no my %utfs = map { $_ => 1 } qw(utf8 UCS-2BE UCS-2LE UTF-16 UTF-16BE UTF-16LE UTF-32 UTF-32BE UTF-32LE); $utfs{$name} or return 0; # UTFs or no require Config; Config->import(); our %Config; return $Config{perl_patchlevel} ? 0 : 1 # maintperl then no } sub in_locale { $^H & ( $locale::hint_bits || 0 ) } sub _get_locale_encoding { my $locale_encoding; # I18N::Langinfo isn't available everywhere eval { require I18N::Langinfo; I18N::Langinfo->import(qw(langinfo CODESET)); $locale_encoding = langinfo( CODESET() ); }; my $country_language; no warnings 'uninitialized'; if ( (not $locale_encoding) && in_locale() ) { if ( $ENV{LC_ALL} =~ /^([^.]+)\.([^.@]+)(@.*)?$/ ) { ( $country_language, $locale_encoding ) = ( $1, $2 ); } elsif ( $ENV{LANG} =~ /^([^.]+)\.([^.@]+)(@.*)?$/ ) { ( $country_language, $locale_encoding ) = ( $1, $2 ); } # LANGUAGE affects only LC_MESSAGES only on glibc } elsif ( not $locale_encoding ) { if ( $ENV{LC_ALL} =~ /\butf-?8\b/i || $ENV{LANG} =~ /\butf-?8\b/i ) { $locale_encoding = 'utf8'; } # Could do more heuristics based on the country and language # parts of LC_ALL and LANG (the parts before the dot (if any)), # since we have Locale::Country and Locale::Language available. # TODO: get a database of Language -> Encoding mappings # (the Estonian database at http://www.eki.ee/letter/ # would be excellent!) --jhi } if ( defined $locale_encoding && lc($locale_encoding) eq 'euc' && defined $country_language ) { if ( $country_language =~ /^ja_JP|japan(?:ese)?$/i ) { $locale_encoding = 'euc-jp'; } elsif ( $country_language =~ /^ko_KR|korean?$/i ) { $locale_encoding = 'euc-kr'; } elsif ( $country_language =~ /^zh_CN|chin(?:a|ese)$/i ) { $locale_encoding = 'euc-cn'; } elsif ( $country_language =~ /^zh_TW|taiwan(?:ese)?$/i ) { $locale_encoding = 'euc-tw'; } else { require Carp; Carp::croak( "encoding: Locale encoding '$locale_encoding' too ambiguous" ); } } return $locale_encoding; } sub import { my $class = shift; my $name = shift; if ( $name eq ':_get_locale_encoding' ) { # used by lib/open.pm my $caller = caller(); { no strict 'refs'; *{"${caller}::_get_locale_encoding"} = \&_get_locale_encoding; } return; } $name = _get_locale_encoding() if $name eq ':locale'; my %arg = @_; $name = $ENV{PERL_ENCODING} unless defined $name; my $enc = find_encoding($name); unless ( defined $enc ) { require Carp; Carp::croak("encoding: Unknown encoding '$name'"); } $name = $enc->name; # canonize unless ( $arg{Filter} ) { DEBUG and warn "_exception($name) = ", _exception($name); _exception($name) or ${^ENCODING} = $enc; $HAS_PERLIO or return 1; } else { defined( ${^ENCODING} ) and undef ${^ENCODING}; # implicitly 'use utf8' require utf8; # to fetch $utf8::hint_bits; $^H |= $utf8::hint_bits; eval { require Filter::Util::Call; Filter::Util::Call->import; filter_add( sub { my $status = filter_read(); if ( $status > 0 ) { $_ = $enc->decode( $_, 1 ); DEBUG and warn $_; } $status; } ); }; $@ eq '' and DEBUG and warn "Filter installed"; } defined ${^UNICODE} and ${^UNICODE} != 0 and return 1; for my $h (qw(STDIN STDOUT)) { if ( $arg{$h} ) { unless ( defined find_encoding( $arg{$h} ) ) { require Carp; Carp::croak( "encoding: Unknown encoding for $h, '$arg{$h}'"); } eval { binmode( $h, ":raw :encoding($arg{$h})" ) }; } else { unless ( exists $arg{$h} ) { eval { no warnings 'uninitialized'; binmode( $h, ":raw :encoding($name)" ); }; } } if ($@) { require Carp; Carp::croak($@); } } return 1; # I doubt if we need it, though } sub unimport { no warnings; undef ${^ENCODING}; if ($HAS_PERLIO) { binmode( STDIN, ":raw" ); binmode( STDOUT, ":raw" ); } else { binmode(STDIN); binmode(STDOUT); } if ( $INC{"Filter/Util/Call.pm"} ) { eval { filter_del() }; } } 1; __END__ =pod =head1 NAME encoding - allows you to write your script in non-ascii or non-utf8 =head1 SYNOPSIS use encoding "greek"; # Perl like Greek to you? use encoding "euc-jp"; # Jperl! # or you can even do this if your shell supports your native encoding perl -Mencoding=latin2 -e'...' # Feeling centrally European? perl -Mencoding=euc-kr -e'...' # Or Korean? # more control # A simple euc-cn => utf-8 converter use encoding "euc-cn", STDOUT => "utf8"; while(<>){print}; # "no encoding;" supported (but not scoped!) no encoding; # an alternate way, Filter use encoding "euc-jp", Filter=>1; # now you can use kanji identifiers -- in euc-jp! # switch on locale - # note that this probably means that unless you have a complete control # over the environments the application is ever going to be run, you should # NOT use the feature of encoding pragma allowing you to write your script # in any recognized encoding because changing locale settings will wreck # the script; you can of course still use the other features of the pragma. use encoding ':locale'; =head1 ABSTRACT Let's start with a bit of history: Perl 5.6.0 introduced Unicode support. You could apply C and regexes even to complex CJK characters -- so long as the script was written in UTF-8. But back then, text editors that supported UTF-8 were still rare and many users instead chose to write scripts in legacy encodings, giving up a whole new feature of Perl 5.6. Rewind to the future: starting from perl 5.8.0 with the B pragma, you can write your script in any encoding you like (so long as the C module supports it) and still enjoy Unicode support. This pragma achieves that by doing the following: =over =item * Internally converts all literals (C) from the encoding specified to utf8. In Perl 5.8.1 and later, literals in C and C pseudo-filehandle are also converted. =item * Changing PerlIO layers of C and C to the encoding specified. =back =head2 Literal Conversions You can write code in EUC-JP as follows: my $Rakuda = "\xF1\xD1\xF1\xCC"; # Camel in Kanji #<-char-><-char-> # 4 octets s/\bCamel\b/$Rakuda/; And with C in effect, it is the same thing as the code in UTF-8: my $Rakuda = "\x{99F1}\x{99DD}"; # two Unicode Characters s/\bCamel\b/$Rakuda/; =head2 PerlIO layers for C The B pragma also modifies the filehandle layers of STDIN and STDOUT to the specified encoding. Therefore, use encoding "euc-jp"; my $message = "Camel is the symbol of perl.\n"; my $Rakuda = "\xF1\xD1\xF1\xCC"; # Camel in Kanji $message =~ s/\bCamel\b/$Rakuda/; print $message; Will print "\xF1\xD1\xF1\xCC is the symbol of perl.\n", not "\x{99F1}\x{99DD} is the symbol of perl.\n". You can override this by giving extra arguments; see below. =head2 Implicit upgrading for byte strings By default, if strings operating under byte semantics and strings with Unicode character data are concatenated, the new string will be created by decoding the byte strings as I. The B pragma changes this to use the specified encoding instead. For example: use encoding 'utf8'; my $string = chr(20000); # a Unicode string utf8::encode($string); # now it's a UTF-8 encoded byte string # concatenate with another Unicode string print length($string . chr(20000)); Will print C<2>, because C<$string> is upgraded as UTF-8. Without C, it will print C<4> instead, since C<$string> is three octets when interpreted as Latin-1. =head2 Side effects If the C pragma is in scope then the lengths returned are calculated from the length of C<$/> in Unicode characters, which is not always the same as the length of C<$/> in the native encoding. This pragma affects utf8::upgrade, but not utf8::downgrade. =head1 FEATURES THAT REQUIRE 5.8.1 Some of the features offered by this pragma requires perl 5.8.1. Most of these are done by Inaba Hiroto. Any other features and changes are good for 5.8.0. =over =item "NON-EUC" doublebyte encodings Because perl needs to parse script before applying this pragma, such encodings as Shift_JIS and Big-5 that may contain '\' (BACKSLASH; \x5c) in the second byte fails because the second byte may accidentally escape the quoting character that follows. Perl 5.8.1 or later fixes this problem. =item tr// C was overlooked by Perl 5 porters when they released perl 5.8.0 See the section below for details. =item DATA pseudo-filehandle Another feature that was overlooked was C. =back =head1 USAGE =over 4 =item use encoding [I] ; Sets the script encoding to I. And unless ${^UNICODE} exists and non-zero, PerlIO layers of STDIN and STDOUT are set to ":encoding(I)". Note that STDERR WILL NOT be changed. Also note that non-STD file handles remain unaffected. Use C or C to change layers of those. If no encoding is specified, the environment variable L is consulted. If no encoding can be found, the error C'> will be thrown. =item use encoding I [ STDIN =E I ...] ; You can also individually set encodings of STDIN and STDOUT via the C<< STDIN => I >> form. In this case, you cannot omit the first I. C<< STDIN => undef >> turns the IO transcoding completely off. When ${^UNICODE} exists and non-zero, these options will completely ignored. ${^UNICODE} is a variable introduced in perl 5.8.1. See L see L and L for details (perl 5.8.1 and later). =item use encoding I Filter=E1; This turns the encoding pragma into a source filter. While the default approach just decodes interpolated literals (in qq() and qr()), this will apply a source filter to the entire source code. See L below for details. =item no encoding; Unsets the script encoding. The layers of STDIN, STDOUT are reset to ":raw" (the default unprocessed raw stream of bytes). =back =head1 The Filter Option The magic of C is not applied to the names of identifiers. In order to make C<${"\x{4eba}"}++> ($human++, where human is a single Han ideograph) work, you still need to write your script in UTF-8 -- or use a source filter. That's what 'Filter=>1' does. What does this mean? Your source code behaves as if it is written in UTF-8 with 'use utf8' in effect. So even if your editor only supports Shift_JIS, for example, you can still try examples in Chapter 15 of C. For instance, you can use UTF-8 identifiers. This option is significantly slower and (as of this writing) non-ASCII identifiers are not very stable WITHOUT this option and with the source code written in UTF-8. =head2 Filter-related changes at Encode version 1.87 =over =item * The Filter option now sets STDIN and STDOUT like non-filter options. And C<< STDIN=>I >> and C<< STDOUT=>I >> work like non-filter version. =item * C is implicitly declared so you no longer have to C to C<${"\x{4eba}"}++>. =back =head1 CAVEATS =head2 NOT SCOPED The pragma is a per script, not a per block lexical. Only the last C or C matters, and it affects B. However, the pragma is supported and B can appear as many times as you want in a given script. The multiple use of this pragma is discouraged. By the same reason, the use this pragma inside modules is also discouraged (though not as strongly discouraged as the case above. See below). If you still have to write a module with this pragma, be very careful of the load order. See the codes below; # called module package Module_IN_BAR; use encoding "bar"; # stuff in "bar" encoding here 1; # caller script use encoding "foo" use Module_IN_BAR; # surprise! use encoding "bar" is in effect. The best way to avoid this oddity is to use this pragma RIGHT AFTER other modules are loaded. i.e. use Module_IN_BAR; use encoding "foo"; =head2 DO NOT MIX MULTIPLE ENCODINGS Notice that only literals (string or regular expression) having only legacy code points are affected: if you mix data like this \xDF\x{100} the data is assumed to be in (Latin 1 and) Unicode, not in your native encoding. In other words, this will match in "greek": "\xDF" =~ /\x{3af}/ but this will not "\xDF\x{100}" =~ /\x{3af}\x{100}/ since the C<\xDF> (ISO 8859-7 GREEK SMALL LETTER IOTA WITH TONOS) on the left will B be upgraded to C<\x{3af}> (Unicode GREEK SMALL LETTER IOTA WITH TONOS) because of the C<\x{100}> on the left. You should not be mixing your legacy data and Unicode in the same string. This pragma also affects encoding of the 0x80..0xFF code point range: normally characters in that range are left as eight-bit bytes (unless they are combined with characters with code points 0x100 or larger, in which case all characters need to become UTF-8 encoded), but if the C pragma is present, even the 0x80..0xFF range always gets UTF-8 encoded. After all, the best thing about this pragma is that you don't have to resort to \x{....} just to spell your name in a native encoding. So feel free to put your strings in your encoding in quotes and regexes. =head2 tr/// with ranges The B pragma works by decoding string literals in C and so forth. In perl 5.8.0, this does not apply to C. Therefore, use encoding 'euc-jp'; #.... $kana =~ tr/\xA4\xA1-\xA4\xF3/\xA5\xA1-\xA5\xF3/; # -------- -------- -------- -------- Does not work as $kana =~ tr/\x{3041}-\x{3093}/\x{30a1}-\x{30f3}/; =over =item Legend of characters above utf8 euc-jp charnames::viacode() ----------------------------------------- \x{3041} \xA4\xA1 HIRAGANA LETTER SMALL A \x{3093} \xA4\xF3 HIRAGANA LETTER N \x{30a1} \xA5\xA1 KATAKANA LETTER SMALL A \x{30f3} \xA5\xF3 KATAKANA LETTER N =back This counterintuitive behavior has been fixed in perl 5.8.1. =head3 workaround to tr///; In perl 5.8.0, you can work around as follows; use encoding 'euc-jp'; # .... eval qq{ \$kana =~ tr/\xA4\xA1-\xA4\xF3/\xA5\xA1-\xA5\xF3/ }; Note the C expression is surrounded by C. The idea behind is the same as classic idiom that makes C 'interpolate'. tr/$from/$to/; # wrong! eval qq{ tr/$from/$to/ }; # workaround. Nevertheless, in case of B pragma even C is affected so C not being decoded was obviously against the will of Perl5 Porters so it has been fixed in Perl 5.8.1 or later. =head1 EXAMPLE - Greekperl use encoding "iso 8859-7"; # \xDF in ISO 8859-7 (Greek) is \x{3af} in Unicode. $a = "\xDF"; $b = "\x{100}"; printf "%#x\n", ord($a); # will print 0x3af, not 0xdf $c = $a . $b; # $c will be "\x{3af}\x{100}", not "\x{df}\x{100}". # chr() is affected, and ... print "mega\n" if ord(chr(0xdf)) == 0x3af; # ... ord() is affected by the encoding pragma ... print "tera\n" if ord(pack("C", 0xdf)) == 0x3af; # ... as are eq and cmp ... print "peta\n" if "\x{3af}" eq pack("C", 0xdf); print "exa\n" if "\x{3af}" cmp pack("C", 0xdf) == 0; # ... but pack/unpack C are not affected, in case you still # want to go back to your native encoding print "zetta\n" if unpack("C", (pack("C", 0xdf))) == 0xdf; =head1 KNOWN PROBLEMS =over =item literals in regex that are longer than 127 bytes For native multibyte encodings (either fixed or variable length), the current implementation of the regular expressions may introduce recoding errors for regular expression literals longer than 127 bytes. =item EBCDIC The encoding pragma is not supported on EBCDIC platforms. (Porters who are willing and able to remove this limitation are welcome.) =item format This pragma doesn't work well with format because PerlIO does not get along very well with it. When format contains non-ascii characters it prints funny or gets "wide character warnings". To understand it, try the code below. # Save this one in utf8 # replace *non-ascii* with a non-ascii string my $camel; format STDOUT = *non-ascii*@>>>>>>> $camel . $camel = "*non-ascii*"; binmode(STDOUT=>':encoding(utf8)'); # bang! write; # funny print $camel, "\n"; # fine Without binmode this happens to work but without binmode, print() fails instead of write(). At any rate, the very use of format is questionable when it comes to unicode characters since you have to consider such things as character width (i.e. double-width for ideographs) and directions (i.e. BIDI for Arabic and Hebrew). =item Thread safety C is not thread-safe (i.e., do not use in threaded applications). =back =head2 The Logic of :locale The logic of C<:locale> is as follows: =over 4 =item 1. If the platform supports the langinfo(CODESET) interface, the codeset returned is used as the default encoding for the open pragma. =item 2. If 1. didn't work but we are under the locale pragma, the environment variables LC_ALL and LANG (in that order) are matched for encodings (the part after C<.>, if any), and if any found, that is used as the default encoding for the open pragma. =item 3. If 1. and 2. didn't work, the environment variables LC_ALL and LANG (in that order) are matched for anything looking like UTF-8, and if any found, C<:utf8> is used as the default encoding for the open pragma. =back If your locale environment variables (LC_ALL, LC_CTYPE, LANG) contain the strings 'UTF-8' or 'UTF8' (case-insensitive matching), the default encoding of your STDIN, STDOUT, and STDERR, and of B, is UTF-8. =head1 HISTORY This pragma first appeared in Perl 5.8.0. For features that require 5.8.1 and better, see above. The C<:locale> subpragma was implemented in 2.01, or Perl 5.8.6. =head1 SEE ALSO L, L, L, L, Ch. 15 of C by Larry Wall, Tom Christiansen, Jon Orwant; O'Reilly & Associates; ISBN 0-596-00027-8 =cut PK[[c~KHKH5.10.1/threads/shared.pmnuW+Apackage threads::shared; use 5.008; use strict; use warnings; use Scalar::Util qw(reftype refaddr blessed); our $VERSION = '1.29'; my $XS_VERSION = $VERSION; $VERSION = eval $VERSION; # Declare that we have been loaded $threads::shared::threads_shared = 1; # Load the XS code, if applicable if ($threads::threads) { require XSLoader; XSLoader::load('threads::shared', $XS_VERSION); *is_shared = \&_id; } else { # String eval is generally evil, but we don't want these subs to # exist at all if 'threads' is not loaded successfully. # Vivifying them conditionally this way saves on average about 4K # of memory per thread. eval <<'_MARKER_'; sub share (\[$@%]) { return $_[0] } sub is_shared (\[$@%]) { undef } sub cond_wait (\[$@%];\[$@%]) { undef } sub cond_timedwait (\[$@%]$;\[$@%]) { undef } sub cond_signal (\[$@%]) { undef } sub cond_broadcast (\[$@%]) { undef } _MARKER_ } ### Export ### sub import { # Exported subroutines my @EXPORT = qw(share is_shared cond_wait cond_timedwait cond_signal cond_broadcast shared_clone); if ($threads::threads) { push(@EXPORT, 'bless'); } # Export subroutine names my $caller = caller(); foreach my $sym (@EXPORT) { no strict 'refs'; *{$caller.'::'.$sym} = \&{$sym}; } } # Predeclarations for internal functions my ($make_shared); ### Methods, etc. ### sub threads::shared::tie::SPLICE { require Carp; Carp::croak('Splice not implemented for shared arrays'); } # Create a thread-shared clone of a complex data structure or object sub shared_clone { if (@_ != 1) { require Carp; Carp::croak('Usage: shared_clone(REF)'); } return $make_shared->(shift, {}); } ### Internal Functions ### # Used by shared_clone() to recursively clone # a complex data structure or object $make_shared = sub { my ($item, $cloned) = @_; # Just return the item if: # 1. Not a ref; # 2. Already shared; or # 3. Not running 'threads'. return $item if (! ref($item) || is_shared($item) || ! $threads::threads); # Check for previously cloned references # (this takes care of circular refs as well) my $addr = refaddr($item); if (exists($cloned->{$addr})) { # Return the already existing clone return $cloned->{$addr}; } # Make copies of array, hash and scalar refs and refs of refs my $copy; my $ref_type = reftype($item); # Copy an array ref if ($ref_type eq 'ARRAY') { # Make empty shared array ref $copy = &share([]); # Add to clone checking hash $cloned->{$addr} = $copy; # Recursively copy and add contents push(@$copy, map { $make_shared->($_, $cloned) } @$item); } # Copy a hash ref elsif ($ref_type eq 'HASH') { # Make empty shared hash ref $copy = &share({}); # Add to clone checking hash $cloned->{$addr} = $copy; # Recursively copy and add contents foreach my $key (keys(%{$item})) { $copy->{$key} = $make_shared->($item->{$key}, $cloned); } } # Copy a scalar ref elsif ($ref_type eq 'SCALAR') { $copy = \do{ my $scalar = $$item; }; share($copy); # Add to clone checking hash $cloned->{$addr} = $copy; } # Copy of a ref of a ref elsif ($ref_type eq 'REF') { # Special handling for $x = \$x if ($addr == refaddr($$item)) { $copy = \$copy; share($copy); $cloned->{$addr} = $copy; } else { my $tmp; $copy = \$tmp; share($copy); # Add to clone checking hash $cloned->{$addr} = $copy; # Recursively copy and add contents $tmp = $make_shared->($$item, $cloned); } } else { require Carp; Carp::croak("Unsupported ref type: ", $ref_type); } # If input item is an object, then bless the copy into the same class if (my $class = blessed($item)) { bless($copy, $class); } # Clone READONLY flag if ($ref_type eq 'SCALAR') { if (Internals::SvREADONLY($$item)) { Internals::SvREADONLY($$copy, 1) if ($] >= 5.008003); } } if (Internals::SvREADONLY($item)) { Internals::SvREADONLY($copy, 1) if ($] >= 5.008003); } return $copy; }; 1; __END__ =head1 NAME threads::shared - Perl extension for sharing data structures between threads =head1 VERSION This document describes threads::shared version 1.29 =head1 SYNOPSIS use threads; use threads::shared; my $var :shared; my %hsh :shared; my @ary :shared; my ($scalar, @array, %hash); share($scalar); share(@array); share(%hash); $var = $scalar_value; $var = $shared_ref_value; $var = shared_clone($non_shared_ref_value); $var = shared_clone({'foo' => [qw/foo bar baz/]}); $hsh{'foo'} = $scalar_value; $hsh{'bar'} = $shared_ref_value; $hsh{'baz'} = shared_clone($non_shared_ref_value); $hsh{'quz'} = shared_clone([1..3]); $ary[0] = $scalar_value; $ary[1] = $shared_ref_value; $ary[2] = shared_clone($non_shared_ref_value); $ary[3] = shared_clone([ {}, [] ]); { lock(%hash); ... } cond_wait($scalar); cond_timedwait($scalar, time() + 30); cond_broadcast(@array); cond_signal(%hash); my $lockvar :shared; # condition var != lock var cond_wait($var, $lockvar); cond_timedwait($var, time()+30, $lockvar); =head1 DESCRIPTION By default, variables are private to each thread, and each newly created thread gets a private copy of each existing variable. This module allows you to share variables across different threads (and pseudo-forks on Win32). It is used together with the L module. This module supports the sharing of the following data types only: scalars and scalar refs, arrays and array refs, and hashes and hash refs. =head1 EXPORT The following functions are exported by this module: C, C, C, C, C, C and C Note that if this module is imported when L has not yet been loaded, then these functions all become no-ops. This makes it possible to write modules that will work in both threaded and non-threaded environments. =head1 FUNCTIONS =over 4 =item share VARIABLE C takes a variable and marks it as shared: my ($scalar, @array, %hash); share($scalar); share(@array); share(%hash); C will return the shared rvalue, but always as a reference. Variables can also be marked as shared at compile time by using the C<:shared> attribute: my ($var, %hash, @array) :shared; Shared variables can only store scalars, refs of shared variables, or refs of shared data (discussed in next section): my ($var, %hash, @array) :shared; my $bork; # Storing scalars $var = 1; $hash{'foo'} = 'bar'; $array[0] = 1.5; # Storing shared refs $var = \%hash; $hash{'ary'} = \@array; $array[1] = \$var; # The following are errors: # $var = \$bork; # ref of non-shared variable # $hash{'bork'} = []; # non-shared array ref # push(@array, { 'x' => 1 }); # non-shared hash ref =item shared_clone REF C takes a reference, and returns a shared version of its argument, performing a deep copy on any non-shared elements. Any shared elements in the argument are used as is (i.e., they are not cloned). my $cpy = shared_clone({'foo' => [qw/foo bar baz/]}); Object status (i.e., the class an object is blessed into) is also cloned. my $obj = {'foo' => [qw/foo bar baz/]}; bless($obj, 'Foo'); my $cpy = shared_clone($obj); print(ref($cpy), "\n"); # Outputs 'Foo' For cloning empty array or hash refs, the following may also be used: $var = &share([]); # Same as $var = shared_clone([]); $var = &share({}); # Same as $var = shared_clone({}); =item is_shared VARIABLE C checks if the specified variable is shared or not. If shared, returns the variable's internal ID (similar to L). Otherwise, returns C. if (is_shared($var)) { print("\$var is shared\n"); } else { print("\$var is not shared\n"); } When used on an element of an array or hash, C checks if the specified element belongs to a shared array or hash. (It does not check the contents of that element.) my %hash :shared; if (is_shared(%hash)) { print("\%hash is shared\n"); } $hash{'elem'} = 1; if (is_shared($hash{'elem'})) { print("\$hash{'elem'} is in a shared hash\n"); } =item lock VARIABLE C places a B lock on a variable until the lock goes out of scope. If the variable is locked by another thread, the C call will block until it's available. Multiple calls to C by the same thread from within dynamically nested scopes are safe -- the variable will remain locked until the outermost lock on the variable goes out of scope. C follows references exactly I level: my %hash :shared; my $ref = \%hash; lock($ref); # This is equivalent to lock(%hash) Note that you cannot explicitly unlock a variable; you can only wait for the lock to go out of scope. This is most easily accomplished by locking the variable inside a block. my $var :shared; { lock($var); # $var is locked from here to the end of the block ... } # $var is now unlocked As locks are advisory, they do not prevent data access or modification by another thread that does not itself attempt to obtain a lock on the variable. You cannot lock the individual elements of a container variable: my %hash :shared; $hash{'foo'} = 'bar'; #lock($hash{'foo'}); # Error lock(%hash); # Works If you need more fine-grained control over shared variable access, see L. =item cond_wait VARIABLE =item cond_wait CONDVAR, LOCKVAR The C function takes a B variable as a parameter, unlocks the variable, and blocks until another thread does a C or C for that same locked variable. The variable that C blocked on is relocked after the C is satisfied. If there are multiple threads Cing on the same variable, all but one will re-block waiting to reacquire the lock on the variable. (So if you're only using C for synchronisation, give up the lock as soon as possible). The two actions of unlocking the variable and entering the blocked wait state are atomic, the two actions of exiting from the blocked wait state and re-locking the variable are not. In its second form, C takes a shared, B variable followed by a shared, B variable. The second variable is unlocked and thread execution suspended until another thread signals the first variable. It is important to note that the variable can be notified even if no thread C or C on the variable. It is therefore important to check the value of the variable and go back to waiting if the requirement is not fulfilled. For example, to pause until a shared counter drops to zero: { lock($counter); cond_wait($counter) until $counter == 0; } =item cond_timedwait VARIABLE, ABS_TIMEOUT =item cond_timedwait CONDVAR, ABS_TIMEOUT, LOCKVAR In its two-argument form, C takes a B variable and an absolute timeout as parameters, unlocks the variable, and blocks until the timeout is reached or another thread signals the variable. A false value is returned if the timeout is reached, and a true value otherwise. In either case, the variable is re-locked upon return. Like C, this function may take a shared, B variable as an additional parameter; in this case the first parameter is an B condition variable protected by a distinct lock variable. Again like C, waking up and reacquiring the lock are not atomic, and you should always check your desired condition after this function returns. Since the timeout is an absolute value, however, it does not have to be recalculated with each pass: lock($var); my $abs = time() + 15; until ($ok = desired_condition($var)) { last if !cond_timedwait($var, $abs); } # we got it if $ok, otherwise we timed out! =item cond_signal VARIABLE The C function takes a B variable as a parameter and unblocks one thread that's Cing on that variable. If more than one thread is blocked in a C on that variable, only one (and which one is indeterminate) will be unblocked. If there are no threads blocked in a C on the variable, the signal is discarded. By always locking before signaling, you can (with care), avoid signaling before another thread has entered cond_wait(). C will normally generate a warning if you attempt to use it on an unlocked variable. On the rare occasions where doing this may be sensible, you can suppress the warning with: { no warnings 'threads'; cond_signal($foo); } =item cond_broadcast VARIABLE The C function works similarly to C. C, though, will unblock B the threads that are blocked in a C on the locked variable, rather than only one. =back =head1 OBJECTS L exports a version of L that works on shared objects such that I propagate across threads. # Create a shared 'Foo' object my $foo :shared = shared_clone({}); bless($foo, 'Foo'); # Create a shared 'Bar' object my $bar :shared = shared_clone({}); bless($bar, 'Bar'); # Put 'bar' inside 'foo' $foo->{'bar'} = $bar; # Rebless the objects via a thread threads->create(sub { # Rebless the outer object bless($foo, 'Yin'); # Cannot directly rebless the inner object #bless($foo->{'bar'}, 'Yang'); # Retrieve and rebless the inner object my $obj = $foo->{'bar'}; bless($obj, 'Yang'); $foo->{'bar'} = $obj; })->join(); print(ref($foo), "\n"); # Prints 'Yin' print(ref($foo->{'bar'}), "\n"); # Prints 'Yang' print(ref($bar), "\n"); # Also prints 'Yang' =head1 NOTES L is designed to disable itself silently if threads are not available. This allows you to write modules and packages that can be used in both threaded and non-threaded applications. If you want access to threads, you must C before you C. L will emit a warning if you use it after L. =head1 BUGS AND LIMITATIONS When C is used on arrays, hashes, array refs or hash refs, any data they contain will be lost. my @arr = qw(foo bar baz); share(@arr); # @arr is now empty (i.e., == ()); # Create a 'foo' object my $foo = { 'data' => 99 }; bless($foo, 'foo'); # Share the object share($foo); # Contents are now wiped out print("ERROR: \$foo is empty\n") if (! exists($foo->{'data'})); Therefore, populate such variables B declaring them as shared. (Scalar and scalar refs are not affected by this problem.) It is often not wise to share an object unless the class itself has been written to support sharing. For example, an object's destructor may get called multiple times, once for each thread's scope exit. Another danger is that the contents of hash-based objects will be lost due to the above mentioned limitation. See F (in the CPAN distribution of this module) for how to create a class that supports object sharing. Does not support C on arrays! Taking references to the elements of shared arrays and hashes does not autovivify the elements, and neither does slicing a shared array/hash over non-existent indices/keys autovivify the elements. C allows you to C<< share($hashref->{key}) >> and C<< share($arrayref->[idx]) >> without giving any error message. But the C<< $hashref->{key} >> or C<< $arrayref->[idx] >> is B shared, causing the error "lock can only be used on shared values" to occur when you attempt to C<< lock($hasref->{key}) >> or C<< lock($arrayref->[idx]) >> in another thread. Using L) is unreliable for testing whether or not two shared references are equivalent (e.g., when testing for circular references). Use L, instead: use threads; use threads::shared; use Scalar::Util qw(refaddr); # If ref is shared, use threads::shared's internal ID. # Otherwise, use refaddr(). my $addr1 = is_shared($ref1) || refaddr($ref1); my $addr2 = is_shared($ref2) || refaddr($ref2); if ($addr1 == $addr2) { # The refs are equivalent } L does not work properly on shared references embedded in shared structures. For example: my %foo :shared; $foo{'bar'} = shared_clone({'a'=>'x', 'b'=>'y', 'c'=>'z'}); while (my ($key, $val) = each(%{$foo{'bar'}})) { ... } Either of the following will work instead: my $ref = $foo{'bar'}; while (my ($key, $val) = each(%{$ref})) { ... } foreach my $key (keys(%{$foo{'bar'}})) { my $val = $foo{'bar'}{$key}; ... } View existing bug reports at, and submit any new bugs, problems, patches, etc. to: L =head1 SEE ALSO L Discussion Forum on CPAN: L Annotated POD for L: L Source repository: L L, L L and L Perl threads mailing list: L =head1 AUTHOR Artur Bergman Esky AT crucially DOT netE Documentation borrowed from the old Thread.pm. CPAN version produced by Jerry D. Hedden Ejdhedden AT cpan DOT orgE. =head1 LICENSE threads::shared is released under the same license as Perl. =cut PK[[Y!995.10.1/endian.phnuW+Arequire '_h2ph_pre.ph'; no warnings qw(redefine misc); unless(defined(&_ENDIAN_H)) { eval 'sub _ENDIAN_H () {1;}' unless defined(&_ENDIAN_H); require 'features.ph'; eval 'sub __LITTLE_ENDIAN () {1234;}' unless defined(&__LITTLE_ENDIAN); eval 'sub __BIG_ENDIAN () {4321;}' unless defined(&__BIG_ENDIAN); eval 'sub __PDP_ENDIAN () {3412;}' unless defined(&__PDP_ENDIAN); require 'bits/endian.ph'; unless(defined(&__FLOAT_WORD_ORDER)) { eval 'sub __FLOAT_WORD_ORDER () { &__BYTE_ORDER;}' unless defined(&__FLOAT_WORD_ORDER); } if(defined(&__USE_BSD)) { eval 'sub LITTLE_ENDIAN () { &__LITTLE_ENDIAN;}' unless defined(&LITTLE_ENDIAN); eval 'sub BIG_ENDIAN () { &__BIG_ENDIAN;}' unless defined(&BIG_ENDIAN); eval 'sub PDP_ENDIAN () { &__PDP_ENDIAN;}' unless defined(&PDP_ENDIAN); eval 'sub BYTE_ORDER () { &__BYTE_ORDER;}' unless defined(&BYTE_ORDER); } if((defined(&__BYTE_ORDER) ? &__BYTE_ORDER : undef) == (defined(&__LITTLE_ENDIAN) ? &__LITTLE_ENDIAN : undef)) { eval 'sub __LONG_LONG_PAIR { my($HI, $LO) = @_; eval q($LO, $HI); }' unless defined(&__LONG_LONG_PAIR); } elsif((defined(&__BYTE_ORDER) ? &__BYTE_ORDER : undef) == (defined(&__BIG_ENDIAN) ? &__BIG_ENDIAN : undef)) { eval 'sub __LONG_LONG_PAIR { my($HI, $LO) = @_; eval q($HI, $LO); }' unless defined(&__LONG_LONG_PAIR); } if(defined(&__USE_BSD)) { require 'bits/byteswap.ph'; if((defined(&__BYTE_ORDER) ? &__BYTE_ORDER : undef) == (defined(&__LITTLE_ENDIAN) ? &__LITTLE_ENDIAN : undef)) { eval 'sub htobe16 { my($x) = @_; eval q( &__bswap_16 ($x)); }' unless defined(&htobe16); eval 'sub htole16 { my($x) = @_; eval q(($x)); }' unless defined(&htole16); eval 'sub be16toh { my($x) = @_; eval q( &__bswap_16 ($x)); }' unless defined(&be16toh); eval 'sub le16toh { my($x) = @_; eval q(($x)); }' unless defined(&le16toh); eval 'sub htobe32 { my($x) = @_; eval q( &__bswap_32 ($x)); }' unless defined(&htobe32); eval 'sub htole32 { my($x) = @_; eval q(($x)); }' unless defined(&htole32); eval 'sub be32toh { my($x) = @_; eval q( &__bswap_32 ($x)); }' unless defined(&be32toh); eval 'sub le32toh { my($x) = @_; eval q(($x)); }' unless defined(&le32toh); eval 'sub htobe64 { my($x) = @_; eval q( &__bswap_64 ($x)); }' unless defined(&htobe64); eval 'sub htole64 { my($x) = @_; eval q(($x)); }' unless defined(&htole64); eval 'sub be64toh { my($x) = @_; eval q( &__bswap_64 ($x)); }' unless defined(&be64toh); eval 'sub le64toh { my($x) = @_; eval q(($x)); }' unless defined(&le64toh); } else { eval 'sub htobe16 { my($x) = @_; eval q(($x)); }' unless defined(&htobe16); eval 'sub htole16 { my($x) = @_; eval q( &__bswap_16 ($x)); }' unless defined(&htole16); eval 'sub be16toh { my($x) = @_; eval q(($x)); }' unless defined(&be16toh); eval 'sub le16toh { my($x) = @_; eval q( &__bswap_16 ($x)); }' unless defined(&le16toh); eval 'sub htobe32 { my($x) = @_; eval q(($x)); }' unless defined(&htobe32); eval 'sub htole32 { my($x) = @_; eval q( &__bswap_32 ($x)); }' unless defined(&htole32); eval 'sub be32toh { my($x) = @_; eval q(($x)); }' unless defined(&be32toh); eval 'sub le32toh { my($x) = @_; eval q( &__bswap_32 ($x)); }' unless defined(&le32toh); eval 'sub htobe64 { my($x) = @_; eval q(($x)); }' unless defined(&htobe64); eval 'sub htole64 { my($x) = @_; eval q( &__bswap_64 ($x)); }' unless defined(&htole64); eval 'sub be64toh { my($x) = @_; eval q(($x)); }' unless defined(&be64toh); eval 'sub le64toh { my($x) = @_; eval q( &__bswap_64 ($x)); }' unless defined(&le64toh); } } } 1; PK[[ =5.10.1/Config_heavy.plnuW+A# This file was created by configpm when Perl was built. Any changes # made to this file will be lost the next time perl is built. package Config; use strict; # use warnings; Pulls in Carp # use vars pulls in Carp ## ## This file was produced by running the Configure script. It holds all the ## definitions figured out by Configure. Should you modify one of these values, ## do not forget to propagate your changes by running "Configure -der". You may ## instead choose to run each of the .SH files by yourself, or "Configure -S". ## # ## Package name : perl5 ## Source directory : . ## Configuration time: Wed Dec 21 09:13:32 UTC 2011 ## Configured by : Debian Project ## Target system : linux barber 2.6.32-5-amd64 #1 smp thu nov 3 03:41:26 utc 2011 x86_64 gnulinux # #: Configure command line arguments. # #: Variables propagated from previous config.sh file. our $summary = <<'!END!'; Summary of my $package (revision $revision $version_patchlevel_string) configuration: $git_commit_id_title $git_commit_id$git_ancestor_line Platform: osname=$osname, osvers=$osvers, archname=$archname uname='$myuname' config_args='$config_args' hint=$hint, useposix=$useposix, d_sigaction=$d_sigaction useithreads=$useithreads, usemultiplicity=$usemultiplicity useperlio=$useperlio, d_sfio=$d_sfio, uselargefiles=$uselargefiles, usesocks=$usesocks use64bitint=$use64bitint, use64bitall=$use64bitall, uselongdouble=$uselongdouble usemymalloc=$usemymalloc, bincompat5005=undef Compiler: cc='$cc', ccflags ='$ccflags', optimize='$optimize', cppflags='$cppflags' ccversion='$ccversion', gccversion='$gccversion', gccosandvers='$gccosandvers' intsize=$intsize, longsize=$longsize, ptrsize=$ptrsize, doublesize=$doublesize, byteorder=$byteorder d_longlong=$d_longlong, longlongsize=$longlongsize, d_longdbl=$d_longdbl, longdblsize=$longdblsize ivtype='$ivtype', ivsize=$ivsize, nvtype='$nvtype', nvsize=$nvsize, Off_t='$lseektype', lseeksize=$lseeksize alignbytes=$alignbytes, prototype=$prototype Linker and Libraries: ld='$ld', ldflags ='$ldflags' libpth=$libpth libs=$libs perllibs=$perllibs libc=$libc, so=$so, useshrplib=$useshrplib, libperl=$libperl gnulibc_version='$gnulibc_version' Dynamic Linking: dlsrc=$dlsrc, dlext=$dlext, d_dlsymun=$d_dlsymun, ccdlflags='$ccdlflags' cccdlflags='$cccdlflags', lddlflags='$lddlflags' !END! my $summary_expanded; sub myconfig { return $summary_expanded if $summary_expanded; ($summary_expanded = $summary) =~ s{\$(\w+)} { my $c; if ($1 eq 'git_ancestor_line') { if ($Config::Config{git_ancestor}) { $c= "\n Ancestor: $Config::Config{git_ancestor}"; } else { $c= ""; } } else { $c = $Config::Config{$1}; } defined($c) ? $c : 'undef' }ge; $summary_expanded; } local *_ = \my $a; $_ = <<'!END!'; Author='' CONFIG='true' Date='$Date' Header='' Id='$Id' Locker='' Log='$Log' PATCHLEVEL='10' PERL_API_REVISION='5' PERL_API_SUBVERSION='0' PERL_API_VERSION='10' PERL_CONFIG_SH='true' PERL_PATCHLEVEL='' PERL_REVISION='5' PERL_SUBVERSION='1' PERL_VERSION='10' RCSfile='$RCSfile' Revision='$Revision' SUBVERSION='1' Source='' State='' _a='.a' _exe='' _o='.o' afs='false' afsroot='/afs' alignbytes='8' ansi2knr='' aphostname='/bin/hostname' api_revision='5' api_subversion='0' api_version='10' api_versionstring='5.10.0' ar='ar' archlib='/usr/lib/perl/5.10' archlibexp='/usr/lib/perl/5.10' archname64='' archname='x86_64-linux-gnu-thread-multi' archobjs='' asctime_r_proto='REENTRANT_PROTO_B_SB' awk='awk' baserev='5.0' bash='' bin='/usr/bin' binexp='/usr/bin' bison='bison' byacc='byacc' byteorder='12345678' c='' castflags='0' cat='cat' cc='cc' cccdlflags='-fPIC' ccdlflags='-Wl,-E' ccflags='-D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64' ccflags_uselargefiles='-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64' ccname='gcc' ccsymbols='' ccversion='' cf_by='Debian Project' cf_email='perl@packages.debian.org' cf_time='Wed Dec 21 09:13:32 UTC 2011' chgrp='' chmod='chmod' chown='' clocktype='clock_t' comm='comm' compress='' config_arg0='Configure' config_arg10='-Dvendorlib=/usr/share/perl5' config_arg11='-Dvendorarch=/usr/lib/perl5' config_arg12='-Dsiteprefix=/usr/local' config_arg13='-Dsitelib=/usr/local/share/perl/5.10.1' config_arg14='-Dsitearch=/usr/local/lib/perl/5.10.1' config_arg15='-Dman1dir=/usr/share/man/man1' config_arg16='-Dman3dir=/usr/share/man/man3' config_arg17='-Dsiteman1dir=/usr/local/man/man1' config_arg18='-Dsiteman3dir=/usr/local/man/man3' config_arg19='-Dman1ext=1' config_arg1='-Dusethreads' config_arg20='-Dman3ext=3perl' config_arg21='-Dpager=/usr/bin/sensible-pager' config_arg22='-Uafs' config_arg23='-Ud_csh' config_arg24='-Ud_ualarm' config_arg25='-Uusesfio' config_arg26='-Uusenm' config_arg27='-DDEBUGGING=-g' config_arg28='-Doptimize=-O2' config_arg29='-Duseshrplib' config_arg2='-Duselargefiles' config_arg30='-Dlibperl=libperl.so.5.10.1' config_arg31='-Dd_dosuid' config_arg32='-des' config_arg3='-Dccflags=-DDEBIAN' config_arg4='-Dcccdlflags=-fPIC' config_arg5='-Darchname=x86_64-linux-gnu' config_arg6='-Dprefix=/usr' config_arg7='-Dprivlib=/usr/share/perl/5.10' config_arg8='-Darchlib=/usr/lib/perl/5.10' config_arg9='-Dvendorprefix=/usr' config_argc='32' config_args='-Dusethreads -Duselargefiles -Dccflags=-DDEBIAN -Dcccdlflags=-fPIC -Darchname=x86_64-linux-gnu -Dprefix=/usr -Dprivlib=/usr/share/perl/5.10 -Darchlib=/usr/lib/perl/5.10 -Dvendorprefix=/usr -Dvendorlib=/usr/share/perl5 -Dvendorarch=/usr/lib/perl5 -Dsiteprefix=/usr/local -Dsitelib=/usr/local/share/perl/5.10.1 -Dsitearch=/usr/local/lib/perl/5.10.1 -Dman1dir=/usr/share/man/man1 -Dman3dir=/usr/share/man/man3 -Dsiteman1dir=/usr/local/man/man1 -Dsiteman3dir=/usr/local/man/man3 -Dman1ext=1 -Dman3ext=3perl -Dpager=/usr/bin/sensible-pager -Uafs -Ud_csh -Ud_ualarm -Uusesfio -Uusenm -DDEBUGGING=-g -Doptimize=-O2 -Duseshrplib -Dlibperl=libperl.so.5.10.1 -Dd_dosuid -des' contains='grep' cp='cp' cpio='' cpp='cpp' cpp_stuff='42' cppccsymbols='' cppflags='-D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include' cpplast='-' cppminus='-' cpprun='cc -E' cppstdin='cc -E' cppsymbols='_FILE_OFFSET_BITS=64 _GNU_SOURCE=1 _LARGEFILE64_SOURCE=1 _LARGEFILE_SOURCE=1 _LP64=1 _POSIX_C_SOURCE=200809L _POSIX_SOURCE=1 _REENTRANT=1 _XOPEN_SOURCE=700 _XOPEN_SOURCE_EXTENDED=1 __BIGGEST_ALIGNMENT__=16 __CHAR16_TYPE__=short\ unsigned\ int __CHAR32_TYPE__=unsigned\ int __CHAR_BIT__=8 __DBL_DENORM_MIN__=4.9406564584124654e-324 __DBL_DIG__=15 __DBL_EPSILON__=2.2204460492503131e-16 __DBL_HAS_DENORM__=1 __DBL_HAS_INFINITY__=1 __DBL_HAS_QUIET_NAN__=1 __DBL_MANT_DIG__=53 __DBL_MAX_10_EXP__=308 __DBL_MAX_EXP__=1024 __DBL_MAX__=1.7976931348623157e+308 __DBL_MIN_10_EXP__=(-307) __DBL_MIN_EXP__=(-1021) __DBL_MIN__=2.2250738585072014e-308 __DEC128_EPSILON__=1E-33DL __DEC128_MANT_DIG__=34 __DEC128_MAX_EXP__=6145 __DEC128_MAX__=9.999999999999999999999999999999999E6144DL __DEC128_MIN_EXP__=(-6142) __DEC128_MIN__=1E-6143DL __DEC128_SUBNORMAL_MIN__=0.000000000000000000000000000000001E-6143DL __DEC32_EPSILON__=1E-6DF __DEC32_MANT_DIG__=7 __DEC32_MAX_EXP__=97 __DEC32_MAX__=9.999999E96DF __DEC32_MIN_EXP__=(-94) __DEC32_MIN__=1E-95DF __DEC32_SUBNORMAL_MIN__=0.000001E-95DF __DEC64_EPSILON__=1E-15DD __DEC64_MANT_DIG__=16 __DEC64_MAX_EXP__=385 __DEC64_MAX__=9.999999999999999E384DD __DEC64_MIN_EXP__=(-382) __DEC64_MIN__=1E-383DD __DEC64_SUBNORMAL_MIN__=0.000000000000001E-383DD __DECIMAL_BID_FORMAT__=1 __DECIMAL_DIG__=21 __DEC_EVAL_METHOD__=2 __ELF__=1 __FINITE_MATH_ONLY__=0 __FLT_DENORM_MIN__=1.40129846e-45F __FLT_DIG__=6 __FLT_EPSILON__=1.19209290e-7F __FLT_EVAL_METHOD__=0 __FLT_HAS_DENORM__=1 __FLT_HAS_INFINITY__=1 __FLT_HAS_QUIET_NAN__=1 __FLT_MANT_DIG__=24 __FLT_MAX_10_EXP__=38 __FLT_MAX_EXP__=128 __FLT_MAX__=3.40282347e+38F __FLT_MIN_10_EXP__=(-37) __FLT_MIN_EXP__=(-125) __FLT_MIN__=1.17549435e-38F __FLT_RADIX__=2 __GCC_HAVE_DWARF2_CFI_ASM=1 __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1=1 __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2=1 __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4=1 __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8=1 __GLIBC_MINOR__=11 __GLIBC__=2 __GNUC_GNU_INLINE__=1 __GNUC_MINOR__=4 __GNUC_PATCHLEVEL__=5 __GNUC__=4 __GNU_LIBRARY__=6 __GXX_ABI_VERSION=1002 __INTMAX_MAX__=9223372036854775807L __INTMAX_TYPE__=long\ int __INT_MAX__=2147483647 __LDBL_DENORM_MIN__=3.64519953188247460253e-4951L __LDBL_DIG__=18 __LDBL_EPSILON__=1.08420217248550443401e-19L __LDBL_HAS_DENORM__=1 __LDBL_HAS_INFINITY__=1 __LDBL_HAS_QUIET_NAN__=1 __LDBL_MANT_DIG__=64 __LDBL_MAX_10_EXP__=4932 __LDBL_MAX_EXP__=16384 __LDBL_MAX__=1.18973149535723176502e+4932L __LDBL_MIN_10_EXP__=(-4931) __LDBL_MIN_EXP__=(-16381) __LDBL_MIN__=3.36210314311209350626e-4932L __LONG_LONG_MAX__=9223372036854775807LL __LONG_MAX__=9223372036854775807L __LP64__=1 __MMX__=1 __PTRDIFF_TYPE__=long\ int __REGISTER_PREFIX__= __SCHAR_MAX__=127 __SHRT_MAX__=32767 __SIZEOF_DOUBLE__=8 __SIZEOF_FLOAT__=4 __SIZEOF_INT__=4 __SIZEOF_LONG_DOUBLE__=16 __SIZEOF_LONG_LONG__=8 __SIZEOF_LONG__=8 __SIZEOF_POINTER__=8 __SIZEOF_PTRDIFF_T__=8 __SIZEOF_SHORT__=2 __SIZEOF_SIZE_T__=8 __SIZEOF_WCHAR_T__=4 __SIZEOF_WINT_T__=4 __SIZE_TYPE__=long\ unsigned\ int __SSE2_MATH__=1 __SSE2__=1 __SSE_MATH__=1 __SSE__=1 __STDC_HOSTED__=1 __STDC__=1 __UINTMAX_TYPE__=long\ unsigned\ int __USER_LABEL_PREFIX__= __USE_BSD=1 __USE_FILE_OFFSET64=1 __USE_GNU=1 __USE_LARGEFILE64=1 __USE_LARGEFILE=1 __USE_MISC=1 __USE_POSIX199309=1 __USE_POSIX199506=1 __USE_POSIX2=1 __USE_POSIX=1 __USE_REENTRANT=1 __USE_SVID=1 __USE_UNIX98=1 __USE_XOPEN=1 __USE_XOPEN_EXTENDED=1 __VERSION__="4.4.5" __WCHAR_MAX__=2147483647 __WCHAR_TYPE__=int __WINT_TYPE__=unsigned\ int __amd64=1 __amd64__=1 __gnu_linux__=1 __k8=1 __k8__=1 __linux=1 __linux__=1 __unix=1 __unix__=1 __x86_64=1 __x86_64__=1 linux=1 unix=1' crypt_r_proto='REENTRANT_PROTO_B_CCS' cryptlib='' csh='csh' ctermid_r_proto='0' ctime_r_proto='REENTRANT_PROTO_B_SB' d_Gconvert='gcvt((x),(n),(b))' d_PRIEUldbl='define' d_PRIFUldbl='define' d_PRIGUldbl='define' d_PRIXU64='define' d_PRId64='define' d_PRIeldbl='define' d_PRIfldbl='define' d_PRIgldbl='define' d_PRIi64='define' d_PRIo64='define' d_PRIu64='define' d_PRIx64='define' d_SCNfldbl='define' d__fwalk='undef' d_access='define' d_accessx='undef' d_aintl='undef' d_alarm='define' d_archlib='define' d_asctime64='undef' d_asctime_r='define' d_atolf='undef' d_atoll='define' d_attribute_deprecated='define' d_attribute_format='define' d_attribute_malloc='define' d_attribute_nonnull='define' d_attribute_noreturn='define' d_attribute_pure='define' d_attribute_unused='define' d_attribute_warn_unused_result='define' d_bcmp='define' d_bcopy='define' d_bsd='undef' d_bsdgetpgrp='undef' d_bsdsetpgrp='undef' d_builtin_choose_expr='define' d_builtin_expect='define' d_bzero='define' d_c99_variadic_macros='define' d_casti32='undef' d_castneg='define' d_charvspr='undef' d_chown='define' d_chroot='define' d_chsize='undef' d_class='undef' d_clearenv='define' d_closedir='define' d_cmsghdr_s='define' d_const='define' d_copysignl='define' d_cplusplus='undef' d_crypt='define' d_crypt_r='define' d_csh='undef' d_ctermid='define' d_ctermid_r='undef' d_ctime64='undef' d_ctime_r='define' d_cuserid='define' d_dbl_dig='define' d_dbminitproto='define' d_difftime64='undef' d_difftime='define' d_dir_dd_fd='undef' d_dirfd='define' d_dirnamlen='undef' d_dlerror='define' d_dlopen='define' d_dlsymun='undef' d_dosuid='define' d_drand48_r='define' d_drand48proto='define' d_dup2='define' d_eaccess='define' d_endgrent='define' d_endgrent_r='undef' d_endhent='define' d_endhostent_r='undef' d_endnent='define' d_endnetent_r='undef' d_endpent='define' d_endprotoent_r='undef' d_endpwent='define' d_endpwent_r='undef' d_endsent='define' d_endservent_r='undef' d_eofnblk='define' d_eunice='undef' d_faststdio='define' d_fchdir='define' d_fchmod='define' d_fchown='define' d_fcntl='define' d_fcntl_can_lock='define' d_fd_macros='define' d_fd_set='define' d_fds_bits='define' d_fgetpos='define' d_finite='define' d_finitel='define' d_flexfnam='define' d_flock='define' d_flockproto='define' d_fork='define' d_fp_class='undef' d_fpathconf='define' d_fpclass='undef' d_fpclassify='undef' d_fpclassl='undef' d_fpos64_t='undef' d_frexpl='define' d_fs_data_s='undef' d_fseeko='define' d_fsetpos='define' d_fstatfs='define' d_fstatvfs='define' d_fsync='define' d_ftello='define' d_ftime='undef' d_futimes='define' d_gdbm_ndbm_h_uses_prototypes='undef' d_gdbmndbm_h_uses_prototypes='undef' d_getaddrinfo='define' d_getcwd='define' d_getespwnam='undef' d_getfsstat='undef' d_getgrent='define' d_getgrent_r='define' d_getgrgid_r='define' d_getgrnam_r='define' d_getgrps='define' d_gethbyaddr='define' d_gethbyname='define' d_gethent='define' d_gethname='define' d_gethostbyaddr_r='define' d_gethostbyname_r='define' d_gethostent_r='define' d_gethostprotos='define' d_getitimer='define' d_getlogin='define' d_getlogin_r='define' d_getmnt='undef' d_getmntent='define' d_getnameinfo='define' d_getnbyaddr='define' d_getnbyname='define' d_getnent='define' d_getnetbyaddr_r='define' d_getnetbyname_r='define' d_getnetent_r='define' d_getnetprotos='define' d_getpagsz='define' d_getpbyname='define' d_getpbynumber='define' d_getpent='define' d_getpgid='define' d_getpgrp2='undef' d_getpgrp='define' d_getppid='define' d_getprior='define' d_getprotobyname_r='define' d_getprotobynumber_r='define' d_getprotoent_r='define' d_getprotoprotos='define' d_getprpwnam='undef' d_getpwent='define' d_getpwent_r='define' d_getpwnam_r='define' d_getpwuid_r='define' d_getsbyname='define' d_getsbyport='define' d_getsent='define' d_getservbyname_r='define' d_getservbyport_r='define' d_getservent_r='define' d_getservprotos='define' d_getspnam='define' d_getspnam_r='define' d_gettimeod='define' d_gmtime64='undef' d_gmtime_r='define' d_gnulibc='define' d_grpasswd='define' d_hasmntopt='define' d_htonl='define' d_ilogbl='define' d_inc_version_list='define' d_index='undef' d_inetaton='define' d_inetntop='define' d_inetpton='define' d_int64_t='define' d_isascii='define' d_isfinite='undef' d_isinf='define' d_isnan='define' d_isnanl='define' d_killpg='define' d_lchown='define' d_ldbl_dig='define' d_libm_lib_version='define' d_link='define' d_localtime64='undef' d_localtime_r='define' d_localtime_r_needs_tzset='define' d_locconv='define' d_lockf='define' d_longdbl='define' d_longlong='define' d_lseekproto='define' d_lstat='define' d_madvise='define' d_malloc_good_size='undef' d_malloc_size='undef' d_mblen='define' d_mbstowcs='define' d_mbtowc='define' d_memchr='define' d_memcmp='define' d_memcpy='define' d_memmove='define' d_memset='define' d_mkdir='define' d_mkdtemp='define' d_mkfifo='define' d_mkstemp='define' d_mkstemps='define' d_mktime64='undef' d_mktime='define' d_mmap='define' d_modfl='define' d_modfl_pow32_bug='undef' d_modflproto='define' d_mprotect='define' d_msg='define' d_msg_ctrunc='define' d_msg_dontroute='define' d_msg_oob='define' d_msg_peek='define' d_msg_proxy='define' d_msgctl='define' d_msgget='define' d_msghdr_s='define' d_msgrcv='define' d_msgsnd='define' d_msync='define' d_munmap='define' d_mymalloc='undef' d_ndbm='define' d_ndbm_h_uses_prototypes='undef' d_nice='define' d_nl_langinfo='define' d_nv_preserves_uv='undef' d_nv_zero_is_allbits_zero='define' d_off64_t='define' d_old_pthread_create_joinable='undef' d_oldpthreads='undef' d_oldsock='undef' d_open3='define' d_pathconf='define' d_pause='define' d_perl_otherlibdirs='undef' d_phostname='undef' d_pipe='define' d_poll='define' d_portable='define' d_printf_format_null='undef' d_procselfexe='define' d_pseudofork='undef' d_pthread_atfork='define' d_pthread_attr_setscope='define' d_pthread_yield='define' d_pwage='undef' d_pwchange='undef' d_pwclass='undef' d_pwcomment='undef' d_pwexpire='undef' d_pwgecos='define' d_pwpasswd='define' d_pwquota='undef' d_qgcvt='define' d_quad='define' d_random_r='define' d_readdir64_r='define' d_readdir='define' d_readdir_r='define' d_readlink='define' d_readv='define' d_recvmsg='define' d_rename='define' d_rewinddir='define' d_rmdir='define' d_safebcpy='undef' d_safemcpy='undef' d_sanemcmp='define' d_sbrkproto='define' d_scalbnl='define' d_sched_yield='define' d_scm_rights='define' d_seekdir='define' d_select='define' d_sem='define' d_semctl='define' d_semctl_semid_ds='define' d_semctl_semun='define' d_semget='define' d_semop='define' d_sendmsg='define' d_setegid='define' d_seteuid='define' d_setgrent='define' d_setgrent_r='undef' d_setgrps='define' d_sethent='define' d_sethostent_r='undef' d_setitimer='define' d_setlinebuf='define' d_setlocale='define' d_setlocale_r='undef' d_setnent='define' d_setnetent_r='undef' d_setpent='define' d_setpgid='define' d_setpgrp2='undef' d_setpgrp='define' d_setprior='define' d_setproctitle='undef' d_setprotoent_r='undef' d_setpwent='define' d_setpwent_r='undef' d_setregid='define' d_setresgid='define' d_setresuid='define' d_setreuid='define' d_setrgid='undef' d_setruid='undef' d_setsent='define' d_setservent_r='undef' d_setsid='define' d_setvbuf='define' d_sfio='undef' d_shm='define' d_shmat='define' d_shmatprototype='define' d_shmctl='define' d_shmdt='define' d_shmget='define' d_sigaction='define' d_signbit='define' d_sigprocmask='define' d_sigsetjmp='define' d_sitearch='define' d_snprintf='define' d_sockatmark='define' d_sockatmarkproto='define' d_socket='define' d_socklen_t='define' d_sockpair='define' d_socks5_init='undef' d_sprintf_returns_strlen='define' d_sqrtl='define' d_srand48_r='define' d_srandom_r='define' d_sresgproto='define' d_sresuproto='define' d_statblks='define' d_statfs_f_flags='define' d_statfs_s='define' d_statvfs='define' d_stdio_cnt_lval='undef' d_stdio_ptr_lval='define' d_stdio_ptr_lval_nochange_cnt='undef' d_stdio_ptr_lval_sets_cnt='define' d_stdio_stream_array='undef' d_stdiobase='define' d_stdstdio='define' d_strchr='define' d_strcoll='define' d_strctcpy='define' d_strerrm='strerror(e)' d_strerror='define' d_strerror_r='define' d_strftime='define' d_strlcat='undef' d_strlcpy='undef' d_strtod='define' d_strtol='define' d_strtold='define' d_strtoll='define' d_strtoq='define' d_strtoul='define' d_strtoull='define' d_strtouq='define' d_strxfrm='define' d_suidsafe='undef' d_symlink='define' d_syscall='define' d_syscallproto='define' d_sysconf='define' d_sysernlst='' d_syserrlst='define' d_system='define' d_tcgetpgrp='define' d_tcsetpgrp='define' d_telldir='define' d_telldirproto='define' d_time='define' d_timegm='define' d_times='define' d_tm_tm_gmtoff='define' d_tm_tm_zone='define' d_tmpnam_r='define' d_truncate='define' d_ttyname_r='define' d_tzname='define' d_u32align='define' d_ualarm='undef' d_umask='define' d_uname='define' d_union_semun='undef' d_unordered='undef' d_unsetenv='define' d_usleep='define' d_usleepproto='define' d_ustat='define' d_vendorarch='define' d_vendorbin='define' d_vendorlib='define' d_vendorscript='define' d_vfork='undef' d_void_closedir='undef' d_voidsig='define' d_voidtty='' d_volatile='define' d_vprintf='define' d_vsnprintf='define' d_wait4='define' d_waitpid='define' d_wcstombs='define' d_wctomb='define' d_writev='define' d_xenix='undef' date='date' db_hashtype='u_int32_t' db_prefixtype='size_t' db_version_major='4' db_version_minor='7' db_version_patch='25' defvoidused='15' direntrytype='struct dirent' dlext='so' dlsrc='dl_dlopen.xs' doublesize='8' drand01='drand48()' drand48_r_proto='REENTRANT_PROTO_I_ST' dtrace='' dynamic_ext='B Compress/Raw/Bzip2 Compress/Raw/Zlib Cwd DB_File Data/Dumper Devel/DProf Devel/PPPort Devel/Peek Digest/MD5 Digest/SHA Encode Fcntl File/Glob Filter/Util/Call GDBM_File Hash/Util Hash/Util/FieldHash I18N/Langinfo IO IO/Compress IPC/SysV List/Util MIME/Base64 Math/BigInt/FastCalc NDBM_File ODBM_File Opcode POSIX PerlIO/encoding PerlIO/scalar PerlIO/via SDBM_File Socket Storable Sys/Hostname Sys/Syslog Text/Soundex Time/HiRes Time/Piece Unicode/Normalize XS/APItest XS/Typemap attrs mro re threads threads/shared' eagain='EAGAIN' ebcdic='undef' echo='echo' egrep='egrep' emacs='' endgrent_r_proto='0' endhostent_r_proto='0' endnetent_r_proto='0' endprotoent_r_proto='0' endpwent_r_proto='0' endservent_r_proto='0' eunicefix=':' exe_ext='' expr='expr' extensions='B Compress/Raw/Bzip2 Compress/Raw/Zlib Cwd DB_File Data/Dumper Devel/DProf Devel/PPPort Devel/Peek Digest/MD5 Digest/SHA Encode Fcntl File/Glob Filter/Util/Call GDBM_File Hash/Util Hash/Util/FieldHash I18N/Langinfo IO IO/Compress IPC/SysV List/Util MIME/Base64 Math/BigInt/FastCalc NDBM_File ODBM_File Opcode POSIX PerlIO/encoding PerlIO/scalar PerlIO/via SDBM_File Socket Storable Sys/Hostname Sys/Syslog Text/Soundex Time/HiRes Time/Piece Unicode/Normalize XS/APItest XS/Typemap attrs mro re threads threads/shared Attribute/Handlers Errno Module/Pluggable Safe Test/Harness' extern_C='extern' extras='' fflushNULL='define' fflushall='undef' find='' firstmakefile='makefile' flex='' fpossize='16' fpostype='fpos_t' freetype='void' from=':' full_ar='/usr/bin/ar' full_csh='csh' full_sed='/bin/sed' gccansipedantic='' gccosandvers='' gccversion='4.4.5' getgrent_r_proto='REENTRANT_PROTO_I_SBWR' getgrgid_r_proto='REENTRANT_PROTO_I_TSBWR' getgrnam_r_proto='REENTRANT_PROTO_I_CSBWR' gethostbyaddr_r_proto='REENTRANT_PROTO_I_TsISBWRE' gethostbyname_r_proto='REENTRANT_PROTO_I_CSBWRE' gethostent_r_proto='REENTRANT_PROTO_I_SBWRE' getlogin_r_proto='REENTRANT_PROTO_I_BW' getnetbyaddr_r_proto='REENTRANT_PROTO_I_uISBWRE' getnetbyname_r_proto='REENTRANT_PROTO_I_CSBWRE' getnetent_r_proto='REENTRANT_PROTO_I_SBWRE' getprotobyname_r_proto='REENTRANT_PROTO_I_CSBWR' getprotobynumber_r_proto='REENTRANT_PROTO_I_ISBWR' getprotoent_r_proto='REENTRANT_PROTO_I_SBWR' getpwent_r_proto='REENTRANT_PROTO_I_SBWR' getpwnam_r_proto='REENTRANT_PROTO_I_CSBWR' getpwuid_r_proto='REENTRANT_PROTO_I_TSBWR' getservbyname_r_proto='REENTRANT_PROTO_I_CCSBWR' getservbyport_r_proto='REENTRANT_PROTO_I_ICSBWR' getservent_r_proto='REENTRANT_PROTO_I_SBWR' getspnam_r_proto='REENTRANT_PROTO_I_CSBWR' gidformat='"u"' gidsign='1' gidsize='4' gidtype='gid_t' glibpth='/usr/shlib /lib /usr/lib /usr/lib/386 /lib/386 /usr/ccs/lib /usr/ucblib /usr/local/lib /lib64 /usr/lib64 /usr/local/lib64 ' gmake='gmake' gmtime_r_proto='REENTRANT_PROTO_S_TS' gnulibc_version='2.11.3' grep='grep' groupcat='cat /etc/group' groupstype='gid_t' gzip='gzip' h_fcntl='false' h_sysfile='true' hint='recommended' hostcat='cat /etc/hosts' html1dir=' ' html1direxp='' html3dir=' ' html3direxp='' i16size='2' i16type='short' i32size='4' i32type='int' i64size='8' i64type='long' i8size='1' i8type='signed char' i_arpainet='define' i_assert='define' i_bsdioctl='' i_crypt='define' i_db='define' i_dbm='define' i_dirent='define' i_dld='undef' i_dlfcn='define' i_fcntl='undef' i_float='define' i_fp='undef' i_fp_class='undef' i_gdbm='define' i_gdbm_ndbm='define' i_gdbmndbm='undef' i_grp='define' i_ieeefp='undef' i_inttypes='define' i_langinfo='define' i_libutil='undef' i_limits='define' i_locale='define' i_machcthr='undef' i_malloc='define' i_mallocmalloc='undef' i_math='define' i_memory='undef' i_mntent='define' i_ndbm='undef' i_netdb='define' i_neterrno='undef' i_netinettcp='define' i_niin='define' i_poll='define' i_prot='undef' i_pthread='define' i_pwd='define' i_rpcsvcdbm='undef' i_sfio='undef' i_sgtty='undef' i_shadow='define' i_socks='undef' i_stdarg='define' i_stddef='define' i_stdlib='define' i_string='define' i_sunmath='undef' i_sysaccess='undef' i_sysdir='define' i_sysfile='define' i_sysfilio='undef' i_sysin='undef' i_sysioctl='define' i_syslog='define' i_sysmman='define' i_sysmode='undef' i_sysmount='define' i_sysndir='undef' i_sysparam='define' i_syspoll='define' i_sysresrc='define' i_syssecrt='undef' i_sysselct='define' i_syssockio='undef' i_sysstat='define' i_sysstatfs='define' i_sysstatvfs='define' i_systime='define' i_systimek='undef' i_systimes='define' i_systypes='define' i_sysuio='define' i_sysun='define' i_sysutsname='define' i_sysvfs='define' i_syswait='define' i_termio='undef' i_termios='define' i_time='define' i_unistd='define' i_ustat='define' i_utime='define' i_values='define' i_varargs='undef' i_varhdr='stdarg.h' i_vfork='undef' ignore_versioned_solibs='y' inc_version_list='5.10.0' inc_version_list_init='"5.10.0",0' incpath='' inews='' initialinstalllocation='/usr/bin' installarchlib='/usr/lib/perl/5.10' installbin='/usr/bin' installhtml1dir='' installhtml3dir='' installman1dir='/usr/share/man/man1' installman3dir='/usr/share/man/man3' installprefix='/usr' installprefixexp='/usr' installprivlib='/usr/share/perl/5.10' installscript='/usr/bin' installsitearch='/usr/local/lib/perl/5.10.1' installsitebin='/usr/local/bin' installsitehtml1dir='' installsitehtml3dir='' installsitelib='/usr/local/share/perl/5.10.1' installsiteman1dir='/usr/local/man/man1' installsiteman3dir='/usr/local/man/man3' installsitescript='/usr/local/bin' installstyle='lib/perl5' installusrbinperl='undef' installvendorarch='/usr/lib/perl5' installvendorbin='/usr/bin' installvendorhtml1dir='' installvendorhtml3dir='' installvendorlib='/usr/share/perl5' installvendorman1dir='/usr/share/man/man1' installvendorman3dir='/usr/share/man/man3' installvendorscript='/usr/bin' intsize='4' issymlink='test -h' ivdformat='"ld"' ivsize='8' ivtype='long' known_extensions='B Compress/Raw/Bzip2 Compress/Raw/Zlib Cwd DB_File Data/Dumper Devel/DProf Devel/PPPort Devel/Peek Digest/MD5 Digest/SHA Encode Fcntl File/Glob Filter/Util/Call GDBM_File Hash/Util Hash/Util/FieldHash I18N/Langinfo IO IO/Compress IPC/SysV List/Util MIME/Base64 Math/BigInt/FastCalc NDBM_File ODBM_File Opcode POSIX PerlIO/encoding PerlIO/scalar PerlIO/via SDBM_File Socket Storable Sys/Hostname Sys/Syslog Text/Soundex Time/HiRes Time/Piece Unicode/Normalize Win32 Win32API/File Win32CORE XS/APItest XS/Typemap attrs mro re threads threads/shared' ksh='' ld='cc' lddlflags='-shared -O2 -g -L/usr/local/lib -fstack-protector' ldflags=' -fstack-protector -L/usr/local/lib' ldflags_uselargefiles='' ldlibpthname='LD_LIBRARY_PATH' less='less' lib_ext='.a' libc='/lib/libc-2.11.3.so' libdb_needs_pthread='N' libperl='libperl.so.5.10.1' libpth='/usr/local/lib /lib /usr/lib /lib64 /usr/lib64' libs='-lgdbm -lgdbm_compat -ldb -ldl -lm -lpthread -lc -lcrypt' libsdirs=' /usr/lib' libsfiles=' libgdbm.so libgdbm_compat.so libdb.so libdl.so libm.so libpthread.so libc.so libcrypt.so' libsfound=' /usr/lib/libgdbm.so /usr/lib/libgdbm_compat.so /usr/lib/libdb.so /usr/lib/libdl.so /usr/lib/libm.so /usr/lib/libpthread.so /usr/lib/libc.so /usr/lib/libcrypt.so' libspath=' /usr/local/lib /lib /usr/lib /lib64 /usr/lib64' libswanted='gdbm gdbm_compat db dl m pthread c crypt gdbm_compat' libswanted_uselargefiles='' line='' lint='' lkflags='' ln='ln' lns='/bin/ln -s' localtime_r_proto='REENTRANT_PROTO_S_TS' locincpth='/usr/local/include /opt/local/include /usr/gnu/include /opt/gnu/include /usr/GNU/include /opt/GNU/include' loclibpth='/usr/local/lib /opt/local/lib /usr/gnu/lib /opt/gnu/lib /usr/GNU/lib /opt/GNU/lib' longdblsize='16' longlongsize='8' longsize='8' lp='' lpr='' ls='ls' lseeksize='8' lseektype='off_t' mad='undef' madlyh='' madlyobj='' madlysrc='' mail='' mailx='' make='make' make_set_make='#' mallocobj='' mallocsrc='' malloctype='void *' man1dir='/usr/share/man/man1' man1direxp='/usr/share/man/man1' man1ext='1p' man3dir='/usr/share/man/man3' man3direxp='/usr/share/man/man3' man3ext='3pm' mips_type='' mistrustnm='' mkdir='mkdir' mmaptype='void *' modetype='mode_t' more='more' multiarch='undef' mv='' myarchname='x86_64-linux' mydomain='' myhostname='localhost' myuname='linux barber 2.6.32-5-amd64 #1 smp thu nov 3 03:41:26 utc 2011 x86_64 gnulinux ' n='-n' need_va_copy='define' netdb_hlen_type='size_t' netdb_host_type='char *' netdb_name_type='const char *' netdb_net_type='in_addr_t' nm='nm' nm_opt='' nm_so_opt='--dynamic' nonxs_ext='Attribute/Handlers Errno Module/Pluggable Safe Test/Harness' nroff='nroff' nvEUformat='"E"' nvFUformat='"F"' nvGUformat='"G"' nv_overflows_integers_at='256.0*256.0*256.0*256.0*256.0*256.0*2.0*2.0*2.0*2.0*2.0' nv_preserves_uv_bits='53' nveformat='"e"' nvfformat='"f"' nvgformat='"g"' nvsize='8' nvtype='double' o_nonblock='O_NONBLOCK' obj_ext='.o' old_pthread_create_joinable='' optimize='-O2 -g' orderlib='false' osname='linux' osvers='2.6.32-5-amd64' otherlibdirs=' ' package='perl5' pager='/usr/bin/sensible-pager' passcat='cat /etc/passwd' patchlevel='10' path_sep=':' perl5='/usr/bin/perl' perl='' perl_patchlevel='' perladmin='root@localhost' perllibs='-ldl -lm -lpthread -lc -lcrypt' perlpath='/usr/bin/perl' pg='pg' phostname='hostname' pidtype='pid_t' plibpth='' pmake='' pr='' prefix='/usr' prefixexp='/usr' privlib='/usr/share/perl/5.10' privlibexp='/usr/share/perl/5.10' procselfexe='"/proc/self/exe"' prototype='define' ptrsize='8' quadkind='2' quadtype='long' randbits='48' randfunc='drand48' random_r_proto='REENTRANT_PROTO_I_St' randseedtype='long' ranlib=':' rd_nodata='-1' readdir64_r_proto='REENTRANT_PROTO_I_TSR' readdir_r_proto='REENTRANT_PROTO_I_TSR' revision='5' rm='rm' rm_try='/bin/rm -f try try a.out .out try.[cho] try..o core core.try* try.core*' rmail='' run='' runnm='false' sGMTIME_max='67768036191676799' sGMTIME_min='-62167219200' sLOCALTIME_max='67768036191676799' sLOCALTIME_min='-62167219200' sPRIEUldbl='"LE"' sPRIFUldbl='"LF"' sPRIGUldbl='"LG"' sPRIXU64='"lX"' sPRId64='"ld"' sPRIeldbl='"Le"' sPRIfldbl='"Lf"' sPRIgldbl='"Lg"' sPRIi64='"li"' sPRIo64='"lo"' sPRIu64='"lu"' sPRIx64='"lx"' sSCNfldbl='"Lf"' sched_yield='sched_yield()' scriptdir='/usr/bin' scriptdirexp='/usr/bin' sed='sed' seedfunc='srand48' selectminbits='64' selecttype='fd_set *' sendmail='' setgrent_r_proto='0' sethostent_r_proto='0' setlocale_r_proto='0' setnetent_r_proto='0' setprotoent_r_proto='0' setpwent_r_proto='0' setservent_r_proto='0' sh='/bin/sh' shar='' sharpbang='#!' shmattype='void *' shortsize='2' shrpenv='' shsharp='true' sig_count='65' sig_name='ZERO HUP INT QUIT ILL TRAP ABRT BUS FPE KILL USR1 SEGV USR2 PIPE ALRM TERM STKFLT CHLD CONT STOP TSTP TTIN TTOU URG XCPU XFSZ VTALRM PROF WINCH IO PWR SYS NUM32 NUM33 RTMIN NUM35 NUM36 NUM37 NUM38 NUM39 NUM40 NUM41 NUM42 NUM43 NUM44 NUM45 NUM46 NUM47 NUM48 NUM49 NUM50 NUM51 NUM52 NUM53 NUM54 NUM55 NUM56 NUM57 NUM58 NUM59 NUM60 NUM61 NUM62 NUM63 RTMAX IOT CLD POLL UNUSED ' sig_name_init='"ZERO", "HUP", "INT", "QUIT", "ILL", "TRAP", "ABRT", "BUS", "FPE", "KILL", "USR1", "SEGV", "USR2", "PIPE", "ALRM", "TERM", "STKFLT", "CHLD", "CONT", "STOP", "TSTP", "TTIN", "TTOU", "URG", "XCPU", "XFSZ", "VTALRM", "PROF", "WINCH", "IO", "PWR", "SYS", "NUM32", "NUM33", "RTMIN", "NUM35", "NUM36", "NUM37", "NUM38", "NUM39", "NUM40", "NUM41", "NUM42", "NUM43", "NUM44", "NUM45", "NUM46", "NUM47", "NUM48", "NUM49", "NUM50", "NUM51", "NUM52", "NUM53", "NUM54", "NUM55", "NUM56", "NUM57", "NUM58", "NUM59", "NUM60", "NUM61", "NUM62", "NUM63", "RTMAX", "IOT", "CLD", "POLL", "UNUSED", 0' sig_num='0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 6 17 29 31 ' sig_num_init='0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 6, 17, 29, 31, 0' sig_size='69' signal_t='void' sitearch='/usr/local/lib/perl/5.10.1' sitearchexp='/usr/local/lib/perl/5.10.1' sitebin='/usr/local/bin' sitebinexp='/usr/local/bin' sitehtml1dir='' sitehtml1direxp='' sitehtml3dir='' sitehtml3direxp='' sitelib='/usr/local/share/perl/5.10.1' sitelib_stem='' sitelibexp='/usr/local/share/perl/5.10.1' siteman1dir='/usr/local/man/man1' siteman1direxp='/usr/local/man/man1' siteman3dir='/usr/local/man/man3' siteman3direxp='/usr/local/man/man3' siteprefix='/usr/local' siteprefixexp='/usr/local' sitescript='/usr/local/bin' sitescriptexp='/usr/local/bin' sizesize='8' sizetype='size_t' sleep='' smail='' so='so' sockethdr='' socketlib='' socksizetype='socklen_t' sort='sort' spackage='Perl5' spitshell='cat' srand48_r_proto='REENTRANT_PROTO_I_LS' srandom_r_proto='REENTRANT_PROTO_I_TS' src='.' ssizetype='ssize_t' startperl='#!/usr/bin/perl' startsh='#!/bin/sh' static_ext=' ' stdchar='char' stdio_base='((fp)->_IO_read_base)' stdio_bufsiz='((fp)->_IO_read_end - (fp)->_IO_read_base)' stdio_cnt='((fp)->_IO_read_end - (fp)->_IO_read_ptr)' stdio_filbuf='' stdio_ptr='((fp)->_IO_read_ptr)' stdio_stream_array='' strerror_r_proto='REENTRANT_PROTO_B_IBW' strings='/usr/include/string.h' submit='' subversion='1' sysman='/usr/share/man/man1' tail='' tar='' targetarch='' tbl='' tee='' test='test' timeincl='/usr/include/sys/time.h /usr/include/time.h ' timetype='time_t' tmpnam_r_proto='REENTRANT_PROTO_B_B' to=':' touch='touch' tr='tr' trnl='\n' troff='' ttyname_r_proto='REENTRANT_PROTO_I_IBW' u16size='2' u16type='unsigned short' u32size='4' u32type='unsigned int' u64size='8' u64type='unsigned long' u8size='1' u8type='unsigned char' uidformat='"u"' uidsign='1' uidsize='4' uidtype='uid_t' uname='uname' uniq='uniq' uquadtype='unsigned long' use5005threads='undef' use64bitall='define' use64bitint='define' usecrosscompile='undef' usedevel='undef' usedl='define' usedtrace='undef' usefaststdio='undef' useithreads='define' uselargefiles='define' uselongdouble='undef' usemallocwrap='define' usemorebits='undef' usemultiplicity='define' usemymalloc='n' usenm='false' useopcode='true' useperlio='define' useposix='true' usereentrant='undef' userelocatableinc='undef' usesfio='false' useshrplib='true' usesitecustomize='undef' usesocks='undef' usethreads='define' usevendorprefix='define' usevfork='false' usrinc='/usr/include' uuname='' uvXUformat='"lX"' uvoformat='"lo"' uvsize='8' uvtype='unsigned long' uvuformat='"lu"' uvxformat='"lx"' vendorarch='/usr/lib/perl5' vendorarchexp='/usr/lib/perl5' vendorbin='/usr/bin' vendorbinexp='/usr/bin' vendorhtml1dir=' ' vendorhtml1direxp='' vendorhtml3dir=' ' vendorhtml3direxp='' vendorlib='/usr/share/perl5' vendorlib_stem='' vendorlibexp='/usr/share/perl5' vendorman1dir='/usr/share/man/man1' vendorman1direxp='/usr/share/man/man1' vendorman3dir='/usr/share/man/man3' vendorman3direxp='/usr/share/man/man3' vendorprefix='/usr' vendorprefixexp='/usr' vendorscript='/usr/bin' vendorscriptexp='/usr/bin' version='5.10.1' version_patchlevel_string='version 10 subversion 1' versiononly='undef' vi='' voidflags='15' xlibpth='/usr/lib/386 /lib/386' yacc='yacc' yaccflags='' zcat='' zip='zip' !END! my $i = 0; foreach my $c (8,7,6,5,4,3,2) { $i |= ord($c); $i <<= 8 } $i |= ord(1); our $byteorder = join('', unpack('aaaaaaaa', pack('L!', $i))); s/(byteorder=)(['"]).*?\2/$1$2$Config::byteorder$2/m; my $config_sh_len = length $_; our $Config_SH_expanded = "\n$_" . << 'EOVIRTUAL'; ccflags_nolargefiles='-D_REENTRANT -D_GNU_SOURCE -DDEBIAN -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include ' ldflags_nolargefiles=' -fstack-protector -L/usr/local/lib' libs_nolargefiles='-lgdbm -lgdbm_compat -ldb -ldl -lm -lpthread -lc -lcrypt' libswanted_nolargefiles='gdbm gdbm_compat db dl m pthread c crypt gdbm_compat' EOVIRTUAL eval { # do not have hairy conniptions if this isnt available require 'Config_git.pl'; $Config_SH_expanded .= $Config::Git_Data; 1; } or warn "Warning: failed to load Config_git.pl, something strange about this perl...\n"; # Search for it in the big string sub fetch_string { my($self, $key) = @_; # We only have ' delimted. my $start = index($Config_SH_expanded, "\n$key=\'"); # Start can never be -1 now, as we've rigged the long string we're # searching with an initial dummy newline. return undef if $start == -1; $start += length($key) + 3; my $value = substr($Config_SH_expanded, $start, index($Config_SH_expanded, "'\n", $start) - $start); # So we can say "if $Config{'foo'}". $value = undef if $value eq 'undef'; $self->{$key} = $value; # cache it } my $prevpos = 0; sub FIRSTKEY { $prevpos = 0; substr($Config_SH_expanded, 1, index($Config_SH_expanded, '=') - 1 ); } sub NEXTKEY { my $pos = index($Config_SH_expanded, qq('\n), $prevpos) + 2; my $len = index($Config_SH_expanded, "=", $pos) - $pos; $prevpos = $pos; $len > 0 ? substr($Config_SH_expanded, $pos, $len) : undef; } sub EXISTS { return 1 if exists($_[0]->{$_[1]}); return(index($Config_SH_expanded, "\n$_[1]='") != -1 ); } sub STORE { die "\%Config::Config is read-only\n" } *DELETE = \&STORE; *CLEAR = \&STORE; sub config_sh { substr $Config_SH_expanded, 1, $config_sh_len; } sub config_re { my $re = shift; return map { chomp; $_ } grep eval{ /^(?:$re)=/ }, split /^/, $Config_SH_expanded; } sub config_vars { # implements -V:cfgvar option (see perlrun -V:) foreach (@_) { # find optional leading, trailing colons; and query-spec my ($notag,$qry,$lncont) = m/^(:)?(.*?)(:)?$/; # flags fore and aft, # map colon-flags to print decorations my $prfx = $notag ? '': "$qry="; # tag-prefix for print my $lnend = $lncont ? ' ' : ";\n"; # line ending for print # all config-vars are by definition \w only, any \W means regex if ($qry =~ /\W/) { my @matches = config_re($qry); print map "$_$lnend", @matches ? @matches : "$qry: not found" if !$notag; print map { s/\w+=//; "$_$lnend" } @matches ? @matches : "$qry: not found" if $notag; } else { my $v = (exists $Config::Config{$qry}) ? $Config::Config{$qry} : 'UNKNOWN'; $v = 'undef' unless defined $v; print "${prfx}'${v}'$lnend"; } } } # Called by the real AUTOLOAD sub launcher { undef &AUTOLOAD; goto \&$Config::AUTOLOAD; } 1; PK[[(oSS5.10.1/wait.phnuW+Arequire '_h2ph_pre.ph'; no warnings qw(redefine misc); require 'sys/wait.ph'; 1; PK[[Buu5.10.1/Config.podnuW+A=head1 NAME Config - access Perl configuration information =head1 SYNOPSIS use Config; if ($Config{usethreads}) { print "has thread support\n" } use Config qw(myconfig config_sh config_vars config_re); print myconfig(); print config_sh(); print config_re(); config_vars(qw(osname archname)); =head1 DESCRIPTION The Config module contains all the information that was available to the C program at Perl build time (over 900 values). Shell variables from the F file (written by Configure) are stored in the readonly-variable C<%Config>, indexed by their names. Values stored in config.sh as 'undef' are returned as undefined values. The perl C function can be used to check if a named variable exists. For a description of the variables, please have a look at the Glossary file, as written in the Porting folder, or use the url: http://perl5.git.perl.org/perl.git/blob/HEAD:/Porting/Glossary =over 4 =item myconfig() Returns a textual summary of the major perl configuration values. See also C<-V> in L. =item config_sh() Returns the entire perl configuration information in the form of the original config.sh shell variable assignment script. =item config_re($regex) Like config_sh() but returns, as a list, only the config entries who's names match the $regex. =item config_vars(@names) Prints to STDOUT the values of the named configuration variable. Each is printed on a separate line in the form: name='value'; Names which are unknown are output as C. See also C<-V:name> in L. =back =head1 EXAMPLE Here's a more sophisticated example of using %Config: use Config; use strict; my %sig_num; my @sig_name; unless($Config{sig_name} && $Config{sig_num}) { die "No sigs?"; } else { my @names = split ' ', $Config{sig_name}; @sig_num{@names} = split ' ', $Config{sig_num}; foreach (@names) { $sig_name[$sig_num{$_}] ||= $_; } } print "signal #17 = $sig_name[17]\n"; if ($sig_num{ALRM}) { print "SIGALRM is $sig_num{ALRM}\n"; } =head1 WARNING Because this information is not stored within the perl executable itself it is possible (but unlikely) that the information does not relate to the actual perl binary which is being used to access it. The Config module is installed into the architecture and version specific library directory ($Config{installarchlib}) and it checks the perl version number when loaded. The values stored in config.sh may be either single-quoted or double-quoted. Double-quoted strings are handy for those cases where you need to include escape sequences in the strings. To avoid runtime variable interpolation, any C<$> and C<@> characters are replaced by C<\$> and C<\@>, respectively. This isn't foolproof, of course, so don't embed C<\$> or C<\@> in double-quoted strings unless you're willing to deal with the consequences. (The slashes will end up escaped and the C<$> or C<@> will trigger variable interpolation) =head1 GLOSSARY Most C variables are determined by the C script on platforms supported by it (which is most UNIX platforms). Some platforms have custom-made C variables, and may thus not have some of the variables described below, or may have extraneous variables specific to that particular port. See the port specific documentation in such cases. =cut =head2 _ =over 4 =cut =item C<_a> From F: This variable defines the extension used for ordinary library files. For unix, it is F<.a>. The F<.> is included. Other possible values include F<.lib>. =item C<_exe> From F: This variable defines the extension used for executable files. C, Cygwin and F use F<.exe>. Stratus C uses F<.pm>. On operating systems which do not require a specific extension for executable files, this variable is empty. =item C<_o> From F: This variable defines the extension used for object files. For unix, it is F<.o>. The F<.> is included. Other possible values include F<.obj>. =back =cut =head2 a =over 4 =cut =item C From F: This variable is set to C if C (Andrew File System) is used on the system, C otherwise. It is possible to override this with a hint value or command line option, but you'd better know what you are doing. =item C From F: This variable is by default set to F. In the unlikely case this is not the correct root, it is possible to override this with a hint value or command line option. This will be used in subsequent tests for AFSness in the configure and test process. =item C From F: This variable holds the number of bytes required to align a double-- or a long double when applicable. Usual values are 2, 4 and 8. The default is eight, for safety. =item C From F: This variable is set if the user needs to run ansi2knr. Currently, this is not supported, so we just abort. =item C From F: This variable contains the command which can be used to compute the host name. The command is fully qualified by its absolute path, to make it safe when used by a process with super-user privileges. =item C From F: The three variables, api_revision, api_version, and api_subversion, specify the version of the oldest perl binary compatible with the present perl. In a full version string such as F<5.6.1>, api_revision is the C<5>. Prior to 5.5.640, the format was a floating point number, like 5.00563. F:incpush() and F will automatically search in F<$sitelib/.>. for older directories back to the limit specified by these api_ variables. This is only useful if you have a perl library directory tree structured like the default one. See C for how this works. The versioned site_perl directory was introduced in 5.005, so that is the lowest possible value. The version list appropriate for the current system is determined in F. C To do: Since compatibility can depend on compile time options (such as bincompat, longlong, etc.) it should (perhaps) be set by Configure, but currently it isn't. Currently, we read a hard-wired value from F. Perhaps what we ought to do is take the hard-wired value from F but then modify it if the current Configure options warrant. F then would use an #ifdef guard. =item C From F: The three variables, api_revision, api_version, and api_subversion, specify the version of the oldest perl binary compatible with the present perl. In a full version string such as F<5.6.1>, api_subversion is the C<1>. See api_revision for full details. =item C From F: The three variables, api_revision, api_version, and api_subversion, specify the version of the oldest perl binary compatible with the present perl. In a full version string such as F<5.6.1>, api_version is the C<6>. See api_revision for full details. As a special case, 5.5.0 is rendered in the old-style as 5.005. (In the 5.005_0x maintenance series, this was the only versioned directory in $sitelib.) =item C From F: This variable combines api_revision, api_version, and api_subversion in a format such as 5.6.1 (or 5_6_1) suitable for use as a directory name. This is filesystem dependent. =item C From F: This variable is used internally by Configure to determine the full pathname (if any) of the ar program. After Configure runs, the value is reset to a plain C and is not useful. =item C From F: This variable holds the name of the directory in which the user wants to put architecture-dependent public library files for $package. It is most often a local directory such as F. Programs using this variable must be prepared to deal with filename expansion. =item C From F: This variable is the same as the archlib variable, but is filename expanded at configuration time, for convenient use. =item C From F: This variable is a short name to characterize the current architecture. It is used mainly to construct the default archlib. =item C From F: This variable is used for the 64-bitness part of $archname. =item C From F: This variable defines any additional objects that must be linked in with the program on this architecture. On unix, it is usually empty. It is typically used to include emulations of unix calls or other facilities. For perl on F, for example, this would include F. =item C From F: This variable encodes the prototype of asctime_r. It is zero if d_asctime_r is undef, and one of the C macros of F if d_asctime_r is defined. =item C From F: This variable is used internally by Configure to determine the full pathname (if any) of the awk program. After Configure runs, the value is reset to a plain C and is not useful. =back =cut =head2 b =over 4 =cut =item C From F: The base revision level of this package, from the F<.package> file. =item C From F: This variable is defined but not used by Configure. The value is the empty string and is not useful. =item C From F: This variable holds the name of the directory in which the user wants to put publicly executable images for the package in question. It is most often a local directory such as F. Programs using this variable must be prepared to deal with F<~name> substitution. =item C From F: This is the same as the bin variable, but is filename expanded at configuration time, for use in your makefiles. =item C From F: This variable is used internally by Configure to determine the full pathname (if any) of the bison program. After Configure runs, the value is reset to a plain C and is not useful. =item C From F: This variable is used internally by Configure to determine the full pathname (if any) of the byacc program. After Configure runs, the value is reset to a plain C and is not useful. =item C From F: This variable holds the byte order in a C. In the following, larger digits indicate more significance. The variable byteorder is either 4321 on a big-endian machine, or 1234 on a little-endian, or 87654321 on a Cray ... or 3412 with weird order ! =back =cut =head2 c =over 4 =cut =item C From F: This variable contains the \c string if that is what causes the echo command to suppress newline. Otherwise it is null. Correct usage is $echo $n "prompt for a question: $c". =item C From F: This variable contains a flag that precise difficulties the compiler has casting odd floating values to unsigned long: 0 = ok 1 = couldn't cast < 0 2 = couldn't cast >= 0x80000000 4 = couldn't cast in argument expression list =item C From F: This variable is used internally by Configure to determine the full pathname (if any) of the cat program. After Configure runs, the value is reset to a plain C and is not useful. =item C From F: This variable holds the name of a command to execute a C compiler which can resolve multiple global references that happen to have the same name. Usual values are C and C. Fervent C compilers may be called C. C has xlc. =item C From F: This variable contains any special flags that might need to be passed with C to compile modules to be used to create a shared library that will be used for dynamic loading. For hpux, this should be +z. It is up to the makefile to use it. =item C From F: This variable contains any special flags that might need to be passed to cc to link with a shared library for dynamic loading. It is up to the makefile to use it. For sunos 4.1, it should be empty. =item C From F: This variable contains any additional C compiler flags desired by the user. It is up to the Makefile to use this. =item C From F: This variable contains the compiler flags needed by large file builds and added to ccflags by hints files. =item C From F: This can set either by hints files or by Configure. If using gcc, this is gcc, and if not, usually equal to cc, unimpressive, no? Some platforms, however, make good use of this by storing the flavor of the C compiler being used here. For example if using the Sun WorkShop suite, ccname will be C. =item C From F: The variable contains the symbols defined by the C compiler alone. The symbols defined by cpp or by cc when it calls cpp are not in this list, see cppsymbols and cppccsymbols. The list is a space-separated list of symbol=value tokens. =item C From F: This can set either by hints files or by Configure. If using a (non-gcc) vendor cc, this variable may contain a version for the compiler. =item C From F: Login name of the person who ran the Configure script and answered the questions. This is used to tag both F and F. =item C From F: Electronic mail address of the person who ran Configure. This can be used by units that require the user's e-mail, like F. =item C From F: Holds the output of the C command when the configuration file was produced. This is used to tag both F and F. =item C From F: This variable is defined but not used by Configure. The value is the empty string and is not useful. =item C From F: This variable is used internally by Configure to determine the full pathname (if any) of the chmod program. After Configure runs, the value is reset to a plain C and is not useful. =item C From F: This variable is defined but not used by Configure. The value is the empty string and is not useful. =item C From F: This variable holds the type returned by times(). It can be long, or clock_t on C sites (in which case should be included). =item C From F: This variable is used internally by Configure to determine the full pathname (if any) of the comm program. After Configure runs, the value is reset to a plain C and is not useful. =item C From F: This variable is defined but not used by Configure. The value is the empty string and is not useful. =item C From F: This variable holds the command to do a grep with a proper return status. On most sane systems it is simply C. On insane systems it is a grep followed by a cat followed by a test. This variable is primarily for the use of other Configure units. =item C From F: This variable is used internally by Configure to determine the full pathname (if any) of the cp program. After Configure runs, the value is reset to a plain C and is not useful. =item C From F: This variable is defined but not used by Configure. The value is the empty string and is not useful. =item C From F: This variable is used internally by Configure to determine the full pathname (if any) of the cpp program. After Configure runs, the value is reset to a plain C and is not useful. =item C From F: This variable contains an identification of the concatenation mechanism used by the C preprocessor. =item C From F: The variable contains the symbols defined by the C compiler when it calls cpp. The symbols defined by the cc alone or cpp alone are not in this list, see ccsymbols and cppsymbols. The list is a space-separated list of symbol=value tokens. =item C From F: This variable holds the flags that will be passed to the C pre- processor. It is up to the Makefile to use it. =item C From F: This variable has the same functionality as cppminus, only it applies to cpprun and not cppstdin. =item C From F: This variable contains the second part of the string which will invoke the C preprocessor on the standard input and produce to standard output. This variable will have the value C<-> if cppstdin needs a minus to specify standard input, otherwise the value is "". =item C From F: This variable contains the command which will invoke a C preprocessor on standard input and put the output to stdout. It is guaranteed not to be a wrapper and may be a null string if no preprocessor can be made directly available. This preprocessor might be different from the one used by the C compiler. Don't forget to append cpplast after the preprocessor options. =item C From F: This variable contains the command which will invoke the C preprocessor on standard input and put the output to stdout. It is primarily used by other Configure units that ask about preprocessor symbols. =item C From F: The variable contains the symbols defined by the C preprocessor alone. The symbols defined by cc or by cc when it calls cpp are not in this list, see ccsymbols and cppccsymbols. The list is a space-separated list of symbol=value tokens. =item C From F: This variable encodes the prototype of crypt_r. It is zero if d_crypt_r is undef, and one of the C macros of F if d_crypt_r is defined. =item C From F: This variable holds -lcrypt or the path to a F archive if the crypt() function is not defined in the standard C library. It is up to the Makefile to use this. =item C From F: This variable is used internally by Configure to determine the full pathname (if any) of the csh program. After Configure runs, the value is reset to a plain C and is not useful. =item C From F: This variable encodes the prototype of ctermid_r. It is zero if d_ctermid_r is undef, and one of the C macros of F if d_ctermid_r is defined. =item C From F: This variable encodes the prototype of ctime_r. It is zero if d_ctime_r is undef, and one of the C macros of F if d_ctime_r is defined. =back =cut =head2 d =over 4 =cut =item C From F: This variable conditionally defines C if _fwalk() is available to apply a function to all the file handles. =item C From F: This variable conditionally defines C if the access() system call is available to check for access permissions using real IDs. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the accessx() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the aintl() routine is available. If copysignl is also present we can emulate modfl. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the alarm() routine is available. =item C From F: This variable conditionally defines C to hold the pathname of architecture-dependent library files for $package. If $archlib is the same as $privlib, then this is set to undef. =item C From F: This variable conditionally defines the HAS_ASCTIME64 symbol, which indicates to the C program that the asctime64 () routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the asctime_r() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the atolf() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the atoll() routine is available. =item C From F: This variable conditionally defines C, which indicates that C can handle the attribute for marking deprecated APIs =item C From F: This variable conditionally defines C, which indicates the C compiler can check for printf-like formats. =item C From F: This variable conditionally defines C, which indicates the C compiler can understand functions as having malloc-like semantics. =item C From F: This variable conditionally defines C, which indicates that the C compiler can know that certain arguments must not be C, and will check accordingly at compile time. =item C From F: This variable conditionally defines C, which indicates that the C compiler can know that certain functions are guaranteed never to return. =item C From F: This variable conditionally defines C, which indicates that the C compiler can know that certain functions are C functions, meaning that they have no side effects, and only rely on function input F global data for their results. =item C From F: This variable conditionally defines C, which indicates that the C compiler can know that certain variables and arguments may not always be used, and to not throw warnings if they don't get used. =item C From F: This variable conditionally defines C, which indicates that the C compiler can know that certain functions have a return values that must not be ignored, such as malloc() or open(). =item C From F: This variable conditionally defines the C symbol if the bcmp() routine is available to compare strings. =item C From F: This variable conditionally defines the C symbol if the bcopy() routine is available to copy strings. =item C From F: This symbol conditionally defines the symbol C when running on a C system. =item C From F: This variable conditionally defines C if getpgrp needs one arguments whereas C one needs none. =item C From F: This variable conditionally defines C if setpgrp needs two arguments whereas C one needs none. See also d_setpgid for a C interface. =item C From F: This conditionally defines C, which indicates that the compiler supports __builtin_choose_expr(x,y,z). This built-in function is analogous to the C operator in C, except that the expression returned has its type unaltered by promotion rules. Also, the built-in function does not evaluate the expression that was not chosen. =item C From F: This conditionally defines C, which indicates that the compiler supports __builtin_expect(exp,c). You may use __builtin_expect to provide the compiler with branch prediction information. =item C From F: This variable conditionally defines the C symbol if the bzero() routine is available to set memory to 0. =item C From F: This variable conditionally defines the HAS_C99_VARIADIC_MACROS symbol, which indicates to the C program that C99 variadic macros are available. =item C From F: This variable conditionally defines CASTI32, which indicates whether the C compiler can cast large floats to 32-bit ints. =item C From F: This variable conditionally defines C, which indicates wether the C compiler can cast negative float to unsigned. =item C From F: This variable conditionally defines C if this system has vsprintf returning type (char*). The trend seems to be to declare it as "int vsprintf()". =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the chown() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the chroot() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the chsize() routine is available to truncate files. You might need a -lx to get this routine. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the class() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the clearenv () routine is available. =item C From F: This variable conditionally defines C if closedir() is available. =item C From F: This variable conditionally defines the C symbol, which indicates that the struct cmsghdr is supported. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that this C compiler knows about the const type. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the copysignl() routine is available. If aintl is also present we can emulate modfl. =item C From F: This variable conditionally defines the C symbol, which indicates that a C++ compiler was used to compiled Perl and will be used to compile extensions. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the crypt() routine is available to encrypt passwords and the like. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the crypt_r() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the C-shell exists. =item C From F: This variable conditionally defines C if ctermid() is available to generate filename for terminal. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the ctermid_r() routine is available. =item C From F: This variable conditionally defines the HAS_CTIME64 symbol, which indicates to the C program that the ctime64 () routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the ctime_r() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the cuserid() routine is available to get character login names. =item C From F: This variable conditionally defines d_dbl_dig if this system's header files provide C, which is the number of significant digits in a double precision number. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the system provides a prototype for the dbminit() function. Otherwise, it is up to the program to supply one. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the difftime() routine is available. =item C From F: This variable conditionally defines the HAS_DIFFTIME64 symbol, which indicates to the C program that the difftime64 () routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates that the C directory stream type contains a member variable called dd_fd. =item C From F: This variable conditionally defines the C constant, which indicates to the C program that dirfd() is available to return the file descriptor of a directory stream. =item C From F: This variable conditionally defines C, which indicates to the C program that the length of directory entry names is provided by a d_namelen field. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the dlerror() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the dlopen() routine is available. =item C From F: This variable conditionally defines C, which indicates that we need to prepend an underscore to the symbol name before calling dlsym(). =item C From F: This variable conditionally defines the symbol C, which tells the C program that it should insert setuid emulation code on hosts which have setuid #! scripts disabled. =item C From F: This variable conditionally defines the HAS_DRAND48_R symbol, which indicates to the C program that the drand48_r() routine is available. =item C From F: This variable conditionally defines the HAS_DRAND48_PROTO symbol, which indicates to the C program that the system provides a prototype for the drand48() function. Otherwise, it is up to the program to supply one. =item C From F: This variable conditionally defines HAS_DUP2 if dup2() is available to duplicate file descriptors. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the eaccess() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the endgrent() routine is available for sequential access of the group database. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the endgrent_r() routine is available. =item C From F: This variable conditionally defines C if endhostent() is available to close whatever was being used for host queries. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the endhostent_r() routine is available. =item C From F: This variable conditionally defines C if endnetent() is available to close whatever was being used for network queries. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the endnetent_r() routine is available. =item C From F: This variable conditionally defines C if endprotoent() is available to close whatever was being used for protocol queries. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the endprotoent_r() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the endpwent() routine is available for sequential access of the passwd database. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the endpwent_r() routine is available. =item C From F: This variable conditionally defines C if endservent() is available to close whatever was being used for service queries. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the endservent_r() routine is available. =item C From F: This variable conditionally defines C if C can be seen when reading from a non-blocking I/O source. =item C From F: This variable conditionally defines the symbols C and C, which alerts the C program that it must deal with ideosyncracies of C. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the "fast stdio" is available to manipulate the stdio buffers directly. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the fchdir() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the fchmod() routine is available to change mode of opened files. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the fchown() routine is available to change ownership of opened files. =item C From F: This variable conditionally defines the C symbol, and indicates whether the fcntl() function exists =item C From F: This variable conditionally defines the C symbol and indicates whether file locking with fcntl() works. =item C From F: This variable contains the eventual value of the C symbol, which indicates if your C compiler knows about the macros which manipulate an fd_set. =item C From F: This variable contains the eventual value of the C symbol, which indicates if your C compiler knows about the fd_set typedef. =item C From F: This variable contains the eventual value of the C symbol, which indicates if your fd_set typedef contains the fds_bits member. If you have an fd_set typedef, but the dweebs who installed it did a half-fast job and neglected to provide the macros to manipulate an fd_set, C will let us know how to fix the gaffe. =item C From F: This variable conditionally defines C if fgetpos() is available to get the file position indicator. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the finite() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the finitel() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates that the system supports filenames longer than 14 characters. =item C From F: This variable conditionally defines C if flock() is available to do file locking. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the system provides a prototype for the flock() function. Otherwise, it is up to the program to supply one. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the fork() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the fp_class() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the pathconf() routine is available to determine file-system related limits and options associated with a given open file descriptor. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the fpclass() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the fpclassify() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the fpclassl() routine is available. =item C From F: This symbol will be defined if the C compiler supports fpos64_t. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the frexpl() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates that the struct fs_data is supported. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the fseeko() routine is available. =item C From F: This variable conditionally defines C if fsetpos() is available to set the file position indicator. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the fstatfs() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the fstatvfs() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the fsync() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the ftello() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates that the ftime() routine exists. The ftime() routine is basically a sub-second accuracy clock. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the futimes() routine is available. =item C From F: This variable holds what Gconvert is defined as to convert floating point numbers into strings. By default, Configure sets C macro to use the first of gconvert, gcvt, or sprintf that pass sprintf-%g-like behaviour tests. If perl is using long doubles, the macro uses the first of the following functions that pass Configure's tests: qgcvt, sprintf (if Configure knows how to make sprintf format long doubles--see sPRIgldbl), gconvert, gcvt, and sprintf (casting to double). The gconvert_preference and gconvert_ld_preference variables can be used to alter Configure's preferences, for doubles and long doubles, respectively. If present, they contain a space-separated list of one or more of the above function names in the order they should be tried. d_Gconvert may be set to override Configure with a platform- specific function. If this function expects a double, a different value may need to be set by the F call-back unit so that long doubles can be formatted without loss of precision. =item C From F: This variable conditionally defines the C symbol, which indicates that the gdbm-F include file uses real C C prototypes instead of K&R style function declarations. K&R style declarations are unsupported in C++, so the include file requires special handling when using a C++ compiler and this variable is undefined. Consult the different d_*ndbm_h_uses_prototypes variables to get the same information for alternative F include files. =item C From F: This variable conditionally defines the C symbol, which indicates that the F include file uses real C C prototypes instead of K&R style function declarations. K&R style declarations are unsupported in C++, so the include file requires special handling when using a C++ compiler and this variable is undefined. Consult the different d_*ndbm_h_uses_prototypes variables to get the same information for alternative F include files. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the getaddrinfo() function is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the getcwd() routine is available to get the current working directory. =item C From F: This variable conditionally defines C if getespwnam() is available to retrieve enchanced (shadow) password entries by name. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the getfsstat() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the getgrent() routine is available for sequential access of the group database. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the getgrent_r() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the getgrgid_r() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the getgrnam_r() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the getgroups() routine is available to get the list of process groups. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the gethostbyaddr() routine is available to look up hosts by their C addresses. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the gethostbyname() routine is available to look up host names in some data base or other. =item C From F: This variable conditionally defines C if gethostent() is available to look up host names in some data base or another. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the gethostname() routine may be used to derive the host name. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the gethostbyaddr_r() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the gethostbyname_r() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the gethostent_r() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that supplies prototypes for the various gethost*() functions. See also F for probing for various netdb types. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the getitimer() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the getlogin() routine is available to get the login name. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the getlogin_r() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the getmnt() routine is available to retrieve one or more mount info blocks by filename. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the getmntent() routine is available to iterate through mounted files to get their mount info. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the getnameinfo() function is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the getnetbyaddr() routine is available to look up networks by their C addresses. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the getnetbyname() routine is available to look up networks by their names. =item C From F: This variable conditionally defines C if getnetent() is available to look up network names in some data base or another. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the getnetbyaddr_r() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the getnetbyname_r() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the getnetent_r() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that supplies prototypes for the various getnet*() functions. See also F for probing for various netdb types. =item C From F: This variable conditionally defines C if getpagesize() is available to get the system page size. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the getprotobyname() routine is available to look up protocols by their name. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the getprotobynumber() routine is available to look up protocols by their number. =item C From F: This variable conditionally defines C if getprotoent() is available to look up protocols in some data base or another. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the getpgid(pid) function is available to get the process group id. =item C From F: This variable conditionally defines C if getpgrp() is available to get the current process group. =item C From F: This variable conditionally defines the HAS_GETPGRP2 symbol, which indicates to the C program that the getpgrp2() (as in F>) routine is available to get the current process group. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the getppid() routine is available to get the parent process C. =item C From F: This variable conditionally defines C if getpriority() is available to get a process's priority. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the getprotobyname_r() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the getprotobynumber_r() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the getprotoent_r() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that supplies prototypes for the various getproto*() functions. See also F for probing for various netdb types. =item C From F: This variable conditionally defines C if getprpwnam() is available to retrieve protected (shadow) password entries by name. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the getpwent() routine is available for sequential access of the passwd database. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the getpwent_r() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the getpwnam_r() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the getpwuid_r() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the getservbyname() routine is available to look up services by their name. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the getservbyport() routine is available to look up services by their port. =item C From F: This variable conditionally defines C if getservent() is available to look up network services in some data base or another. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the getservbyname_r() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the getservbyport_r() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the getservent_r() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that supplies prototypes for the various getserv*() functions. See also F for probing for various netdb types. =item C From F: This variable conditionally defines C if getspnam() is available to retrieve SysV shadow password entries by name. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the getspnam_r() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates that the gettimeofday() system call exists (to obtain a sub-second accuracy clock). You should probably include . =item C From F: This variable conditionally defines the HAS_GMTIME64 symbol, which indicates to the C program that the gmtime64 () routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the gmtime_r() routine is available. =item C From F: Defined if we're dealing with the C C Library. =item C From F: This variable conditionally defines C, which indicates that struct group in contains gr_passwd. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the hasmntopt() routine is available to query the mount options of file systems. =item C From F: This variable conditionally defines C if htonl() and its friends are available to do network order byte swapping. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the ilogbl() routine is available. If scalbnl is also present we can emulate frexpl. =item C From F: This variable conditionally defines C. It is set to undef when C is empty. =item C From F: This variable conditionally defines C if index() and rindex() are available for string searching. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the inet_aton() function is available to parse C address C strings. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the inet_ntop() function is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the inet_pton() function is available. =item C From F: This symbol will be defined if the C compiler supports int64_t. =item C From F: This variable conditionally defines the C constant, which indicates to the C program that isascii() is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the isfinite() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the isinf() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the isnan() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the isnanl() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the killpg() routine is available to kill process groups. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the lchown() routine is available to operate on a symbolic link (instead of following the link). =item C From F: This variable conditionally defines d_ldbl_dig if this system's header files provide C, which is the number of significant digits in a long double precision number. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that F defines C<_LIB_VERSION> being available in libm =item C From F: This variable conditionally defines C if link() is available to create hard links. =item C From F: This variable conditionally defines the HAS_LOCALTIME64 symbol, which indicates to the C program that the localtime64 () routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the localtime_r() routine is available. =item C From F: This variable conditionally defines the C symbol, which makes us call tzset before localtime_r() =item C From F: This variable conditionally defines C if localeconv() is available for numeric and monetary formatting conventions. =item C From F: This variable conditionally defines C if lockf() is available to do file locking. =item C From F: This variable conditionally defines C if the long double type is supported. =item C From F: This variable conditionally defines C if the long long type is supported. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the system provides a prototype for the lseek() function. Otherwise, it is up to the program to supply one. =item C From F: This variable conditionally defines C if lstat() is available to do file stats on symbolic links. =item C From F: This variable conditionally defines C if madvise() is available to map a file into memory. =item C From F: This symbol, if defined, indicates that the malloc_good_size routine is available for use. =item C From F: This symbol, if defined, indicates that the malloc_size routine is available for use. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the mblen() routine is available to find the number of bytes in a multibye character. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the mbstowcs() routine is available to convert a multibyte string into a wide character string. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the mbtowc() routine is available to convert multibyte to a wide character. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the memchr() routine is available to locate characters within a C string. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the memcmp() routine is available to compare blocks of memory. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the memcpy() routine is available to copy blocks of memory. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the memmove() routine is available to copy potentatially overlapping blocks of memory. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the memset() routine is available to set blocks of memory. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the mkdir() routine is available to create F. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the mkdtemp() routine is available to exclusively create a uniquely named temporary directory. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the mkfifo() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the mkstemp() routine is available to exclusively create and open a uniquely named temporary file. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the mkstemps() routine is available to exclusively create and open a uniquely named (with a suffix) temporary file. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the mktime() routine is available. =item C From F: This variable conditionally defines the HAS_MKTIME64 symbol, which indicates to the C program that the mktime64 () routine is available. =item C From F: This variable conditionally defines C if mmap() is available to map a file into memory. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the modfl() routine is available. =item C From F: This variable conditionally defines the HAS_MODFL_POW32_BUG symbol, which indicates that modfl() is broken for long doubles >= pow(2, 32). For example from 4294967303.150000 one would get 4294967302.000000 and 1.150000. The bug has been seen in certain versions of glibc, release 2.2.2 is known to be okay. =item C From F: This symbol, if defined, indicates that the system provides a prototype for the modfl() function. Otherwise, it is up to the program to supply one. C99 says it should be long double modfl(long double, long double *); =item C From F: This variable conditionally defines C if mprotect() is available to modify the access protection of a memory mapped file. =item C From F: This variable conditionally defines the C symbol, which indicates that the entire msg*(2) library is present. =item C From F: This variable conditionally defines the C symbol, which indicates that the C is available. #ifdef is not enough because it may be an enum, glibc has been known to do this. =item C From F: This variable conditionally defines the C symbol, which indicates that the C is available. #ifdef is not enough because it may be an enum, glibc has been known to do this. =item C From F: This variable conditionally defines the C symbol, which indicates that the C is available. #ifdef is not enough because it may be an enum, glibc has been known to do this. =item C From F: This variable conditionally defines the C symbol, which indicates that the C is available. #ifdef is not enough because it may be an enum, glibc has been known to do this. =item C From F: This variable conditionally defines the C symbol, which indicates that the C is available. #ifdef is not enough because it may be an enum, glibc has been known to do this. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the msgctl() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the msgget() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates that the struct msghdr is supported. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the msgrcv() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the msgsnd() routine is available. =item C From F: This variable conditionally defines C if msync() is available to synchronize a mapped file. =item C From F: This variable conditionally defines C if munmap() is available to unmap a region mapped by mmap(). =item C From F: This variable conditionally defines C in case other parts of the source want to take special action if C is used. This may include different sorts of profiling or error detection. =item C From F: This variable conditionally defines the C symbol, which indicates that both the F include file and an appropriate ndbm library exist. Consult the different i_*ndbm variables to find out the actual include location. Sometimes, a system has the header file but not the library. This variable will only be set if the system has both. =item C From F: This variable conditionally defines the C symbol, which indicates that the F include file uses real C C prototypes instead of K&R style function declarations. K&R style declarations are unsupported in C++, so the include file requires special handling when using a C++ compiler and this variable is undefined. Consult the different d_*ndbm_h_uses_prototypes variables to get the same information for alternative F include files. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the nice() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the nl_langinfo() routine is available. =item C From F: This variable indicates whether a variable of type nvtype can preserve all the bits a variable of type uvtype. =item C From F: This variable indicates whether a variable of type nvtype stores 0.0 in memory as all bits zero. =item C From F: This symbol will be defined if the C compiler supports off64_t. =item C From F: This variable conditionally defines pthread_create_joinable. undef if F defines C. =item C From F: This variable conditionally defines the C symbol, and indicates that Perl should be built to use the old draft C threads C. This is only potentially meaningful if usethreads is set. =item C From F: This variable conditionally defines the C symbol, which indicates that the C socket interface is based on 4.1c and not 4.2. =item C From F: This variable conditionally defines the HAS_OPEN3 manifest constant, which indicates to the C program that the 3 argument version of the open(2) function is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the pathconf() routine is available to determine file-system related limits and options associated with a given filename. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the pause() routine is available to suspend a process until a signal is received. =item C From F: This variable conditionally defines C, which contains a colon-separated set of paths for the perl binary to include in @C. See also otherlibdirs. =item C From F: This variable conditionally defines the C symbol, which contains the shell command which, when fed to popen(), may be used to derive the host name. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the pipe() routine is available to create an inter-process channel. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the poll() routine is available to poll active file descriptors. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that it should not assume that it is running on the machine it was compiled on. =item C From F: This variable conditionally defines the PERL_PRId64 symbol, which indiciates that stdio has a symbol to print 64-bit decimal numbers. =item C From F: This variable conditionally defines the PERL_PRIfldbl symbol, which indiciates that stdio has a symbol to print long doubles. =item C From F: This variable conditionally defines the PERL_PRIfldbl symbol, which indiciates that stdio has a symbol to print long doubles. The C in the name is to separate this from d_PRIeldbl so that even case-blind systems can see the difference. =item C From F: This variable conditionally defines the PERL_PRIfldbl symbol, which indiciates that stdio has a symbol to print long doubles. =item C From F: This variable conditionally defines the PERL_PRIfldbl symbol, which indiciates that stdio has a symbol to print long doubles. The C in the name is to separate this from d_PRIfldbl so that even case-blind systems can see the difference. =item C From F: This variable conditionally defines the PERL_PRIfldbl symbol, which indiciates that stdio has a symbol to print long doubles. =item C From F: This variable conditionally defines the PERL_PRIfldbl symbol, which indiciates that stdio has a symbol to print long doubles. The C in the name is to separate this from d_PRIgldbl so that even case-blind systems can see the difference. =item C From F: This variable conditionally defines the PERL_PRIi64 symbol, which indiciates that stdio has a symbol to print 64-bit decimal numbers. =item C From F: This variable conditionally defines C, which indicates the C compiler allows printf-like formats to be null. =item C From F: This variable conditionally defines the PERL_PRIo64 symbol, which indiciates that stdio has a symbol to print 64-bit octal numbers. =item C From F: This variable conditionally defines the PERL_PRIu64 symbol, which indiciates that stdio has a symbol to print 64-bit unsigned decimal numbers. =item C From F: This variable conditionally defines the PERL_PRIx64 symbol, which indiciates that stdio has a symbol to print 64-bit hexadecimal numbers. =item C From F: This variable conditionally defines the PERL_PRIXU64 symbol, which indiciates that stdio has a symbol to print 64-bit hExADECimAl numbers. The C in the name is to separate this from d_PRIx64 so that even case-blind systems can see the difference. =item C From F: Defined if $procselfexe is symlink to the absolute pathname of the executing program. =item C From F: This variable conditionally defines the C symbol, which indicates that an emulation of the fork routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the pthread_atfork() routine is available. =item C From F: This variable conditionally defines C if pthread_attr_setscope() is available to set the contention scope attribute of a thread attribute object. =item C From F: This variable conditionally defines the C symbol if the pthread_yield routine is available to yield the execution of the current thread. =item C From F: This variable conditionally defines C, which indicates that struct passwd contains pw_age. =item C From F: This variable conditionally defines C, which indicates that struct passwd contains pw_change. =item C From F: This variable conditionally defines C, which indicates that struct passwd contains pw_class. =item C From F: This variable conditionally defines C, which indicates that struct passwd contains pw_comment. =item C From F: This variable conditionally defines C, which indicates that struct passwd contains pw_expire. =item C From F: This variable conditionally defines C, which indicates that struct passwd contains pw_gecos. =item C From F: This variable conditionally defines C, which indicates that struct passwd contains pw_passwd. =item C From F: This variable conditionally defines C, which indicates that struct passwd contains pw_quota. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the qgcvt() routine is available. =item C From F: This variable, if defined, tells that there's a 64-bit integer type, quadtype. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the random_r() routine is available. =item C From F: This variable conditionally defines C if readdir() is available to read directory entries. =item C From F: This variable conditionally defines the HAS_READDIR64_R symbol, which indicates to the C program that the readdir64_r() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the readdir_r() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the readlink() routine is available to read the value of a symbolic link. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the readv() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the recvmsg() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the rename() routine is available to rename files. =item C From F: This variable conditionally defines C if rewinddir() is available. =item C From F: This variable conditionally defines C if rmdir() is available to remove directories. =item C From F: This variable conditionally defines the C symbol if the bcopy() routine can do overlapping copies. Normally, you should probably use memmove(). =item C From F: This variable conditionally defines the C symbol if the memcpy() routine can do overlapping copies. For overlapping copies, memmove() should be used, if available. =item C From F: This variable conditionally defines the C symbol if the memcpy() routine is available and can be used to compare relative magnitudes of chars with their high bits set. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the system provides a prototype for the sbrk() function. Otherwise, it is up to the program to supply one. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the scalbnl() routine is available. If ilogbl is also present we can emulate frexpl. =item C From F: This variable conditionally defines the C symbol if the sched_yield routine is available to yield the execution of the current thread. =item C From F: This variable conditionally defines the C symbol, which indicates that the C is available. #ifdef is not enough because it may be an enum, glibc has been known to do this. =item C From F: This variable conditionally defines the PERL_PRIfldbl symbol, which indiciates that stdio has a symbol to scan long doubles. =item C From F: This variable conditionally defines C if seekdir() is available. =item C From F: This variable conditionally defines C if select() is available to select active file descriptors. A inclusion may be necessary for the timeout field. =item C From F: This variable conditionally defines the C symbol, which indicates that the entire sem*(2) library is present. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the semctl() routine is available. =item C From F: This variable conditionally defines C, which indicates that struct semid_ds * is to be used for semctl C. =item C From F: This variable conditionally defines C, which indicates that union semun is to be used for semctl C. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the semget() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the semop() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the sendmsg() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the setegid() routine is available to change the effective gid of the current program. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the seteuid() routine is available to change the effective uid of the current program. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the setgrent() routine is available for initializing sequential access to the group database. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the setgrent_r() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the setgroups() routine is available to set the list of process groups. =item C From F: This variable conditionally defines C if sethostent() is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the sethostent_r() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the setitimer() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the setlinebuf() routine is available to change stderr or stdout from block-buffered or unbuffered to a line-buffered mode. =item C From F: This variable conditionally defines C if setlocale() is available to handle locale-specific ctype implementations. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the setlocale_r() routine is available. =item C From F: This variable conditionally defines C if setnetent() is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the setnetent_r() routine is available. =item C From F: This variable conditionally defines C if setprotoent() is available. =item C From F: This variable conditionally defines the C symbol if the setpgid(pid, gpid) function is available to set process group C. =item C From F: This variable conditionally defines C if setpgrp() is available to set the current process group. =item C From F: This variable conditionally defines the HAS_SETPGRP2 symbol, which indicates to the C program that the setpgrp2() (as in F>) routine is available to set the current process group. =item C From F: This variable conditionally defines C if setpriority() is available to set a process's priority. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the setproctitle() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the setprotoent_r() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the setpwent() routine is available for initializing sequential access to the passwd database. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the setpwent_r() routine is available. =item C From F: This variable conditionally defines C if setregid() is available to change the real and effective gid of the current process. =item C From F: This variable conditionally defines C if setresgid() is available to change the real, effective and saved gid of the current process. =item C From F: This variable conditionally defines C if setresuid() is available to change the real, effective and saved uid of the current process. =item C From F: This variable conditionally defines C if setreuid() is available to change the real and effective uid of the current process. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the setrgid() routine is available to change the real gid of the current program. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the setruid() routine is available to change the real uid of the current program. =item C From F: This variable conditionally defines C if setservent() is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the setservent_r() routine is available. =item C From F: This variable conditionally defines C if setsid() is available to set the process group C. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the setvbuf() routine is available to change buffering on an open stdio stream. =item C From F: This variable conditionally defines the C symbol, and indicates whether sfio is available (and should be used). =item C From F: This variable conditionally defines the C symbol, which indicates that the entire shm*(2) library is present. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the shmat() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates that F has a prototype for shmat. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the shmctl() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the shmdt() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the shmget() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates that the Vr4 sigaction() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the signbit() routine is available and safe to use with perl's intern C type. =item C From F: This variable conditionally defines C if sigprocmask() is available to examine or change the signal mask of the calling process. =item C From F: This variable conditionally defines the C symbol, which indicates that the sigsetjmp() routine is available to call setjmp() and optionally save the process's signal mask. =item C From F: This variable conditionally defines C to hold the pathname of architecture-dependent library files for $package. If $sitearch is the same as $archlib, then this is set to undef. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the snprintf () library function is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the sockatmark() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the system provides a prototype for the sockatmark() function. Otherwise, it is up to the program to supply one. =item C From F: This variable conditionally defines C, which indicates that the C socket interface is supported. =item C From F: This symbol will be defined if the C compiler supports socklen_t. =item C From F: This variable conditionally defines the C symbol, which indicates that the C socketpair() is supported. =item C From F: This variable conditionally defines the HAS_SOCKS5_INIT symbol, which indicates to the C program that the socks5_init() routine is available. =item C From F: This variable defines whether sprintf returns the length of the string (as per the C spec). Some C libraries retain compatibility with pre-C C and return a pointer to the passed in buffer; for these this variable will be undef. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the sqrtl() routine is available. =item C From F: This variable conditionally defines the HAS_SRAND48_R symbol, which indicates to the C program that the srand48_r() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the srandom_r() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the system provides a prototype for the setresgid() function. Otherwise, it is up to the program to supply one. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the system provides a prototype for the setresuid() function. Otherwise, it is up to the program to supply one. =item C From F: This variable conditionally defines C if this system has a stat structure declaring st_blksize and st_blocks. =item C From F: This variable conditionally defines the C symbol, which indicates to struct statfs from has f_flags member. This kind of struct statfs is coming from F (C), not from F (C). =item C From F: This variable conditionally defines the C symbol, which indicates that the struct statfs is supported. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the statvfs() routine is available. =item C From F: This variable conditionally defines C if the C macro can be used as an lvalue. =item C From F: This variable conditionally defines C if the C macro can be used as an lvalue. =item C From F: This symbol is defined if using the C macro as an lvalue to increase the pointer by n leaves File_cnt(fp) unchanged. =item C From F: This symbol is defined if using the C macro as an lvalue to increase the pointer by n has the side effect of decreasing the value of File_cnt(fp) by n. =item C From F: This variable tells whether there is an array holding the stdio streams. =item C From F: This variable conditionally defines C if this system has a C structure declaring a usable _base field (or equivalent) in F. =item C From F: This variable conditionally defines C if this system has a C structure declaring usable _ptr and _cnt fields (or equivalent) in F. =item C From F: This variable conditionally defines C if strchr() and strrchr() are available for string searching. =item C From F: This variable conditionally defines C if strcoll() is available to compare strings using collating information. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that this C compiler knows how to copy structures. =item C From F: This variable holds what Strerrr is defined as to translate an error code condition into an error message string. It could be C or a more C macro emulating strrror with sys_errlist[], or the C string when both strerror and sys_errlist are missing. =item C From F: This variable conditionally defines C if strerror() is available to translate error numbers to strings. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the strerror_r() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the strftime() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the strlcat () routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the strlcpy () routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the strtod() routine is available to provide better numeric string conversion than atof(). =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the strtol() routine is available to provide better numeric string conversion than atoi() and friends. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the strtold() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the strtoll() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the strtoq() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the strtoul() routine is available to provide conversion of strings to unsigned long. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the strtoull() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the strtouq() routine is available. =item C From F: This variable conditionally defines C if strxfrm() is available to transform strings. =item C From F: This variable conditionally defines C if setuid scripts can be secure. This test looks in F. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the symlink() routine is available to create symbolic links. =item C From F: This variable conditionally defines C if syscall() is available call arbitrary system calls. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the system provides a prototype for the syscall() function. Otherwise, it is up to the program to supply one. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the sysconf() routine is available to determine system related limits and options. =item C From F: This variable conditionally defines C if sys_errnolist[] is available to translate error numbers to the symbolic name. =item C From F: This variable conditionally defines C if sys_errlist[] is available to translate error numbers to strings. =item C From F: This variable conditionally defines C if system() is available to issue a shell command. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the tcgetpgrp() routine is available. to get foreground process group C. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the tcsetpgrp() routine is available to set foreground process group C. =item C From F: This variable conditionally defines C if telldir() is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the system provides a prototype for the telldir() function. Otherwise, it is up to the program to supply one. =item C From F: This variable conditionally defines the C symbol, which indicates that the time() routine exists. The time() routine is normaly provided on C systems. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the timegm () routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates that the times() routine exists. The times() routine is normaly provided on C systems. You may have to include . =item C From F: This variable conditionally defines C, which indicates indicates to the C program that the struct tm has the tm_gmtoff field. =item C From F: This variable conditionally defines C, which indicates indicates to the C program that the struct tm has the tm_zone field. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the tmpnam_r() routine is available. =item C From F: This variable conditionally defines C if truncate() is available to truncate files. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the ttyname_r() routine is available. =item C From F: This variable conditionally defines C if tzname[] is available to access timezone names. =item C From F: This variable tells whether you must access character data through U32-aligned pointers. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the ualarm() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the umask() routine is available. to set and get the value of the file creation mask. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the uname() routine may be used to derive the host name. =item C From F: This variable conditionally defines C if the union semun is defined by including . =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the unordered() routine is available. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the unsetenv () routine is available. =item C From F: This variable conditionally defines C if usleep() is available to do high granularity sleeps. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the system provides a prototype for the usleep() function. Otherwise, it is up to the program to supply one. =item C From F: This variable conditionally defines C if ustat() is available to query file system statistics by dev_t. =item C From F: This variable conditionally defined C. =item C From F: This variable conditionally defines C. =item C From F: This variable conditionally defines C. =item C From F: This variable conditionally defines C. =item C From F: This variable conditionally defines the C symbol, which indicates the vfork() routine is available. =item C From F: This variable conditionally defines C if closedir() does not return a value. =item C From F: This variable conditionally defines C if this system declares "void (*signal(...))()" in F. The old way was to declare it as "int (*signal(...))()". =item C From F: This variable conditionally defines C to indicate that the ioctl() call with C should be used to void tty association. Otherwise (on C probably), it is enough to close the standard file decriptors and do a setpgrp(). =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that this C compiler knows about the volatile declaration. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the vprintf() routine is available to printf with a pointer to an argument list. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the vsnprintf () library function is available. =item C From F: This variable conditionally defines the HAS_WAIT4 symbol, which indicates the wait4() routine is available. =item C From F: This variable conditionally defines C if waitpid() is available to wait for child process. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the wcstombs() routine is available to convert wide character strings to multibyte strings. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the wctomb() routine is available to convert a wide character to a multibyte. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the writev() routine is available. =item C From F: This variable conditionally defines the symbol C, which alerts the C program that it runs under Xenix. =item C From F: This variable is used internally by Configure to determine the full pathname (if any) of the date program. After Configure runs, the value is reset to a plain C and is not useful. =item C From F: This variable contains the type of the hash structure element in the header file. In older versions of C, it was int, while in newer ones it is u_int32_t. =item C From F: This variable contains the type of the prefix structure element in the header file. In older versions of C, it was int, while in newer ones it is size_t. =item C From F: This variable contains the major version number of Berkeley C found in the header file. =item C From F: This variable contains the minor version number of Berkeley C found in the header file. For C version 1 this is always 0. =item C From F: This variable contains the patch version number of Berkeley C found in the header file. For C version 1 this is always 0. =item C From F: This variable contains the default value of the C symbol (15). =item C From F: This symbol is set to C or C depending on whether dirent is available or not. You should use this pseudo type to portably declare your directory entries. =item C From F: This variable contains the extension that is to be used for the dynamically loaded modules that perl generaties. =item C From F: This variable contains the name of the dynamic loading file that will be used with the package. =item C From F: This variable contains the value of the C symbol, which indicates to the C program how many bytes there are in a double. =item C From F: Indicates the macro to be used to generate normalized random numbers. Uses randfunc, often divided by (double) (((unsigned long) 1 << randbits)) in order to normalize the result. In C programs, the macro C is mapped to drand01. =item C From F: This variable encodes the prototype of drand48_r. It is zero if d_drand48_r is undef, and one of the C macros of F if d_drand48_r is defined. =item C From F: This variable holds the location of the dtrace executable. =item C From F: This variable holds a list of C extension files we want to link dynamically into the package. It is used by Makefile. =back =cut =head2 e =over 4 =cut =item C From F: This variable bears the symbolic errno code set by read() when no data is present on the file and non-blocking I/O was enabled (otherwise, read() blocks naturally). =item C From F: This variable conditionally defines C if this system uses C encoding. Among other things, this means that the character ranges are not contiguous. See F =item C From F: This variable is used internally by Configure to determine the full pathname (if any) of the echo program. After Configure runs, the value is reset to a plain C and is not useful. =item C From F: This variable is used internally by Configure to determine the full pathname (if any) of the egrep program. After Configure runs, the value is reset to a plain C and is not useful. =item C From F: This variable is defined but not used by Configure. The value is the empty string and is not useful. =item C From F: This variable encodes the prototype of endgrent_r. It is zero if d_endgrent_r is undef, and one of the C macros of F if d_endgrent_r is defined. =item C From F: This variable encodes the prototype of endhostent_r. It is zero if d_endhostent_r is undef, and one of the C macros of F if d_endhostent_r is defined. =item C From F: This variable encodes the prototype of endnetent_r. It is zero if d_endnetent_r is undef, and one of the C macros of F if d_endnetent_r is defined. =item C From F: This variable encodes the prototype of endprotoent_r. It is zero if d_endprotoent_r is undef, and one of the C macros of F if d_endprotoent_r is defined. =item C From F: This variable encodes the prototype of endpwent_r. It is zero if d_endpwent_r is undef, and one of the C macros of F if d_endpwent_r is defined. =item C From F: This variable encodes the prototype of endservent_r. It is zero if d_endservent_r is undef, and one of the C macros of F if d_endservent_r is defined. =item C From F: When running under Eunice this variable contains a command which will convert a shell script to the proper form of text file for it to be executable by the shell. On other systems it is a no-op. =item C From F: This is an old synonym for _exe. =item C From F: This variable is used internally by Configure to determine the full pathname (if any) of the expr program. After Configure runs, the value is reset to a plain C and is not useful. =item C From F: This variable holds a list of all extension files (both C and non-xs linked into the package. It is propagated to F and is typically used to test whether a particular extesion is available. =item C From F: C C requires C where C++ requires 'extern C'. This variable can be used in Configure to do the right thing. =item C From F: This variable holds a list of extra modules to install. =back =cut =head2 f =over 4 =cut =item C From F: This symbol, if defined, tells that to flush all pending stdio output one must loop through all the stdio file handles stored in an array and fflush them. Note that if fflushNULL is defined, fflushall will not even be probed for and will be left undefined. =item C From F: This symbol, if defined, tells that fflush(C) does flush all pending stdio output. =item C From F: This variable is defined but not used by Configure. The value is the empty string and is not useful. =item C From F: This variable defines the first file searched by make. On unix, it is makefile (then Makefile). On case-insensitive systems, it might be something else. This is only used to deal with convoluted make depend tricks. =item C From F: This variable is defined but not used by Configure. The value is the empty string and is not useful. =item C From F: This variable contains the size of a fpostype in bytes. =item C From F: This variable defines Fpos_t to be something like fpos_t, long, uint, or whatever type is used to declare file positions in libc. =item C From F: This variable contains the return type of free(). It is usually void, but occasionally int. =item C From F: This variable contains the command used by Configure to copy files from the target host. Useful and available only during Perl build. The string C<:> if not cross-compiling. =item C From F: This variable contains the full pathname to C, whether or not the user has specified C. This is only used in the F. =item C From F: This variable contains the full pathname to C, whether or not the user has specified C. This is only used in the compiled C program, and we assume that all systems which can share this executable will have the same full pathname to F =item C From F: This variable contains the full pathname to C, whether or not the user has specified C. This is only used in the compiled C program, and we assume that all systems which can share this executable will have the same full pathname to F =back =cut =head2 g =over 4 =cut =item C From F: If C cc (gcc) is used, this variable will enable (if set) the -ansi and -pedantic ccflags for building core files (through cflags script). (See F for full description). =item C From F: If C cc (gcc) is used, this variable holds the operating system and version used to compile gcc. It is set to '' if not gcc, or if nothing useful can be parsed as the os version. =item C From F: If C cc (gcc) is used, this variable holds C<1> or C<2> to indicate whether the compiler is version 1 or 2. This is used in setting some of the default cflags. It is set to '' if not gcc. =item C From F: This variable encodes the prototype of getgrent_r. It is zero if d_getgrent_r is undef, and one of the C macros of F if d_getgrent_r is defined. =item C From F: This variable encodes the prototype of getgrgid_r. It is zero if d_getgrgid_r is undef, and one of the C macros of F if d_getgrgid_r is defined. =item C From F: This variable encodes the prototype of getgrnam_r. It is zero if d_getgrnam_r is undef, and one of the C macros of F if d_getgrnam_r is defined. =item C From F: This variable encodes the prototype of gethostbyaddr_r. It is zero if d_gethostbyaddr_r is undef, and one of the C macros of F if d_gethostbyaddr_r is defined. =item C From F: This variable encodes the prototype of gethostbyname_r. It is zero if d_gethostbyname_r is undef, and one of the C macros of F if d_gethostbyname_r is defined. =item C From F: This variable encodes the prototype of gethostent_r. It is zero if d_gethostent_r is undef, and one of the C macros of F if d_gethostent_r is defined. =item C From F: This variable encodes the prototype of getlogin_r. It is zero if d_getlogin_r is undef, and one of the C macros of F if d_getlogin_r is defined. =item C From F: This variable encodes the prototype of getnetbyaddr_r. It is zero if d_getnetbyaddr_r is undef, and one of the C macros of F if d_getnetbyaddr_r is defined. =item C From F: This variable encodes the prototype of getnetbyname_r. It is zero if d_getnetbyname_r is undef, and one of the C macros of F if d_getnetbyname_r is defined. =item C From F: This variable encodes the prototype of getnetent_r. It is zero if d_getnetent_r is undef, and one of the C macros of F if d_getnetent_r is defined. =item C From F: This variable encodes the prototype of getprotobyname_r. It is zero if d_getprotobyname_r is undef, and one of the C macros of F if d_getprotobyname_r is defined. =item C From F: This variable encodes the prototype of getprotobynumber_r. It is zero if d_getprotobynumber_r is undef, and one of the C macros of F if d_getprotobynumber_r is defined. =item C From F: This variable encodes the prototype of getprotoent_r. It is zero if d_getprotoent_r is undef, and one of the C macros of F if d_getprotoent_r is defined. =item C From F: This variable encodes the prototype of getpwent_r. It is zero if d_getpwent_r is undef, and one of the C macros of F if d_getpwent_r is defined. =item C From F: This variable encodes the prototype of getpwnam_r. It is zero if d_getpwnam_r is undef, and one of the C macros of F if d_getpwnam_r is defined. =item C From F: This variable encodes the prototype of getpwuid_r. It is zero if d_getpwuid_r is undef, and one of the C macros of F if d_getpwuid_r is defined. =item C From F: This variable encodes the prototype of getservbyname_r. It is zero if d_getservbyname_r is undef, and one of the C macros of F if d_getservbyname_r is defined. =item C From F: This variable encodes the prototype of getservbyport_r. It is zero if d_getservbyport_r is undef, and one of the C macros of F if d_getservbyport_r is defined. =item C From F: This variable encodes the prototype of getservent_r. It is zero if d_getservent_r is undef, and one of the C macros of F if d_getservent_r is defined. =item C From F: This variable encodes the prototype of getspnam_r. It is zero if d_getspnam_r is undef, and one of the C macros of F if d_getspnam_r is defined. =item C From F: This variable contains the format string used for printing a Gid_t. =item C From F: This variable contains the signedness of a gidtype. 1 for unsigned, -1 for signed. =item C From F: This variable contains the size of a gidtype in bytes. =item C From F: This variable defines Gid_t to be something like gid_t, int, ushort, or whatever type is used to declare the return type of getgid(). Typically, it is the type of group ids in the kernel. =item C From F: This variable holds the general path (space-separated) used to find libraries. It may contain directories that do not exist on this platform, libpth is the cleaned-up version. =item C From F: This variable is used internally by Configure to determine the full pathname (if any) of the gmake program. After Configure runs, the value is reset to a plain C and is not useful. =item C From F: This variable encodes the prototype of gmtime_r. It is zero if d_gmtime_r is undef, and one of the C macros of F if d_gmtime_r is defined. =item C From F: This variable contains the version number of the C C library. It is usually something like F<2.2.5>. It is a plain '' if this is not the C C library, or if the version is unknown. =item C From F: This variable is used internally by Configure to determine the full pathname (if any) of the grep program. After Configure runs, the value is reset to a plain C and is not useful. =item C From F: This variable contains a command that produces the text of the F file. This is normally "cat F", but can be "ypcat group" when C is used. On some systems, such as os390, there may be no equivalent command, in which case this variable is unset. =item C From F: This variable defines Groups_t to be something like gid_t, int, ushort, or whatever type is used for the second argument to getgroups() and setgroups(). Usually, this is the same as gidtype (gid_t), but sometimes it isn't. =item C From F: This variable is used internally by Configure to determine the full pathname (if any) of the gzip program. After Configure runs, the value is reset to a plain C and is not useful. =back =cut =head2 h =over 4 =cut =item C From F: This is variable gets set in various places to tell i_fcntl that should be included. =item C From F: This is variable gets set in various places to tell i_sys_file that should be included. =item C From F: Gives the type of hints used for previous answers. May be one of C, C or C. =item C From F: This variable contains a command that produces the text of the F file. This is normally "cat F", but can be "ypcat hosts" when C is used. On some systems, such as os390, there may be no equivalent command, in which case this variable is unset. =item C From F: This variable contains the name of the directory in which html source pages are to be put. This directory is for pages that describe whole programs, not libraries or modules. It is intended to correspond roughly to section 1 of the Unix manuals. =item C From F: This variable is the same as the html1dir variable, but is filename expanded at configuration time, for convenient use in makefiles. =item C From F: This variable contains the name of the directory in which html source pages are to be put. This directory is for pages that describe libraries or modules. It is intended to correspond roughly to section 3 of the Unix manuals. =item C From F: This variable is the same as the html3dir variable, but is filename expanded at configuration time, for convenient use in makefiles. =back =cut =head2 i =over 4 =cut =item C From F: This variable is the size of an I16 in bytes. =item C From F: This variable contains the C type used for Perl's I16. =item C From F: This variable is the size of an I32 in bytes. =item C From F: This variable contains the C type used for Perl's I32. =item C From F: This variable is the size of an I64 in bytes. =item C From F: This variable contains the C type used for Perl's I64. =item C From F: This variable is the size of an I8 in bytes. =item C From F: This variable contains the C type used for Perl's I8. =item C From F: This variable conditionally defines the C symbol, and indicates whether a C program should include . =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that exists and could be included. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that exists and should be included. =item C From F: This variable conditionally defines the C symbol, and indicates whether a C program should include . =item C From F: This variable conditionally defines the C symbol, and indicates whether a C program may include Berkeley's C include file . =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that exists and should be included. =item C From F: This variable conditionally defines C, which indicates to the C program that it should include . =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that (C dynamic loading) exists and should be included. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that exists and should be included. =item C From F: This variable controls the value of C (which tells the C program to include ). =item C From F: This variable conditionally defines the C symbol, and indicates whether a C program may include to get symbols like C or C, F. machine dependent floating point values. =item C From F: This variable conditionally defines the C symbol, and indicates whether a C program should include . =item C From F: This variable conditionally defines the C symbol, and indicates whether a C program should include . =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that exists and should be included. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that > exists and should be included. This is the location of the F compatibility file in Debian 4.0. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that exists and should be included. This was the location of the F compatibility file in RedHat 7.1. =item C From F: This variable conditionally defines the C symbol, and indicates whether a C program should include . =item C From F: This variable conditionally defines the C symbol, and indicates whether a C program should include . =item C From F: This variable conditionally defines the C symbol, and indicates whether a C program should include . =item C From F: This variable conditionally defines the C symbol, and indicates whether a C program should include . =item C From F: This variable conditionally defines the C symbol, and indicates whether a C program should include . =item C From F: This variable conditionally defines the C symbol, and indicates whether a C program may include to get symbols like C and friends. =item C From F: This variable conditionally defines the C symbol, and indicates whether a C program should include . =item C From F: This variable conditionally defines the C symbol, and indicates whether a C program should include . =item C From F: This variable conditionally defines the C symbol, and indicates whether a C program should include . =item C From F: This variable conditionally defines the C symbol, and indicates whether a C program should include . =item C From F: This variable conditionally defines the C symbol, and indicates whether a C program may include . =item C From F: This variable conditionally defines the C symbol, and indicates whether a C program should include . =item C From F: This variable conditionally defines the C symbol, and indicates whether a C program should include . =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that exists and should be included. =item C From F: This variable conditionally defines the C symbol, and indicates whether a C program should include . =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that exists and should be included. =item C From F: This variable conditionally defines the C symbol, and indicates whether a C program should include . =item C From F: This variable conditionally defines C, which indicates to the C program that it should include . Otherwise, you may try . =item C From F: This variable conditionally defines the C symbol, and indicates whether a C program should include . =item C From F: This variable conditionally defines the C symbol, and indicates whether a C program should include . =item C From F: This variable conditionally defines the C symbol, and indicates whether a C program should include . =item C From F: This variable conditionally defines C, which indicates to the C program that it should include . =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that exists and should be included. Some System V systems might need this instead of . =item C From F: This variable conditionally defines the C symbol, and indicates whether a C program should include . =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that it should include rather than . =item C From F: This variable conditionally defines the C symbol, and indicates whether a C program should include . =item C From F: This variable conditionally defines the C symbol, and indicates whether a C program should include . =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that exists and should be included. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that exists and should be included. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that exists and should be included. =item C From F: This variable conditionally defines the C symbol, which indicates that should be included rather than . =item C From F: This variable conditionally defines the C symbol, and indicates whether a C program should include . =item C From F: This variable conditionally defines the C symbol, and indicates whether a C program should include . =item C From F: This variable conditionally defines the C symbol, and indicates whether a C program should include . =item C From F: This variable conditionally defines the C symbol, and indicates whether a C program should include to get C and friends. =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that exists and should be included in preference to . =item C From F: This variable conditionally defines C, which indicates to the C program that it should include instead of . =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that exists and should be included. =item C From F: This variable conditionally defines the C symbol, and indicates whether a C program should include . =item C From F: This variable conditionally defines the C symbol, and indicates whether a C program should include . =item C From F: This variable conditionally defines the C symbol, and indicates whether a C program should include . =item C From F: This variable conditionally defines the C symbol, and indicates whether a C program should include . =item C From F: This variable conditionally defines the C symbol, and indicates whether a C program should include . =item C From F: This variable conditionally defines the C symbol, and indicates whether a C program should include . =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that it should include . =item C From F: This variable conditionally defines the C symbol, and indicates whether a C program should include . =item C From F: This variable conditionally defines the C symbol, and indicates whether a C program should include . =item C From F: This variable conditionally defines C, which indicates to the C program that it should include in order to get the definition of struct timeval. =item C From F: This variable conditionally defines C to indicate to the C program that socket ioctl codes may be found in instead of . =item C From F: This variable conditionally defines the C symbol, and indicates whether a C program should include . =item C From F: This variable conditionally defines the C symbol, and indicates whether a C program should include . =item C From F: This variable conditionally defines the C symbol, and indicates whether a C program should include . =item C From F: This variable conditionally defines C, which indicates to the C program that it should include . =item C From F: This variable conditionally defines C, which indicates to the C program that it should include with C defined. =item C From F: This variable conditionally defines the C symbol, and indicates whether a C program should include . =item C From F: This variable conditionally defines the C symbol, and indicates whether a C program should include . =item C From F: This variable conditionally defines the C symbol, and indicates whether a C program should include . =item C From F: This variable conditionally defines C, which indicates to the C program that it should include to get C domain socket definitions. =item C From F: This variable conditionally defines the C symbol, and indicates whether a C program should include . =item C From F: This variable conditionally defines the C symbol, and indicates whether a C program should include . =item C From F: This variable conditionally defines C, which indicates to the C program that it should include . =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that it should include rather than . =item C From F: This variable conditionally defines the C symbol, which indicates to the C program that the C file is to be included. =item C From F: This variable conditionally defines C, which indicates to the C program that it should include . =item C From F: This variable conditionally defines the C symbol, and indicates whether a C program should include . =item C From F: This variable conditionally defines the C symbol, and indicates whether a C program should include . =item C From F: This variable conditionally defines the C symbol, and indicates whether a C program should include . =item C From F: This variable conditionally defines the C symbol, and indicates whether a C program may include to get symbols like C and friends. =item C From F: This variable conditionally defines C, which indicates to the C program that it should include . =item C From F: Contains the name of the header to be included to get va_dcl definition. Typically one of F or F. =item C From F: This variable conditionally defines the C symbol, and indicates whether a C program should include F. =item C From F: This variable should be non-empty if non-versioned shared libraries (F) are to be ignored (because they cannot be linked against). =item C From F: This variable specifies the list of subdirectories in over which F:incpush() and F will automatically search when adding directories to @C. The elements in the list are separated by spaces. This is only useful if you have a perl library directory tree structured like the default one. See C for how this works. The versioned site_perl directory was introduced in 5.005, so that is the lowest possible value. This list includes architecture-dependent directories back to version $api_versionstring (e.g. 5.5.640) and architecture-independent directories all the way back to 5.005. =item C From F: This variable holds the same list as inc_version_list, but each item is enclosed in double quotes and separated by commas, suitable for use in the C initialization. =item C From F: This variable must preceed the normal include path to get hte right one, as in F<$F> or F<$F>. Value can be "" or F on mips. =item C From F: This variable is defined but not used by Configure. The value is the empty string and is not useful. =item C From F: When userelocatableinc is true, this variable holds the location that make install should copy the perl binary to, with all the run-time relocatable paths calculated from this at install time. When used, it is initialised to the original value of binexp, and then binexp is set to F<.../>, as the other binaries are found relative to the perl binary. =item C From F: This variable is really the same as archlibexp but may differ on those systems using C. For extra portability, only this variable should be used in makefiles. =item C From F: This variable is the same as binexp unless C is running in which case the user is explicitely prompted for it. This variable should always be used in your makefiles for maximum portability. =item C From F: This variable is really the same as html1direxp, unless you are using a different installprefix. For extra portability, you should only use this variable within your makefiles. =item C From F: This variable is really the same as html3direxp, unless you are using a different installprefix. For extra portability, you should only use this variable within your makefiles. =item C From F: This variable is really the same as man1direxp, unless you are using C in which case it points to the read/write location whereas man1direxp only points to the read-only access location. For extra portability, you should only use this variable within your makefiles. =item C From F: This variable is really the same as man3direxp, unless you are using C in which case it points to the read/write location whereas man3direxp only points to the read-only access location. For extra portability, you should only use this variable within your makefiles. =item C From F: This variable holds the name of the directory below which "make install" will install the package. For most users, this is the same as prefix. However, it is useful for installing the software into a different (usually temporary) location after which it can be bundled up and moved somehow to the final location specified by prefix. =item C From F: This variable holds the full absolute path of installprefix with all F<~>-expansion done. =item C From F: This variable is really the same as privlibexp but may differ on those systems using C. For extra portability, only this variable should be used in makefiles. =item C From F: This variable is usually the same as scriptdirexp, unless you are on a system running C, in which case they may differ slightly. You should always use this variable within your makefiles for portability. =item C From F: This variable is really the same as sitearchexp but may differ on those systems using C. For extra portability, only this variable should be used in makefiles. =item C From F: This variable is usually the same as sitebinexp, unless you are on a system running C, in which case they may differ slightly. You should always use this variable within your makefiles for portability. =item C From F: This variable is really the same as sitehtml1direxp, unless you are using C in which case it points to the read/write location whereas html1direxp only points to the read-only access location. For extra portability, you should only use this variable within your makefiles. =item C From F: This variable is really the same as sitehtml3direxp, unless you are using C in which case it points to the read/write location whereas html3direxp only points to the read-only access location. For extra portability, you should only use this variable within your makefiles. =item C From F: This variable is really the same as sitelibexp but may differ on those systems using C. For extra portability, only this variable should be used in makefiles. =item C From F: This variable is really the same as siteman1direxp, unless you are using C in which case it points to the read/write location whereas man1direxp only points to the read-only access location. For extra portability, you should only use this variable within your makefiles. =item C From F: This variable is really the same as siteman3direxp, unless you are using C in which case it points to the read/write location whereas man3direxp only points to the read-only access location. For extra portability, you should only use this variable within your makefiles. =item C From F: This variable is usually the same as sitescriptexp, unless you are on a system running C, in which case they may differ slightly. You should always use this variable within your makefiles for portability. =item C From F: This variable describes the C