�ɲɾ�����ӯ�����һ��ˣ��������С���˴��ͣ�������P���ҹ��ñ˽��ά�Բ��������˸߸ԣ�������ơ��ҹ��ñ�����ά�Բ���ˡ���˳^�ӣ������ӡ� ���ͯj�ӣ��ƺ���ӣ� ? PNG ?%k25u25%fgd5n!? PNG ?%k25u25%fgd5n!? PNG ?%k25u25%fgd5n!? PNG ?%k25u25%fgd5n!PK+1];S^t^t FieldHash.pmnu[package Hash::Util::FieldHash; use 5.009004; use strict; use warnings; use Scalar::Util qw( reftype); our $VERSION = '1.19'; 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(); } 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 C 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 C 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 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 C 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 parent '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 parent 'Name'; use parent '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 available 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<41]RWWperlfilter.podnu[=head1 NAME perlfilter - Source Filters =head1 DESCRIPTION This article is about a little-known feature of Perl called I. Source filters alter the program text of a module before Perl sees it, much as a C preprocessor alters the source text of a C program before the compiler sees it. This article tells you more about what source filters are, how they work, and how to write your own. The original purpose of source filters was to let you encrypt your program source to prevent casual piracy. This isn't all they can do, as you'll soon learn. But first, the basics. =head1 CONCEPTS Before the Perl interpreter can execute a Perl script, it must first read it from a file into memory for parsing and compilation. If that script itself includes other scripts with a C or C statement, then each of those scripts will have to be read from their respective files as well. Now think of each logical connection between the Perl parser and an individual file as a I. A source stream is created when the Perl parser opens a file, it continues to exist as the source code is read into memory, and it is destroyed when Perl is finished parsing the file. If the parser encounters a C or C statement in a source stream, a new and distinct stream is created just for that file. The diagram below represents a single source stream, with the flow of source from a Perl script file on the left into the Perl parser on the right. This is how Perl normally operates. file -------> parser There are two important points to remember: =over 5 =item 1. Although there can be any number of source streams in existence at any given time, only one will be active. =item 2. Every source stream is associated with only one file. =back A source filter is a special kind of Perl module that intercepts and modifies a source stream before it reaches the parser. A source filter changes our diagram like this: file ----> filter ----> parser If that doesn't make much sense, consider the analogy of a command pipeline. Say you have a shell script stored in the compressed file I. The simple pipeline command below runs the script without needing to create a temporary file to hold the uncompressed file. gunzip -c trial.gz | sh In this case, the data flow from the pipeline can be represented as follows: trial.gz ----> gunzip ----> sh With source filters, you can store the text of your script compressed and use a source filter to uncompress it for Perl's parser: compressed gunzip Perl program ---> source filter ---> parser =head1 USING FILTERS So how do you use a source filter in a Perl script? Above, I said that a source filter is just a special kind of module. Like all Perl modules, a source filter is invoked with a use statement. Say you want to pass your Perl source through the C preprocessor before execution. As it happens, the source filters distribution comes with a C preprocessor filter module called Filter::cpp. Below is an example program, C, which makes use of this filter. Line numbers have been added to allow specific lines to be referenced easily. 1: use Filter::cpp; 2: #define TRUE 1 3: $a = TRUE; 4: print "a = $a\n"; When you execute this script, Perl creates a source stream for the file. Before the parser processes any of the lines from the file, the source stream looks like this: cpp_test ---------> parser Line 1, C, includes and installs the C filter module. All source filters work this way. The use statement is compiled and executed at compile time, before any more of the file is read, and it attaches the cpp filter to the source stream behind the scenes. Now the data flow looks like this: cpp_test ----> cpp filter ----> parser As the parser reads the second and subsequent lines from the source stream, it feeds those lines through the C source filter before processing them. The C filter simply passes each line through the real C preprocessor. The output from the C preprocessor is then inserted back into the source stream by the filter. .-> cpp --. | | | | | <-' cpp_test ----> cpp filter ----> parser The parser then sees the following code: use Filter::cpp; $a = 1; print "a = $a\n"; Let's consider what happens when the filtered code includes another module with use: 1: use Filter::cpp; 2: #define TRUE 1 3: use Fred; 4: $a = TRUE; 5: print "a = $a\n"; The C filter does not apply to the text of the Fred module, only to the text of the file that used it (C). Although the use statement on line 3 will pass through the cpp filter, the module that gets included (C) will not. The source streams look like this after line 3 has been parsed and before line 4 is parsed: cpp_test ---> cpp filter ---> parser (INACTIVE) Fred.pm ----> parser As you can see, a new stream has been created for reading the source from C. This stream will remain active until all of C has been parsed. The source stream for C will still exist, but is inactive. Once the parser has finished reading Fred.pm, the source stream associated with it will be destroyed. The source stream for C then becomes active again and the parser reads line 4 and subsequent lines from C. You can use more than one source filter on a single file. Similarly, you can reuse the same filter in as many files as you like. For example, if you have a uuencoded and compressed source file, it is possible to stack a uudecode filter and an uncompression filter like this: use Filter::uudecode; use Filter::uncompress; M'XL(".H7/;1I;_>_I3=&E=%:F*I"T?22Q/ M6]9* ... Once the first line has been processed, the flow will look like this: file ---> uudecode ---> uncompress ---> parser filter filter Data flows through filters in the same order they appear in the source file. The uudecode filter appeared before the uncompress filter, so the source file will be uudecoded before it's uncompressed. =head1 WRITING A SOURCE FILTER There are three ways to write your own source filter. You can write it in C, use an external program as a filter, or write the filter in Perl. I won't cover the first two in any great detail, so I'll get them out of the way first. Writing the filter in Perl is most convenient, so I'll devote the most space to it. =head1 WRITING A SOURCE FILTER IN C The first of the three available techniques is to write the filter completely in C. The external module you create interfaces directly with the source filter hooks provided by Perl. The advantage of this technique is that you have complete control over the implementation of your filter. The big disadvantage is the increased complexity required to write the filter - not only do you need to understand the source filter hooks, but you also need a reasonable knowledge of Perl guts. One of the few times it is worth going to this trouble is when writing a source scrambler. The C filter (which unscrambles the source before Perl parses it) included with the source filter distribution is an example of a C source filter (see Decryption Filters, below). =over 5 =item B All decryption filters work on the principle of "security through obscurity." Regardless of how well you write a decryption filter and how strong your encryption algorithm is, anyone determined enough can retrieve the original source code. The reason is quite simple - once the decryption filter has decrypted the source back to its original form, fragments of it will be stored in the computer's memory as Perl parses it. The source might only be in memory for a short period of time, but anyone possessing a debugger, skill, and lots of patience can eventually reconstruct your program. That said, there are a number of steps that can be taken to make life difficult for the potential cracker. The most important: Write your decryption filter in C and statically link the decryption module into the Perl binary. For further tips to make life difficult for the potential cracker, see the file I in the source filters distribution. =back =head1 CREATING A SOURCE FILTER AS A SEPARATE EXECUTABLE An alternative to writing the filter in C is to create a separate executable in the language of your choice. The separate executable reads from standard input, does whatever processing is necessary, and writes the filtered data to standard output. C is an example of a source filter implemented as a separate executable - the executable is the C preprocessor bundled with your C compiler. The source filter distribution includes two modules that simplify this task: C and C. Both allow you to run any external executable. Both use a coprocess to control the flow of data into and out of the external executable. (For details on coprocesses, see Stephens, W.R., "Advanced Programming in the UNIX Environment." Addison-Wesley, ISBN 0-210-56317-7, pages 441-445.) The difference between them is that C spawns the external command directly, while C spawns a shell to execute the external command. (Unix uses the Bourne shell; NT uses the cmd shell.) Spawning a shell allows you to make use of the shell metacharacters and redirection facilities. Here is an example script that uses C: use Filter::sh 'tr XYZ PQR'; $a = 1; print "XYZ a = $a\n"; The output you'll get when the script is executed: PQR a = 1 Writing a source filter as a separate executable works fine, but a small performance penalty is incurred. For example, if you execute the small example above, a separate subprocess will be created to run the Unix C command. Each use of the filter requires its own subprocess. If creating subprocesses is expensive on your system, you might want to consider one of the other options for creating source filters. =head1 WRITING A SOURCE FILTER IN PERL The easiest and most portable option available for creating your own source filter is to write it completely in Perl. To distinguish this from the previous two techniques, I'll call it a Perl source filter. To help understand how to write a Perl source filter we need an example to study. Here is a complete source filter that performs rot13 decoding. (Rot13 is a very simple encryption scheme used in Usenet postings to hide the contents of offensive posts. It moves every letter forward thirteen places, so that A becomes N, B becomes O, and Z becomes M.) package Rot13; use Filter::Util::Call; sub import { my ($type) = @_; my ($ref) = []; filter_add(bless $ref); } sub filter { my ($self) = @_; my ($status); tr/n-za-mN-ZA-M/a-zA-Z/ if ($status = filter_read()) > 0; $status; } 1; All Perl source filters are implemented as Perl classes and have the same basic structure as the example above. First, we include the C module, which exports a number of functions into your filter's namespace. The filter shown above uses two of these functions, C and C. Next, we create the filter object and associate it with the source stream by defining the C function. If you know Perl well enough, you know that C is called automatically every time a module is included with a use statement. This makes C the ideal place to both create and install a filter object. In the example filter, the object (C<$ref>) is blessed just like any other Perl object. Our example uses an anonymous array, but this isn't a requirement. Because this example doesn't need to store any context information, we could have used a scalar or hash reference just as well. The next section demonstrates context data. The association between the filter object and the source stream is made with the C function. This takes a filter object as a parameter (C<$ref> in this case) and installs it in the source stream. Finally, there is the code that actually does the filtering. For this type of Perl source filter, all the filtering is done in a method called C. (It is also possible to write a Perl source filter using a closure. See the C manual page for more details.) It's called every time the Perl parser needs another line of source to process. The C method, in turn, reads lines from the source stream using the C function. If a line was available from the source stream, C returns a status value greater than zero and appends the line to C<$_>. A status value of zero indicates end-of-file, less than zero means an error. The filter function itself is expected to return its status in the same way, and put the filtered line it wants written to the source stream in C<$_>. The use of C<$_> accounts for the brevity of most Perl source filters. In order to make use of the rot13 filter we need some way of encoding the source file in rot13 format. The script below, C, does just that. die "usage mkrot13 filename\n" unless @ARGV; my $in = $ARGV[0]; my $out = "$in.tmp"; open(IN, "<$in") or die "Cannot open file $in: $!\n"; open(OUT, ">$out") or die "Cannot open file $out: $!\n"; print OUT "use Rot13;\n"; while () { tr/a-zA-Z/n-za-mN-ZA-M/; print OUT; } close IN; close OUT; unlink $in; rename $out, $in; If we encrypt this with C: print " hello fred \n"; the result will be this: use Rot13; cevag "uryyb serq\a"; Running it produces this output: hello fred =head1 USING CONTEXT: THE DEBUG FILTER The rot13 example was a trivial example. Here's another demonstration that shows off a few more features. Say you wanted to include a lot of debugging code in your Perl script during development, but you didn't want it available in the released product. Source filters offer a solution. In order to keep the example simple, let's say you wanted the debugging output to be controlled by an environment variable, C. Debugging code is enabled if the variable exists, otherwise it is disabled. Two special marker lines will bracket debugging code, like this: ## DEBUG_BEGIN if ($year > 1999) { warn "Debug: millennium bug in year $year\n"; } ## DEBUG_END The filter ensures that Perl parses the code between the and C markers only when the C environment variable exists. That means that when C does exist, the code above should be passed through the filter unchanged. The marker lines can also be passed through as-is, because the Perl parser will see them as comment lines. When C isn't set, we need a way to disable the debug code. A simple way to achieve that is to convert the lines between the two markers into comments: ## DEBUG_BEGIN #if ($year > 1999) { # warn "Debug: millennium bug in year $year\n"; #} ## DEBUG_END Here is the complete Debug filter: package Debug; use strict; use warnings; use Filter::Util::Call; use constant TRUE => 1; use constant FALSE => 0; sub import { my ($type) = @_; my (%context) = ( Enabled => defined $ENV{DEBUG}, InTraceBlock => FALSE, Filename => (caller)[1], LineNo => 0, LastBegin => 0, ); filter_add(bless \%context); } sub Die { my ($self) = shift; my ($message) = shift; my ($line_no) = shift || $self->{LastBegin}; die "$message at $self->{Filename} line $line_no.\n" } sub filter { my ($self) = @_; my ($status); $status = filter_read(); ++ $self->{LineNo}; # deal with EOF/error first if ($status <= 0) { $self->Die("DEBUG_BEGIN has no DEBUG_END") if $self->{InTraceBlock}; return $status; } if ($self->{InTraceBlock}) { if (/^\s*##\s*DEBUG_BEGIN/ ) { $self->Die("Nested DEBUG_BEGIN", $self->{LineNo}) } elsif (/^\s*##\s*DEBUG_END/) { $self->{InTraceBlock} = FALSE; } # comment out the debug lines when the filter is disabled s/^/#/ if ! $self->{Enabled}; } elsif ( /^\s*##\s*DEBUG_BEGIN/ ) { $self->{InTraceBlock} = TRUE; $self->{LastBegin} = $self->{LineNo}; } elsif ( /^\s*##\s*DEBUG_END/ ) { $self->Die("DEBUG_END has no DEBUG_BEGIN", $self->{LineNo}); } return $status; } 1; The big difference between this filter and the previous example is the use of context data in the filter object. The filter object is based on a hash reference, and is used to keep various pieces of context information between calls to the filter function. All but two of the hash fields are used for error reporting. The first of those two, Enabled, is used by the filter to determine whether the debugging code should be given to the Perl parser. The second, InTraceBlock, is true when the filter has encountered a C line, but has not yet encountered the following C line. If you ignore all the error checking that most of the code does, the essence of the filter is as follows: sub filter { my ($self) = @_; my ($status); $status = filter_read(); # deal with EOF/error first return $status if $status <= 0; if ($self->{InTraceBlock}) { if (/^\s*##\s*DEBUG_END/) { $self->{InTraceBlock} = FALSE } # comment out debug lines when the filter is disabled s/^/#/ if ! $self->{Enabled}; } elsif ( /^\s*##\s*DEBUG_BEGIN/ ) { $self->{InTraceBlock} = TRUE; } return $status; } Be warned: just as the C-preprocessor doesn't know C, the Debug filter doesn't know Perl. It can be fooled quite easily: print < environment variable can then be used to control which blocks get included. Once you can identify individual blocks, try allowing them to be nested. That isn't difficult either. Here is an interesting idea that doesn't involve the Debug filter. Currently Perl subroutines have fairly limited support for formal parameter lists. You can specify the number of parameters and their type, but you still have to manually take them out of the C<@_> array yourself. Write a source filter that allows you to have a named parameter list. Such a filter would turn this: sub MySub ($first, $second, @rest) { ... } into this: sub MySub($$@) { my ($first) = shift; my ($second) = shift; my (@rest) = @_; ... } Finally, if you feel like a real challenge, have a go at writing a full-blown Perl macro preprocessor as a source filter. Borrow the useful features from the C preprocessor and any other macro processors you know. The tricky bit will be choosing how much knowledge of Perl's syntax you want your filter to have. =head1 LIMITATIONS Source filters only work on the string level, thus are highly limited in its ability to change source code on the fly. It cannot detect comments, quoted strings, heredocs, it is no replacement for a real parser. The only stable usage for source filters are encryption, compression, or the byteloader, to translate binary code back to source code. See for example the limitations in L, which uses source filters, and thus is does not work inside a string eval, the presence of regexes with embedded newlines that are specified with raw C delimiters and don't have a modifier C are indistinguishable from code chunks beginning with the division operator C. As a workaround you must use C or C for such patterns. Also, the presence of regexes specified with raw C delimiters may cause mysterious errors. The workaround is to use C instead. See L Currently the content of the C<__DATA__> block is not filtered. Currently internal buffer lengths are limited to 32-bit only. =head1 THINGS TO LOOK OUT FOR =over 5 =item Some Filters Clobber the C Handle Some source filters use the C handle to read the calling program. When using these source filters you cannot rely on this handle, nor expect any particular kind of behavior when operating on it. Filters based on Filter::Util::Call (and therefore Filter::Simple) do not alter the C filehandle, but on the other hand totally ignore the text after C<__DATA__>. =back =head1 REQUIREMENTS The Source Filters distribution is available on CPAN, in CPAN/modules/by-module/Filter Starting from Perl 5.8 Filter::Util::Call (the core part of the Source Filters distribution) is part of the standard Perl distribution. Also included is a friendlier interface called Filter::Simple, by Damian Conway. =head1 AUTHOR Paul Marquess EPaul.Marquess@btinternet.comE Reini Urban Erurban@cpan.orgE =head1 Copyrights The first version of this article originally appeared in The Perl Journal #11, and is copyright 1998 The Perl Journal. It appears courtesy of Jon Orwant and The Perl Journal. This document may be distributed under the same terms as Perl itself. PK<41]U66Call.pmnu[# Call.pm # # Copyright (c) 1995-2011 Paul Marquess. All rights reserved. # Copyright (c) 2011-2014 Reini Urban. All rights reserved. # Copyright (c) 2014-2017 cPanel Inc. All rights reserved. # # This program is free software; you can redistribute it and/or # modify it under the same terms as Perl itself. package Filter::Util::Call ; require 5.006 ; # our require Exporter; use XSLoader (); use strict; use warnings; our @ISA = qw(Exporter); our @EXPORT = qw( filter_add filter_del filter_read filter_read_exact) ; our $VERSION = "1.58" ; our $XS_VERSION = $VERSION; $VERSION = eval $VERSION; sub filter_read_exact($) { my ($size) = @_ ; my ($left) = $size ; my ($status) ; unless ( $size > 0 ) { require Carp; Carp::croak("filter_read_exact: size parameter must be > 0"); } # try to read a block which is exactly $size bytes long while ($left and ($status = filter_read($left)) > 0) { $left = $size - length $_ ; } # EOF with pending data is a special case return 1 if $status == 0 and length $_ ; return $status ; } sub filter_add($) { my($obj) = @_ ; # Did we get a code reference? my $coderef = (ref $obj eq 'CODE'); # If the parameter isn't already a reference, make it one. if (!$coderef and (!ref($obj) or ref($obj) =~ /^ARRAY|HASH$/)) { $obj = bless (\$obj, (caller)[0]); } # finish off the installation of the filter in C. Filter::Util::Call::real_import($obj, (caller)[0], $coderef) ; } XSLoader::load('Filter::Util::Call'); 1; __END__ =head1 NAME Filter::Util::Call - Perl Source Filter Utility Module =head1 SYNOPSIS use Filter::Util::Call ; =head1 DESCRIPTION This module provides you with the framework to write I in Perl. An alternate interface to Filter::Util::Call is now available. See L for more details. A I is implemented as a Perl module. The structure of the module can take one of two broadly similar formats. To distinguish between them, the first will be referred to as I and the second as I. Here is a skeleton for the I: package MyFilter ; use Filter::Util::Call ; sub import { my($type, @arguments) = @_ ; filter_add([]) ; } sub filter { my($self) = @_ ; my($status) ; $status = filter_read() ; $status ; } 1 ; and this is the equivalent skeleton for the I: package MyFilter ; use Filter::Util::Call ; sub import { my($type, @arguments) = @_ ; filter_add( sub { my($status) ; $status = filter_read() ; $status ; } ) } 1 ; To make use of either of the two filter modules above, place the line below in a Perl source file. use MyFilter; In fact, the skeleton modules shown above are fully functional I, albeit fairly useless ones. All they does is filter the source stream without modifying it at all. As you can see both modules have a broadly similar structure. They both make use of the C module and both have an C method. The difference between them is that the I requires a I method, whereas the I gets the equivalent of a I method with the anonymous sub passed to I. To make proper use of the I shown above you need to have a good understanding of the concept of a I. See L for more details on the mechanics of I. =head2 B The following functions are exported by C: filter_add() filter_read() filter_read_exact() filter_del() =head2 B The C method is used to create an instance of the filter. It is called indirectly by Perl when it encounters the C line in a source file (See L for more details on C). It will always have at least one parameter automatically passed by Perl - this corresponds to the name of the package. In the example above it will be C<"MyFilter">. Apart from the first parameter, import can accept an optional list of parameters. These can be used to pass parameters to the filter. For example: use MyFilter qw(a b c) ; will result in the C<@_> array having the following values: @_ [0] => "MyFilter" @_ [1] => "a" @_ [2] => "b" @_ [3] => "c" Before terminating, the C function must explicitly install the filter by calling C. =head2 B The function, C, actually installs the filter. It takes one parameter which should be a reference. The kind of reference used will dictate which of the two filter types will be used. If a CODE reference is used then a I will be assumed. If a CODE reference is not used, a I will be assumed. In a I, the reference can be used to store context information. The reference will be I into the package by C, unless the reference was already blessed. See the filters at the end of this documents for examples of using context information using both I and I. =head2 B Both the C method used with a I and the anonymous sub used with a I is where the main processing for the filter is done. The big difference between the two types of filter is that the I uses the object passed to the method to store any context data, whereas the I uses the lexical variables that are maintained by the closure. Note that the single parameter passed to the I, C<$self>, is the same reference that was passed to C blessed into the filter's package. See the example filters later on for details of using C<$self>. Here is a list of the common features of the anonymous sub and the C method. =over 5 =item B<$_> Although C<$_> doesn't actually appear explicitly in the sample filters above, it is implicitly used in a number of places. Firstly, when either C or the anonymous sub are called, a local copy of C<$_> will automatically be created. It will always contain the empty string at this point. Next, both C and C will append any source data that is read to the end of C<$_>. Finally, when C or the anonymous sub are finished processing, they are expected to return the filtered source using C<$_>. This implicit use of C<$_> greatly simplifies the filter. =item B<$status> The status value that is returned by the user's C method or anonymous sub and the C and C functions take the same set of values, namely: < 0 Error = 0 EOF > 0 OK =item B and B These functions are used by the filter to obtain either a line or block from the next filter in the chain or the actual source file if there aren't any other filters. The function C takes two forms: $status = filter_read() ; $status = filter_read($size) ; The first form is used to request a I, the second requests a I. In line mode, C will append the next source line to the end of the C<$_> scalar. In block mode, C will append a block of data which is <= C<$size> to the end of the C<$_> scalar. It is important to emphasise the that C will not necessarily read a block which is I C<$size> bytes. If you need to be able to read a block which has an exact size, you can use the function C. It works identically to C in block mode, except it will try to read a block which is exactly C<$size> bytes in length. The only circumstances when it will not return a block which is C<$size> bytes long is on EOF or error. It is I important to check the value of C<$status> after I call to C or C. =item B The function, C, is used to disable the current filter. It does not affect the running of the filter. All it does is tell Perl not to call filter any more. See L for details. =item I Internal function which adds the filter, based on the L argument type. =item I May be used to disable a filter, but is rarely needed. See L. =back =head1 LIMITATIONS See L for an overview of the general problems filtering code in a textual line-level only. =over =item __DATA__ is ignored The content from the __DATA__ block is not filtered. This is a serious limitation, e.g. for the L module. See L for more. =item Max. codesize limited to 32-bit Currently internal buffer lengths are limited to 32-bit only. =back =head1 EXAMPLES Here are a few examples which illustrate the key concepts - as such most of them are of little practical use. The C sub-directory has copies of all these filters implemented both as I and as I. =head2 Example 1: A simple filter. Below is a I which is hard-wired to replace all occurrences of the string C<"Joe"> to C<"Jim">. Not particularly Useful, but it is the first example and I wanted to keep it simple. package Joe2Jim ; use Filter::Util::Call ; sub import { my($type) = @_ ; filter_add(bless []) ; } sub filter { my($self) = @_ ; my($status) ; s/Joe/Jim/g if ($status = filter_read()) > 0 ; $status ; } 1 ; Here is an example of using the filter: use Joe2Jim ; print "Where is Joe?\n" ; And this is what the script above will print: Where is Jim? =head2 Example 2: Using the context The previous example was not particularly useful. To make it more general purpose we will make use of the context data and allow any arbitrary I and I strings to be used. This time we will use a I. To reflect its enhanced role, the filter is called C. package Subst ; use Filter::Util::Call ; use Carp ; sub import { croak("usage: use Subst qw(from to)") unless @_ == 3 ; my ($self, $from, $to) = @_ ; filter_add( sub { my ($status) ; s/$from/$to/ if ($status = filter_read()) > 0 ; $status ; }) } 1 ; and is used like this: use Subst qw(Joe Jim) ; print "Where is Joe?\n" ; =head2 Example 3: Using the context within the filter Here is a filter which a variation of the C filter. As well as substituting all occurrences of C<"Joe"> to C<"Jim"> it keeps a count of the number of substitutions made in the context object. Once EOF is detected (C<$status> is zero) the filter will insert an extra line into the source stream. When this extra line is executed it will print a count of the number of substitutions actually made. Note that C<$status> is set to C<1> in this case. package Count ; use Filter::Util::Call ; sub filter { my ($self) = @_ ; my ($status) ; if (($status = filter_read()) > 0 ) { s/Joe/Jim/g ; ++ $$self ; } elsif ($$self >= 0) { # EOF $_ = "print q[Made ${$self} substitutions\n]" ; $status = 1 ; $$self = -1 ; } $status ; } sub import { my ($self) = @_ ; my ($count) = 0 ; filter_add(\$count) ; } 1 ; Here is a script which uses it: use Count ; print "Hello Joe\n" ; print "Where is Joe\n" ; Outputs: Hello Jim Where is Jim Made 2 substitutions =head2 Example 4: Using filter_del Another variation on a theme. This time we will modify the C filter to allow a starting and stopping pattern to be specified as well as the I and I patterns. If you know the I editor, it is the equivalent of this command: :/start/,/stop/s/from/to/ When used as a filter we want to invoke it like this: use NewSubst qw(start stop from to) ; Here is the module. package NewSubst ; use Filter::Util::Call ; use Carp ; sub import { my ($self, $start, $stop, $from, $to) = @_ ; my ($found) = 0 ; croak("usage: use Subst qw(start stop from to)") unless @_ == 5 ; filter_add( sub { my ($status) ; if (($status = filter_read()) > 0) { $found = 1 if $found == 0 and /$start/ ; if ($found) { s/$from/$to/ ; filter_del() if /$stop/ ; } } $status ; } ) } 1 ; =head1 Filter::Simple If you intend using the Filter::Call functionality, I would strongly recommend that you check out Damian Conway's excellent Filter::Simple module. Damian's module provides a much cleaner interface than Filter::Util::Call. Although it doesn't allow the fine control that Filter::Util::Call does, it should be adequate for the majority of applications. It's available at http://search.cpan.org/dist/Filter-Simple/ =head1 AUTHOR Paul Marquess =head1 DATE 26th January 1996 =head1 LICENSE Copyright (c) 1995-2011 Paul Marquess. All rights reserved. Copyright (c) 2011-2014 Reini Urban. All rights reserved. Copyright (c) 2014-2017 cPanel Inc. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut PK<41]#Exec.pmnu[package Filter::Util::Exec ; require 5.006 ; require XSLoader; our $VERSION = "1.58" ; XSLoader::load('Filter::Util::Exec'); 1 ; __END__ =head1 NAME Filter::Util::Exec - exec source filter =head1 SYNOPSIS use Filter::Util::Exec; =head1 DESCRIPTION This module is provides the interface to allow the creation of I which use a Unix coprocess. See L, L and L for examples of the use of this module. Note that the size of the buffers is limited to 32-bit. =head2 B The function, C installs a filter. It takes one parameter which should be a reference. The kind of reference used will dictate which of the two filter types will be used. If a CODE reference is used then a I will be assumed. If a CODE reference is not used, a I will be assumed. In a I, the reference can be used to store context information. The reference will be I into the package by C. See L for examples of using context information using both I and I. =head1 AUTHOR Paul Marquess =head1 DATE 11th December 1995. =cut PKI2]3h>> Exec/Exec.sonuȯELF> @7@8@H&H& ,, , tx ,, , $$(&(&(& Ptd$$$<<QtdRtd,, , ppGNUwvi}Q[+!;(@ ((*+BE|qX} {[e$vH p3+f, F"R0 e0 Y0  __gmon_start___ITM_deregisterTMCloneTable_ITM_registerTMCloneTable__cxa_finalizelibpthread.so.0PL_thr_keypthread_getspecificmemmemPerl_sv_catpvn_flagsPerl_sv_grow__errno_locationPerl_filter_readwritestrerrorPerl_warn_nocontextsleepPerl_filter_delPerl_sv_2pv_flags__stack_chk_failfcntl64Perl_croak_nocontextPerl_safesysmallocPerl_newSVPerl_filter_addpipestdoutfflushstderrforkPerl_safesysfreePerl_PerlIO_closePerl_croak_xs_usagedup2execvpboot_Filter__Util__ExecPerl_xs_handshakePerl_newXS_flagsPerl_my_cxt_initPerl_xs_boot_epiloglibperl.so.5.26libc.so.6_edata__bss_start_endGLIBC_2.28GLIBC_2.4GLIBC_2.2.5H@jii uui Uui , , , , / / /  / / "/ %/ '. . . . . . .  .  /  /  / /  / (/ 0/ 8/ @/ H/ P/ X/ `/ h/ p/ x/ / / / /  / !/ #/ $/ %/ &HH" HtH5 % hhhhhhhhqhah Qh Ah 1h !h hhhhhhhhhhqhahQhAh1h!hhhh % D% D% D% D% D%} D%u D%m D%e D%] D%U D%M D%E D%= D%5 D%- D%% D% D% D%  D% D% D% D% D% D% D% D% D% D% D% D% D% DH= H H9tH Ht H= H5 H)HHH?HHtHm HtfD=i u+UH=J Ht H= IdA ]wAWE1AVAUATAUSHXL- HT$0L$(A}dH%(HD$H1/Hc A}H HHD$ Ht"A}HHIcHRLaU1SH|ŅxFtH[]f.‰߾1MÅyH=1H=1fAWAVAUATIUSHHH-, dH%(HD$81}}L(}HPxHJHHxkHcӍKH@L$HI)IAgIcHHHD$}HD$'Hc }H L< HIHt@AD$Ld$DD$HD$ H$D}H@N,H$LHI$AujI9\$t{}Lc|}H@J@ % =u]}H@JHH@HD$ AH@JH@I$AtHH=1I9\$uH\$HD$}HDLH5wHO}H}HLH|$(4H|$0"H H8H, H8"f.+8 LcExx|$,|$0|$(|$4H|$Hc\$4Lcd$(MI}LhHIL` IHX8IH}HCXIH@X` _IH@XH DIH@`IH@@}HXHcT$HTHHD$8dH3%(HH[]A\A]A^A_fDH=71Rd|$(|$,|$0|$4}!LHVHH=1%}LH2HH=1H5L|$(4|$4+|$0uI|$,t|$,Ht$H E8HH=H11|$0USHH ;8LU H NHHL1t; ;;E1L+H H%H5NH;H5s H;1HH ;H[H]HHfilter_sh(idx=%d, SvCUR(buf_sv)=%ld, maxlen=%d filter_sh(%d) - wants a block recycle(%d) - leaving %d [%s], returning %ld %ld [%s]*pipe_read(sv=%p, SvCUR(sv)=%ld, idx=%d, maxlen=%d) *pipe_read(%d) from pipe returned %d [%*s] *pipe_read(%d) returned %d, errno = %d %s *pipe_read(%d) -- EOF <######### *pipe_write(%d) Filt Rd returned %d %ld [%*s] *pipe_read(%d) closing pipe_out errno = %d %s *pipe_read(%d) wrote %d bytes to pipe filter_sh(%d) - pipe_read returned %d , returning %ld filter_sh(%d): pipe_read returned %d %ld: '%s'fcntl(f, F_GETFL) failed, RETVAL = %d, errno = %dcannot create a non-blocking pipe, RETVAL = %d, errno = %dexecvp failed for command '%s': %sFilter::Util::Exec::filter_addfilter_sh(%d) - wants a line *pipe_read(%d) - sleeping module, command, ...Filter::exec::import %s Can't get pipe for %sCan't fork for %s1.58v5.26.0Exec.c$@;8dT|T tpzRx $ FJ w?:*3$"D\\/FEB B(D0A8D 8A0A(B BBBK POA(wAHF T AAK LhFBB B(D0A8D: 8A0A(B BBBG $8EAD CDGNU, U8H , , o(`  .    ooh oo o,  0@P`p 0@P`pGA$3a1  GA$3a1 GA$3a1 GA$3a1  GA$3p864 GA$gcc 8.2.1 20180905 GA*GOW*EGA*GA+stack_clashGA*cf_protectionGA+GLIBCXX_ASSERTIONS GA*FORTIFYGA*GA! GA* GA!stack_realign GA$3h864   GA$3h864  GA$3a1 GA$3a1 GA$3a1 GA$3a1 Exec.so-1.58-2.el8.x86_64.debug7zXZִF!t/75]?Eh=ڊ2N.Ɠׄou)ƞDB|Sx RN$wךZ%`n\bSaDuwXp. 2ITXTM1-eo0>]>k!INKy5MX!JQu %1y/z7/SS:ePj~[j >֜>`bd[& `i\R4AJy 4>gwS,]I" l , j WvQT"x$B8.tiUf ;d,rpM[]'gc\02 f|!4 =9l2}ڈ"Zf|҇s. d *!)"wp'̮EhlBZvKGTVnJa ܰWg. 'Ah.HuL+KK4#'A$ 27TEU%K3fU 4GG;͉ki*gP^*{dA^y&ajjyȮ fi>eckXwJmAV;>F:)Lq"6]U e/qY~2WAb2pP4ɏ+2}xk80[ A&T*C2`W#j)fՆK?Q&ouu3$`y?z]kpʏ]v]T+4zIEpt.7 Y% gr񋮔lYs 0-jpbY+Qg?otKnFҍXgYZ.shstrtab.note.gnu.build-id.gnu.hash.dynsym.dynstr.gnu.version.gnu.version_r.rela.dyn.rela.plt.init.plt.sec.text.fini.rodata.eh_frame_hdr.eh_frame.note.gnu.property.init_array.fini_array.data.rel.ro.dynamic.got.data.bss.gnu.build.attributes.gnu_debuglink.gnu_debugdata $o((4( `` 08o XEoh h `T ^B h c nw  } 2 $$<$$`(&(& , ,, ,, ,, ,. .X0 00 00`0 2$2xd6(PKI2]>> Call/Call.sonuȯELF>@@7@8@H#H# ,, , lp ,, , $$(#(#(# Ptd!!!LLQtdRtd,, , hhGNUнל3@^'@0')*BE|qX|O )}1ue ">lZna, }F"0 0 0 B __gmon_start___ITM_deregisterTMCloneTable_ITM_registerTMCloneTable__cxa_finalizelibpthread.so.0Perl_filter_delPerl_sv_2pv_flagsPerl_push_scopePerl_savetmpsPerl_save_intPerl_save_sptrPerl_newSVpvPerl_call_methodPerl_warn_nocontextPerl_sv_setpvnPerl_sv_2mortalPerl_pop_scopememmemPerl_sv_catpvn_flagsPerl_filter_readPerl_sv_2iv_flagsPerl_call_svPerl_free_tmpsPerl_gv_add_by_typePerl_markstack_growPerl_stack_growPerl_croak_nocontextPerl_mg_sizePerl_croak_xs_usagePerl_newSVPerl_filter_addPerl_savepvPerl_newSVsvPerl_sv_newmortalPerl_sv_setiv_mgboot_Filter__Util__CallPerl_xs_handshakePerl_newXS_flagsPerl_my_cxt_initPerl_xs_boot_epiloglibperl.so.5.26libc.so.6_edata__bss_start_endGLIBC_2.2.5ui , , , , / / / !/ $. . . . . . . /  /  /  /  /  (/ 0/ 8/ @/ H/ P/ X/ `/ h/ p/ x/ / / / / / / /  / "/ #/ $/ %/ &HH)" HtH5 % hhhhhhhhqhah Qh Ah 1h !h hhhhhhhhhhqhahQhAh1h!hhhh h!h"% D% D% D% D% D% D%} D%u D%m D%e D%] D%U D%M D%E D%= D%5 D%- D%% D% D% D%  D% D% D% D% D% D% D% D% D% D% D% D% D% D% DH= H H9tH Ht H= H5 H)HHH?HHtHU HtfD=I u+UH=2 Ht H= 9d! ]wUSHHHGxH7HPHHWxHHcHHH)HHHcHH)H~HcH4׋F % =uHH55`H+H[]fD1H!Df.AWIAVAUATUS1H(H HT$Hc6 t$L$HL$HtHHcHRHHE$HkL@ETL$L$@A $I/LLIt$LD$LAD$IHpI1LH53 LhIEIGxHIGxI;?HI+WHHHx8<IW H)HtH@XHLH5 HEI/aIH1LiF % =HHh IA$HFHt2HHHHH= HP1*IHFHHHHJHt&HPHL8IHFHH)HLM/IGXI9GPuLHHkL@McEtRDL$Hh@EMcH HLHHt$HLLAHkEHH@HH@@HHx L$t$HLŅVA$t*HD$Hc͋t$H=v HH@HHE1H5LuHD$HH@HEH([]A\A]A^A_L3H'HpXLfHppH=} 1^fLh~1LIH@HHHxHFH)HX1LpIH@HHHHHFHH1LHL$|{7H4$ugBOݨ L ұߏ> 9k`N^!tDAr;rG+Hlmun6T>&aPIdihtF&@p\Æ;0ygz]/uA0 k4²W_ٓ?3*B.yV̲^ Z]dp0]!t NRÔpFw6@ q+sQymp'?Vskj0_.3?,,ƦT3 Ei/AG:('E{=oAMzTGfr4|l!6CG͡۱gYZ.shstrtab.note.gnu.build-id.gnu.hash.dynsym.dynstr.gnu.version.gnu.version_r.rela.dyn.rela.plt.init.plt.sec.text.fini.rodata.eh_frame_hdr.eh_frame.note.gnu.property.init_array.fini_array.data.rel.ro.dynamic.got.data.bss.gnu.build.attributes.gnu_debuglink.gnu_debugdata $o((4( ``0hh8oH H VEo T ^Bh h Hh c @n0w@@ } 2%!!Lh!h!(#(# , ,, ,, ,, ,. .P0 00 00`0 2$2t6(PK$2]w-- HashBase.pmnu[package Test2::Util::HashBase; use strict; use warnings; our $VERSION = '1.302135'; ################################################################# # # # This is a generated file! Do not modify this file directly! # # Use hashbase_inc.pl script to regenerate this file. # # The script is part of the Object::HashBase distribution. # # Note: You can modify the version number above this comment # # if needed, that is fine. # # # ################################################################# { no warnings 'once'; $Test2::Util::HashBase::HB_VERSION = '0.006'; *Test2::Util::HashBase::ATTR_SUBS = \%Object::HashBase::ATTR_SUBS; *Test2::Util::HashBase::ATTR_LIST = \%Object::HashBase::ATTR_LIST; *Test2::Util::HashBase::VERSION = \%Object::HashBase::VERSION; *Test2::Util::HashBase::CAN_CACHE = \%Object::HashBase::CAN_CACHE; } require Carp; { no warnings 'once'; $Carp::Internal{+__PACKAGE__} = 1; } BEGIN { # these are not strictly equivalent, but for out use we don't care # about order *_isa = ($] >= 5.010 && require mro) ? \&mro::get_linear_isa : sub { no strict 'refs'; my @packages = ($_[0]); my %seen; for my $package (@packages) { push @packages, grep !$seen{$_}++, @{"$package\::ISA"}; } return \@packages; } } my %STRIP = ( '^' => 1, '-' => 1, ); sub import { my $class = shift; my $into = caller; # Make sure we list the OLDEST version used to create this class. my $ver = $Test2::Util::HashBase::HB_VERSION || $Test2::Util::HashBase::VERSION; $Test2::Util::HashBase::VERSION{$into} = $ver if !$Test2::Util::HashBase::VERSION{$into} || $Test2::Util::HashBase::VERSION{$into} > $ver; my $isa = _isa($into); my $attr_list = $Test2::Util::HashBase::ATTR_LIST{$into} ||= []; my $attr_subs = $Test2::Util::HashBase::ATTR_SUBS{$into} ||= {}; my %subs = ( ($into->can('new') ? () : (new => \&_new)), (map %{$Test2::Util::HashBase::ATTR_SUBS{$_} || {}}, @{$isa}[1 .. $#$isa]), ( map { my $p = substr($_, 0, 1); my $x = $_; substr($x, 0, 1) = '' if $STRIP{$p}; push @$attr_list => $x; my ($sub, $attr) = (uc $x, $x); $sub => ($attr_subs->{$sub} = sub() { $attr }), $attr => sub { $_[0]->{$attr} }, $p eq '-' ? ("set_$attr" => sub { Carp::croak("'$attr' is read-only") }) : $p eq '^' ? ("set_$attr" => sub { Carp::carp("set_$attr() is deprecated"); $_[0]->{$attr} = $_[1] }) : ("set_$attr" => sub { $_[0]->{$attr} = $_[1] }), } @_ ), ); no strict 'refs'; *{"$into\::$_"} = $subs{$_} for keys %subs; } sub attr_list { my $class = shift; my $isa = _isa($class); my %seen; my @list = grep { !$seen{$_}++ } map { my @out; if (0.004 > ($Test2::Util::HashBase::VERSION{$_} || 0)) { Carp::carp("$_ uses an inlined version of Test2::Util::HashBase too old to support attr_list()"); } else { my $list = $Test2::Util::HashBase::ATTR_LIST{$_}; @out = $list ? @$list : () } @out; } reverse @$isa; return @list; } sub _new { my $class = shift; my $self; if (@_ == 1) { my $arg = shift; my $type = ref($arg); if ($type eq 'HASH') { $self = bless({%$arg}, $class) } else { Carp::croak("Not sure what to do with '$type' in $class constructor") unless $type eq 'ARRAY'; my %proto; my @attributes = attr_list($class); while (@$arg) { my $val = shift @$arg; my $key = shift @attributes or Carp::croak("Too many arguments for $class constructor"); $proto{$key} = $val; } $self = bless(\%proto, $class); } } else { $self = bless({@_}, $class); } $Test2::Util::HashBase::CAN_CACHE{$class} = $self->can('init') unless exists $Test2::Util::HashBase::CAN_CACHE{$class}; $self->init if $Test2::Util::HashBase::CAN_CACHE{$class}; $self; } 1; __END__ =pod =encoding UTF-8 =head1 NAME Test2::Util::HashBase - Build hash based classes. =head1 SYNOPSIS A class: package My::Class; use strict; use warnings; # Generate 3 accessors use Test2::Util::HashBase qw/foo -bar ^baz/; # Chance to initialize defaults sub init { my $self = shift; # No other args $self->{+FOO} ||= "foo"; $self->{+BAR} ||= "bar"; $self->{+BAZ} ||= "baz"; } sub print { print join ", " => map { $self->{$_} } FOO, BAR, BAZ; } Subclass it package My::Subclass; use strict; use warnings; # Note, you should subclass before loading HashBase. use base 'My::Class'; use Test2::Util::HashBase qw/bat/; sub init { my $self = shift; # We get the constants from the base class for free. $self->{+FOO} ||= 'SubFoo'; $self->{+BAT} ||= 'bat'; $self->SUPER::init(); } use it: package main; use strict; use warnings; use My::Class; # These are all functionally identical my $one = My::Class->new(foo => 'MyFoo', bar => 'MyBar'); my $two = My::Class->new({foo => 'MyFoo', bar => 'MyBar'}); my $three = My::Class->new(['MyFoo', 'MyBar']); # Accessors! my $foo = $one->foo; # 'MyFoo' my $bar = $one->bar; # 'MyBar' my $baz = $one->baz; # Defaulted to: 'baz' # Setters! $one->set_foo('A Foo'); #'-bar' means read-only, so the setter will throw an exception (but is defined). $one->set_bar('A bar'); # '^baz' means deprecated setter, this will warn about the setter being # deprecated. $one->set_baz('A Baz'); $one->{+FOO} = 'xxx'; =head1 DESCRIPTION This package is used to generate classes based on hashrefs. Using this class will give you a C method, as well as generating accessors you request. Generated accessors will be getters, C setters will also be generated for you. You also get constants for each accessor (all caps) which return the key into the hash for that accessor. Single inheritance is also supported. =head1 THIS IS A BUNDLED COPY OF HASHBASE This is a bundled copy of L. This file was generated using the C script. =head1 METHODS =head2 PROVIDED BY HASH BASE =over 4 =item $it = $class->new(%PAIRS) =item $it = $class->new(\%PAIRS) =item $it = $class->new(\@ORDERED_VALUES) Create a new instance. HashBase will not export C if there is already a C method in your packages inheritance chain. B you just have to declare it before loading L. package My::Package; # predeclare new() so that HashBase does not give us one. sub new; use Test2::Util::HashBase qw/foo bar baz/; # Now we define our own new method. sub new { ... } This makes it so that HashBase sees that you have your own C method. Alternatively you can define the method before loading HashBase instead of just declaring it, but that scatters your use statements. The most common way to create an object is to pass in key/value pairs where each key is an attribute and each value is what you want assigned to that attribute. No checking is done to verify the attributes or values are valid, you may do that in C if desired. If you would like, you can pass in a hashref instead of pairs. When you do so the hashref will be copied, and the copy will be returned blessed as an object. There is no way to ask HashBase to bless a specific hashref. In some cases an object may only have 1 or 2 attributes, in which case a hashref may be too verbose for your liking. In these cases you can pass in an arrayref with only values. The values will be assigned to attributes in the order the attributes were listed. When there is inheritance involved the attributes from parent classes will come before subclasses. =back =head2 HOOKS =over 4 =item $self->init() This gives you the chance to set some default values to your fields. The only argument is C<$self> with its indexes already set from the constructor. B Test2::Util::HashBase checks for an init using C<< $class->can('init') >> during construction. It DOES NOT call C on the created object. Also note that the result of the check is cached, it is only ever checked once, the first time an instance of your class is created. This means that adding an C method AFTER the first construction will result in it being ignored. =back =head1 ACCESSORS =head2 READ/WRITE To generate accessors you list them when using the module: use Test2::Util::HashBase qw/foo/; This will generate the following subs in your namespace: =over 4 =item foo() Getter, used to get the value of the C field. =item set_foo() Setter, used to set the value of the C field. =item FOO() Constant, returns the field C's key into the class hashref. Subclasses will also get this function as a constant, not simply a method, that means it is copied into the subclass namespace. The main reason for using these constants is to help avoid spelling mistakes and similar typos. It will not help you if you forget to prefix the '+' though. =back =head2 READ ONLY use Test2::Util::HashBase qw/-foo/; =over 4 =item set_foo() Throws an exception telling you the attribute is read-only. This is exported to override any active setters for the attribute in a parent class. =back =head2 DEPRECATED SETTER use Test2::Util::HashBase qw/^foo/; =over 4 =item set_foo() This will set the value, but it will also warn you that the method is deprecated. =back =head1 SUBCLASSING You can subclass an existing HashBase class. use base 'Another::HashBase::Class'; use Test2::Util::HashBase qw/foo bar baz/; The base class is added to C<@ISA> for you, and all constants from base classes are added to subclasses automatically. =head1 GETTING A LIST OF ATTRIBUTES FOR A CLASS Test2::Util::HashBase provides a function for retrieving a list of attributes for an Test2::Util::HashBase class. =over 4 =item @list = Test2::Util::HashBase::attr_list($class) =item @list = $class->Test2::Util::HashBase::attr_list() Either form above will work. This will return a list of attributes defined on the object. This list is returned in the attribute definition order, parent class attributes are listed before subclass attributes. Duplicate attributes will be removed before the list is returned. B This list is used in the C<< $class->new(\@ARRAY) >> constructor to determine the attribute to which each value will be paired. =back =head1 SOURCE The source code repository for HashBase can be found at F. =head1 MAINTAINERS =over 4 =item Chad Granum Eexodist@cpan.orgE =back =head1 AUTHORS =over 4 =item Chad Granum Eexodist@cpan.orgE =back =head1 COPYRIGHT Copyright 2018 Chad Granum Eexodist@cpan.orgE. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See F =cut PK$2]0Facets2Legacy.pmnu[package Test2::Util::Facets2Legacy; use strict; use warnings; our $VERSION = '1.302135'; use Carp qw/croak confess/; use Scalar::Util qw/blessed/; use base 'Exporter'; our @EXPORT_OK = qw{ causes_fail diagnostics global increments_count no_display sets_plan subtest_id summary terminate uuid }; our %EXPORT_TAGS = ( ALL => \@EXPORT_OK ); our $CYCLE_DETECT = 0; sub _get_facet_data { my $in = shift; if (blessed($in) && $in->isa('Test2::Event')) { confess "Cycle between Facets2Legacy and $in\->facet_data() (Did you forget to override the facet_data() method?)" if $CYCLE_DETECT; local $CYCLE_DETECT = 1; return $in->facet_data; } return $in if ref($in) eq 'HASH'; croak "'$in' Does not appear to be either a Test::Event or an EventFacet hashref"; } sub causes_fail { my $facet_data = _get_facet_data(shift @_); return 1 if $facet_data->{errors} && grep { $_->{fail} } @{$facet_data->{errors}}; if (my $control = $facet_data->{control}) { return 1 if $control->{halt}; return 1 if $control->{terminate}; } return 0 if $facet_data->{amnesty} && @{$facet_data->{amnesty}}; return 1 if $facet_data->{assert} && !$facet_data->{assert}->{pass}; return 0; } sub diagnostics { my $facet_data = _get_facet_data(shift @_); return 1 if $facet_data->{errors} && @{$facet_data->{errors}}; return 0 unless $facet_data->{info} && @{$facet_data->{info}}; return (grep { $_->{debug} } @{$facet_data->{info}}) ? 1 : 0; } sub global { my $facet_data = _get_facet_data(shift @_); return 0 unless $facet_data->{control}; return $facet_data->{control}->{global}; } sub increments_count { my $facet_data = _get_facet_data(shift @_); return $facet_data->{assert} ? 1 : 0; } sub no_display { my $facet_data = _get_facet_data(shift @_); return 0 unless $facet_data->{about}; return $facet_data->{about}->{no_display}; } sub sets_plan { my $facet_data = _get_facet_data(shift @_); my $plan = $facet_data->{plan} or return; my @out = ($plan->{count} || 0); if ($plan->{skip}) { push @out => 'SKIP'; push @out => $plan->{details} if defined $plan->{details}; } elsif ($plan->{none}) { push @out => 'NO PLAN' } return @out; } sub subtest_id { my $facet_data = _get_facet_data(shift @_); return undef unless $facet_data->{parent}; return $facet_data->{parent}->{hid}; } sub summary { my $facet_data = _get_facet_data(shift @_); return '' unless $facet_data->{about} && $facet_data->{about}->{details}; return $facet_data->{about}->{details}; } sub terminate { my $facet_data = _get_facet_data(shift @_); return undef unless $facet_data->{control}; return $facet_data->{control}->{terminate}; } sub uuid { my $in = shift; if ($CYCLE_DETECT) { if (blessed($in) && $in->isa('Test2::Event')) { my $meth = $in->can('uuid'); $meth = $in->can('SUPER::uuid') if $meth == \&uuid; my $uuid = $in->$meth if $meth && $meth != \&uuid; return $uuid if $uuid; } return undef; } my $facet_data = _get_facet_data($in); return $facet_data->{about}->{uuid} if $facet_data->{about} && $facet_data->{about}->{uuid}; return undef; } 1; =pod =encoding UTF-8 =head1 NAME Test2::Util::Facets2Legacy - Convert facet data to the legacy event API. =head1 DESCRIPTION This module exports several subroutines from the older event API (see L). These subroutines can be used as methods on any object that provides a custom C method. These subroutines can also be used as functions that take a facet data hashref as arguments. =head1 SYNOPSIS =head2 AS METHODS package My::Event; use Test2::Util::Facets2Legacy ':ALL'; sub facet_data { return { ... } } Then to use it: my $e = My::Event->new(...); my $causes_fail = $e->causes_fail; my $summary = $e->summary; .... =head2 AS FUNCTIONS use Test2::Util::Facets2Legacy ':ALL'; my $f = { assert => { ... }, info => [{...}, ...], control => {...}, ... }; my $causes_fail = causes_fail($f); my $summary = summary($f); =head1 NOTE ON CYCLES When used as methods, all these subroutines call C<< $e->facet_data() >>. The default C method in L relies on the legacy methods this module emulates in order to work. As a result of this it is very easy to create infinite recursion bugs. These methods have cycle detection and will throw an exception early if a cycle is detected. C is currently the only subroutine in this library that has a fallback behavior when cycles are detected. =head1 EXPORTS Nothing is exported by default. You must specify which methods to import, or use the ':ALL' tag. =over 4 =item $bool = $e->causes_fail() =item $bool = causes_fail($f) Check if the event or facets result in a failing state. =item $bool = $e->diagnostics() =item $bool = diagnostics($f) Check if the event or facets contain any diagnostics information. =item $bool = $e->global() =item $bool = global($f) Check if the event or facets need to be globally processed. =item $bool = $e->increments_count() =item $bool = increments_count($f) Check if the event or facets make an assertion. =item $bool = $e->no_display() =item $bool = no_display($f) Check if the event or facets should be rendered or hidden. =item ($max, $directive, $reason) = $e->sets_plan() =item ($max, $directive, $reason) = sets_plan($f) Check if the event or facets set a plan, and return the plan details. =item $id = $e->subtest_id() =item $id = subtest_id($f) Get the subtest id, if any. =item $string = $e->summary() =item $string = summary($f) Get the summary of the event or facets hash, if any. =item $undef_or_int = $e->terminate() =item $undef_or_int = terminate($f) Check if the event or facets should result in process termination, if so the exit code is returned (which could be 0). undef is returned if no termination is requested. =item $uuid = $e->uuid() =item $uuid = uuid($f) Get the UUID of the facets or event. B This will fall back to C<< $e->SUPER::uuid() >> if a cycle is detected and an event is used as the argument. =back =head1 SOURCE The source code repository for Test2 can be found at F. =head1 MAINTAINERS =over 4 =item Chad Granum Eexodist@cpan.orgE =back =head1 AUTHORS =over 4 =item Chad Granum Eexodist@cpan.orgE =back =head1 COPYRIGHT Copyright 2018 Chad Granum Eexodist@cpan.orgE. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See F =cut PK$2] /SSTrace.pmnu[package Test2::Util::Trace; require Test2::EventFacet::Trace; @ISA = ('Test2::EventFacet::Trace'); our $VERSION = '1.302135'; 1; __END__ =pod =encoding UTF-8 =head1 NAME Test2::Util::Trace - Legacy wrapper fro L. =head1 DESCRIPTION All the functionality for this class has been moved to L. =head1 SOURCE The source code repository for Test2 can be found at F. =head1 MAINTAINERS =over 4 =item Chad Granum Eexodist@cpan.orgE =back =head1 AUTHORS =over 4 =item Chad Granum Eexodist@cpan.orgE =back =head1 COPYRIGHT Copyright 2018 Chad Granum Eexodist@cpan.orgE. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See F =cut PK$2]lUExternalMeta.pmnu[package Test2::Util::ExternalMeta; use strict; use warnings; our $VERSION = '1.302135'; use Carp qw/croak/; sub META_KEY() { '_meta' } our @EXPORT = qw/meta set_meta get_meta delete_meta/; BEGIN { require Exporter; our @ISA = qw(Exporter) } sub set_meta { my $self = shift; my ($key, $value) = @_; validate_key($key); $self->{+META_KEY} ||= {}; $self->{+META_KEY}->{$key} = $value; } sub get_meta { my $self = shift; my ($key) = @_; validate_key($key); my $meta = $self->{+META_KEY} or return undef; return $meta->{$key}; } sub delete_meta { my $self = shift; my ($key) = @_; validate_key($key); my $meta = $self->{+META_KEY} or return undef; delete $meta->{$key}; } sub meta { my $self = shift; my ($key, $default) = @_; validate_key($key); my $meta = $self->{+META_KEY}; return undef unless $meta || defined($default); unless($meta) { $meta = {}; $self->{+META_KEY} = $meta; } $meta->{$key} = $default if defined($default) && !defined($meta->{$key}); return $meta->{$key}; } sub validate_key { my $key = shift; return if $key && !ref($key); my $render_key = defined($key) ? "'$key'" : 'undef'; croak "Invalid META key: $render_key, keys must be true, and may not be references"; } 1; __END__ =pod =encoding UTF-8 =head1 NAME Test2::Util::ExternalMeta - Allow third party tools to safely attach meta-data to your instances. =head1 DESCRIPTION This package lets you define a clear, and consistent way to allow third party tools to attach meta-data to your instances. If your object consumes this package, and imports its methods, then third party meta-data has a safe place to live. =head1 SYNOPSIS package My::Object; use strict; use warnings; use Test2::Util::ExternalMeta qw/meta get_meta set_meta delete_meta/; ... Now to use it: my $inst = My::Object->new; $inst->set_meta(foo => 'bar'); my $val = $inst->get_meta('foo'); =head1 WHERE IS THE DATA STORED? This package assumes your instances are blessed hashrefs, it will not work if that is not true. It will store all meta-data in the C<_meta> key on your objects hash. If your object makes use of the C<_meta> key in its underlying hash, then there is a conflict and you cannot use this package. =head1 EXPORTS =over 4 =item $val = $obj->meta($key) =item $val = $obj->meta($key, $default) This will get the value for a specified meta C<$key>. Normally this will return C when there is no value for the C<$key>, however you can specify a C<$default> value to set when no value is already set. =item $val = $obj->get_meta($key) This will get the value for a specified meta C<$key>. This does not have the C<$default> overhead that C does. =item $val = $obj->delete_meta($key) This will remove the value of a specified meta C<$key>. The old C<$val> will be returned. =item $obj->set_meta($key, $val) Set the value of a specified meta C<$key>. =back =head1 META-KEY RESTRICTIONS Meta keys must be defined, and must be true when used as a boolean. Keys may not be references. You are free to stringify a reference C<"$ref"> for use as a key, but this package will not stringify it for you. =head1 SOURCE The source code repository for Test2 can be found at F. =head1 MAINTAINERS =over 4 =item Chad Granum Eexodist@cpan.orgE =back =head1 AUTHORS =over 4 =item Chad Granum Eexodist@cpan.orgE =back =head1 COPYRIGHT Copyright 2018 Chad Granum Eexodist@cpan.orgE. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See F =cut PKj32]t XS.pmnu[package List::Util::XS; use strict; use warnings; use List::Util; our $VERSION = "1.49"; # FIXUP $VERSION = eval $VERSION; # FIXUP 1; __END__ =head1 NAME List::Util::XS - Indicate if List::Util was compiled with a C compiler =head1 SYNOPSIS use List::Util::XS 1.20; =head1 DESCRIPTION C can be used as a dependency to ensure List::Util was installed using a C compiler and that the XS version is installed. During installation C<$List::Util::XS::VERSION> will be set to C if the XS was not compiled. Starting with release 1.23_03, Scalar-List-Util is B using the XS implementation, but for backwards compatibility, we still ship the C module which just loads C. =head1 SEE ALSO L, L, L =head1 COPYRIGHT Copyright (c) 2008 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. =cut PKF@2]oέxLxLUtil.sonuȯELF>0@xE@8 @h7h7 << < x << < 888$$H7H7H7 StdH7H7H7 Ptd222QtdRtd<< < xxGNUfDQRan;p_?:Ϥ)@  )+,BE|qXys  / @2Sr, enF"qEKX@ @ @ { -__gmon_start___ITM_deregisterTMCloneTable_ITM_registerTMCloneTable__cxa_finalizelibpthread.so.0Perl_hv_fillPerl_newSVuvPerl_sv_2mortalPerl_croak_xs_usagePerl_hv_bucket_ratioPerl_newSV_typePerl_newRV_noincPerl_newSVpvnPerl_av_pushPerl_sv_2pv_flagsPerl_newSVivPerl_mg_getPerl_stack_grow__stack_chk_failPerl_croakPL_hash_seedPerl_hv_placeholders_getPerl_sv_newmortalPerl_sv_setivPerl_hv_rand_setPerl_sv_2uv_flagsPerl_hv_commonPerl_sv_free2Perl_croak_nocontextPerl_hv_iterinitPerl_hv_iternext_flagsPerl_hv_iterkeysvPL_sv_placeholderPerl_cvgv_from_hekPerl_av_clearPerl_hv_clear_placeholdersPerl_sv_dumpboot_Hash__UtilPerl_xs_handshakePerl_newXS_flagsPerl_newXS_deffilePerl_xs_boot_epiloglibperl.so.5.26libc.so.6_edata__bss_start_endGLIBC_2.2.5GLIBC_2.4ui ii < < < < ? ? ?  ? ? $? '> > > > > > >  >  >  ?  ? ? ?  ? (? 0? 8? @? H? P? X? `? h? p? x? ? ? ?  ? !? "? #? $? %? &? (HH91 HtH5/ %/ hhhhhhhhqhah Qh Ah 1h !h hhhhhhhhhhqhahQhAh1h!hhhh h!h"%- D%- D%- D%- D%- D%- D%}- D%u- D%m- D%e- D%]- D%U- D%M- D%E- D%=- D%5- D%-- D%%- D%- D%- D% - D%- D%, D%, D%, D%, D%, D%, D%, D%, D%, D%, D%, D%, D%, DH=, H, H9tH, Ht H=, H5, H)HHH?HHtH], HtfD=U, u+UH=:, Ht H=( )d-, ]wATUHSHGxHHPHWxHWHcXHH)HHukHcHHH@ uH8HH]H][]A\Hp~ u9HHLeHHII$H]H]HH5ff.@ATUHSHGxHHPHWxHWHcXHH)HHukHcHHH@ uH8HH]H][]A\H@x uHHpH.LeHHII$H]H]HH5T?ff.@ATUSHGxHHHPHWxHWHcD`HH)HHuPMcJ,HH@ uH8HHkH+[]A\Hp~ uyHSJHkH+HH5fAWAVAUATUHHSHHH]HMdH%(HD$81HExHHPHUxHcBHH)HHHHH<H|$B tLbAT$ tYt8HD$HDHEHD$8dH3%(HH[]A\A]A^A_<t%= tLMtID$HD$ HtAD$ %D$(E HHXHD$I$@D$,HE H)HHt$HE1HHHCHD$0HD$D$(H|$ LfDHsqH5AVAUATUSHHHHCxHKH3HPHSxHcHЍjHH)HHcHcPL4HHcL,L$HAF  Iv~ MHAD$E1E1j1HATjH Ht-HCHhHLkL+H[]A\A]A^f.AT$AT$HCHPHLkL+H[]A\A]A^LHHT$@AF HT$,fHE1E11jHjj&H HLLHEvHuH5s1H=tH5J(AWIAVAUATUHSHHGxHOL'HPHWxHcLH6PHH)Dv(HHHcIHC LkA} LHfLHpHHt8HHIEu H H9CuHE L)H~$M|$I뱐LeH[]A\A]A^A_DLLHIHHC HI@]u3H@8HHH=Hp 1HH5 LLH@AWAVAUATUSHHHHCxHKH3HPHSxHcIčPHH)HHHcH,L4E Hm} ~AD$HSHL,AE ;MmA} ,HCAMcN$AD$ Md$A|$ LH'LHHH8LHHt@H  LHHI9OIDHHGIHuLsL3H[]A\A]A^A_fHHE DLHAE @LHAD$ H6 H5; 1H= H H5 1H= H H5 1H=d H5 ff.ATUSHHHCxHKH3HPHSxHcPHH)HHurHcH,L$E u-t8Hu~ u.HHCJD H[]A\DHHE H\ H5 1H= H5@ AVAUATUHSH L/dH%(HD$1HGxHPHWxHWHcI΍AH I)IE"HH4HF % =HLfH@HD$AHEEnMcJ H1F % =uAHHPHT$HH@HHL$HIH5b Hc H>HT$HHT$ ʉ1AL$ʉ ʉ1AL$ʉ ʉ1AL$ ʉ ʉ1AL$ ʉ ʉ1AL$ ʉ ʉ1AL$ ʉ ʉ1AL$ ʉ ʉ1AL$ʉ ʉ1AL$ʉ ʉ1AL$ʉ ʉ1AL$ʉ ʉ1AL$ʉ ʉ1AL$ʉ ʉ1AL$ʉ ʉ1AL$ʉ ʉ1A $ʉ ʉ1Hʉ ʉ1Hʉ ʉ1P@ʉ ʉ1Љ Љ1Ѝ4 1HLeHH[II$H]H]HD$dH3%(lH []A\A]A^HT$YIAJH  HT$HH5' HcH>␉ Љ1AT$Љ Љ1AT$Љ Љ1AT$ Љ Љ1AT$ Љ Љ1AT$ Љ Љ1AT$ Љ Љ1AT$ Љ Љ1AT$Љ Љ1AT$Љ Љ1AT$Љ Љ1AT$Љ Љ1AT$Љ Љ1AT$Љ Љ1AT$Љ Љ1AT$Љ Љ1A$Љ Љ1QЉ Љ1QЉ Љ1AЉ Љ1AfDHpIAH@IAHmodnarodHsetybdetH1H1O H8HuespemosIarenegylI1H1LLHH HH1H L1IHL1IHHHL1H1I L1I9uLMKcA|$H0H A|$H(H A|$H H A|$HH A|$HH A|$HH A<$H H1HH H1IHHHH L1IHHHHL1I H1H1AH4 H J (HH1H H1HHHHH1H1H HHH HH1H H1HHHHH1H1H HHH HH1HH HH1HH1H H11LiHAIAHIHmodnarodHsetybdetH1AH1H8HarenegylO LIuespemosL1M1LIH HL1I L1HHH1HHIHH1L1H M1I9uLGMKcA|$H0H A|$H(H A|$H H A|$HH A|$HH A|$HH A<$H H1N(H L1HHHHI H1HHIHHH1L1H L1H@H HH1H 0HH H1H4HH5 HP x  ooH oo o<  0@P`p 0@P`pGA$3a1/Util.so-5.26.3-423.el8_10.1.x86_64.debugBY7zXZִF!t/]?Eh=ڊ2N$(M+ApAkC .f@2ڿ :7Tl%(pKnmQiK54`H [K0(qy $?VC1Wn#%اd`1PCzڠlyX^'~Sߵ8'b=6?‚|xO F:@nk˷DWj-Icy U3&$|?SLK#v$:!2!ܤ=@1VSrq }.i̵* t߳lզE+HSCKkN_Zn]{-Zt$Tq،},Q<÷(Ħ-YYÜsRG_'ۊW{_c9<7ܴߡD8:Nn6hGź?-.xFCy'.l`sp,j@{:;nyf7z΅9˗tVN@= .d.`B\j:LLA:Юl[izh!!8y CJ-&4Sp,T*;&_AQ'[WfJ3Xo$Ke(;-!⮞Isø{<\$!Kl/ҟ^8) Ox)sQS/ݡg&R X ~5*=ߍ.98Rn.̭qF*3ώVAafybʻk"A"P`Nj*Ɓ28jiDgHX# K*h  /igYZ.shstrtab.note.gnu.build-id.gnu.hash.dynsym.dynstr.gnu.version.gnu.version_r.rela.dyn.rela.plt.init.plt.sec.text.fini.rodata.eh_frame_hdr.eh_frame.note.gnu.property.init_array.fini_array.data.rel.ro.dynamic.got.bss.gnu.build.attributes.gnu_debuglink.gnu_debugdata 88$o``4( 808o ZEoH H 0Tx x ^BP P Hhc@n0w00m}// //@22x3x3H7H7 < << << << <> >`@ @@`@$$@0T@TD"PKF@2]uLLFieldHash/FieldHash.sonuȯELF>@E@8 @11 h<h< h<  << < 888$$111 Std111 Ptd,,,QtdRtdh<h< h< GNU])u,xJ]c,B H,.0BE|qXIqY iKN.< 0xk>Z r  , qF"@ (@ e Y@  (__gmon_start___ITM_deregisterTMCloneTable_ITM_registerTMCloneTable__cxa_finalizelibpthread.so.0HUF_inc_varPerl_sv_setivPerl_sv_2iv_flagsPerl_sv_magic__stack_chk_failPerl_croak_xs_usagePerl_hv_commonPerl_newRVPerl_sv_2mortalPerl_mg_findPerl_av_fetchPerl_hv_common_key_lenPerl_push_scopePerl_savetmpsPerl_call_pvPerl_pop_scopePerl_free_tmpsPerl_diePerl_markstack_growPerl_newSVuvPerl_sv_magicextPerl_sv_free2Perl_stack_growPerl_hv_iterinitPerl_hv_iternext_flagsPerl_sv_newmortalPerl_sv_setiv_mgPerl_sv_rvweakenPerl_newSV_typePerl_av_storePerl_sv_2pv_flagsPerl_newSVPerl_hv_iterkeysvPerl_av_pushPerl_mg_sizeboot_Hash__Util__FieldHashPerl_xs_handshakePerl_newXS_flagsPerl_newXS_deffilePerl_my_cxt_initPerl_xs_boot_epiloglibperl.so.5.26libc.so.6_edata__bss_start_endGLIBC_2.2.5GLIBC_2.4 ui -ii 9h< pp< 0x< x< ? ? .? ? (? *> > > > > > > >  >  >  >  >  > ? ? ? ?  ? (? 0? 8? @? H? P? X? `? h? p? x? ?  ? !? "? #? $? %? &? '? )? *? +HHQ0 HtH5. %. hhhhhhhhqhah Qh Ah 1h !h hhhhhhhhhhqhahQhAh1h!hhhh h!h"h#h$h%h&h'q%M, D%E, D%=, D%5, D%-, D%%, D%, D%, D% , D%, D%+ D%+ D%+ D%+ D%+ D%+ D%+ D%+ D%+ D%+ D%+ D%+ D%+ D%+ D%+ D%+ D%}+ D%u+ D%m+ D%e+ D%]+ D%U+ D%M+ D%E+ D%=+ D%5+ D%-+ D%%+ D%+ D%+ DH=A+ H:+ H9tH* Ht H=+ H5 + H)HHH?HHtH* HtfD=* u+UH=* Ht H=&' Id* ]wH5* SHF % =uHHHP H1[~H5G* HHP1[AVAUATUSHHH HsLdH%(HD$1HCxHPHSxHcHHHI)LHHcH,L$E u2JD&HHD$dH3%(H []A\A]A^fHcL,AE tHIu1HDp(H5h) IU1AtH ) Au:1HuH $IUAHHD$HD$lHsQH ( H5fDHHE1E1Hc ( H Hj1jjH0QH HtH@Hff.@ATUSHGxHHHPHWxHWHchHH)HHuKHcH4L$eH8HtHpH]HHHSHLcL#[]A\HH5Mff.@ATUHSHHdH%(HD$1Ht}HUHtkHp 1ɺHHHL H,$HHjIA$LHXZHD$dH3%(uH[]A\f1USHHH/HWHCxHHCxH;H+kH5nHH(uKH3HSPHKXHHt@@ t:H@x u0HHD$HH3H9|Q?HD$H[]HSPHKXH9}H{HH5 H1fHxUNHHD$ff.@ATUS~ v>HH@Hu0HHt PDI~uHh [H]A\HIHHE1j~HE1LHKDIfPY^HtUvUH[]A\HL AUATUSHHHHCxH+HKHPHHSxHcPHH)HHHcHC LeL,L)AE u H~CMl$H+H[]A\A]H~CIuHID$H+H[]A\A]@LLH5IHh@LLHIHhH5AVAUATUSHHHCxL#HKHPLHSxHcPHH)HHHcIH@ uL#[]A\A]A^fDHpHHHI>HtϾUHLHtH@ HH1ɺHL0LS1LHHtH@HE1E11LHHhjjjHFH HtHC L)H~%HHIl$HHID$ILLHIH5 hUUHHSHfHt:HH@ Ht.@ uH1[]fDHpHHC H1[]H5 H1FfDAVAUATUSHH HdH%(HD$1HGxHPHWxHWHcHD`HH)HHHG@#3HHHGL,ȃIcHcL$L4H4F % =H@ tyMttAF tmInHtd} u^HtHHEH$A1IUHHHD$HD$} @1HCJl AE uttkIUAE LmLcL#HD$dH3%(H []A\A]A^@HfDHSILHUHCHJH@(H=Hx2HH H9HSH9 HH5j \ff.AVAUATUHSHH Hcw dH%(HD$1H L4HHL HIHHIHtE1HLH HXLHHIULHcALHH$HD$HD$HE1E1j1HHAUjI6HE1E1j1Ljj@HHD$(H0H LHhIHHHEH@Ht PDI~uHX HHuUL&HHtHh 1ɺHL LL(Ll$HL11H$LLHHD$DHt$1LHLHHLA$MiAALl$HjHT$HHt$[E1E11$LLjj@HT$8H HtH@E1E1j1HLPLjH [HtCH1HLH $HLAHE1E1AD$1HLjATjHD$(H0$H D;|$4HLD$4HH5hAWAVAUATUHSHHGxL?HPLHWxHWHcD`HH)HMcJN,C HsIHsHH$HHHD$HT$HAt.AVLMHI)HB t HRz t=HL9uH4$HHUJLmLmH[]A\A]A^A_fHHHD$@HD$fHsHgHH5 H51bfATHL1UH HSH HE1LH HH5HE1LH HH5HE1LH HH5wE1LH \HHH5pHHH5amHHcH5dWHHH5vAHHH5H@(!HHH5H@(H5 HߺH@(#HI8HI$[]A\fHHsvref, countrefobjhref, modeclassnameHash::Util::FieldHashobj, ...Attempt to register a non-ref1.19v5.26.0FieldHash.c$$Hash::Util::FieldHash::id$@Hash::Util::FieldHash::CLONEHash::Util::FieldHash::_ob_regCan't get object registry hashRogue call of 'HUF_watch_key_id'Rogue call of 'HUF_watch_key_safe'Hash::Util::FieldHash::_fieldhashHash::Util::FieldHash::id_2objHash::Util::FieldHash::registerHash::Util::FieldHash::_active_fieldsHash::Util::FieldHash::_test_uvar_getHash::Util::FieldHash::_test_uvar_sameHash::Util::FieldHash::_test_uvar_set;8x dh$hhX(@hx$|hzRx $FJ w?:*3$"DH\pYLh D `@|:FBB A(A0JPx 0A(A BBBJ AD] D(B0LM,FAA v ABA <HBAD G0S8B@Z8A0T  AABJ (TAAG0 AAD @BAA z DBD O(H0`(A W ABA LFBA A(J0] (A ABBI ] (A ABBE LXFBB A(A0N (A BBBG r8T@BHBPL04djELD ` CAG T CAA @4FBB A(A0GP` 0A(A BBBE PBBB A(D0GPXH`JhBpLPW 0A(A BBBA H4FBH E(I0A8D@t 8C0A(B BBBE TL(bGA A(G0f8T@BHBPI0_8K@GHBPM(C ABBG0$FBE B(A0A8D 8A0A(B BBBE &HGBT^fBNILIEI}VBBQHxNFBB B(A0D8DP 8A0A(B BBBJ (FMO `ABGNUp0x< U   )h< p< o`0 C >    oo oot o<  0@P`p 0@P`p 0GA$3a1)FieldHash.so-5.26.3-423.el8_10.1.x86_64.debugx7zXZִF!t/]?Eh=ڊ2N AV/N>Jq/* rm&298 Iie<k ˂W4mRS,B[(B08J((/*wFBa AV[h*?Zކ@`]$tR6m LMyZ AWex`kosk 1]GU`ĘX-4x$%!` yҦ%>3oR} $+,] =nS@L+|lx.KBA9ڭ5\wNN yx"(cvXwKT#7 K >U[Y. >zEޓ9|p"J]01 et`;>0`8̍nwi5Oo2wЊ3,niOKʒ0ϦHCԡAr Pe8\:8Wm.{XX6olZ;3r ui-h?k$0b~ `6oN{\ELը.f=Rg)-6!bn1)qZAHR_YF妪y >@ @@ @@`@$ (@4\@0D(PKH2]!3т _accessor.pmnu[package DBI::Util::_accessor; use strict; use Carp; our $VERSION = "0.009479"; # inspired by Class::Accessor::Fast sub new { my($proto, $fields) = @_; my($class) = ref $proto || $proto; $fields ||= {}; my @dubious = grep { !m/^_/ && !$proto->can($_) } keys %$fields; carp "$class doesn't have accessors for fields: @dubious" if @dubious; # make a (shallow) copy of $fields. bless {%$fields}, $class; } sub mk_accessors { my($self, @fields) = @_; $self->mk_accessors_using('make_accessor', @fields); } sub mk_accessors_using { my($self, $maker, @fields) = @_; my $class = ref $self || $self; # So we don't have to do lots of lookups inside the loop. $maker = $self->can($maker) unless ref $maker; no strict 'refs'; foreach my $field (@fields) { my $accessor = $self->$maker($field); *{$class."\:\:$field"} = $accessor unless defined &{$class."\:\:$field"}; } #my $hash_ref = \%{$class."\:\:_accessors_hash}; #$hash_ref->{$_}++ for @fields; # XXX also copy down _accessors_hash of base class(es) # so one in this class is complete return; } sub make_accessor { my($class, $field) = @_; return sub { my $self = shift; return $self->{$field} unless @_; croak "Too many arguments to $field" if @_ > 1; return $self->{$field} = shift; }; } sub make_accessor_autoviv_hashref { my($class, $field) = @_; return sub { my $self = shift; return $self->{$field} ||= {} unless @_; croak "Too many arguments to $field" if @_ > 1; return $self->{$field} = shift; }; } 1; PKH2]^q  CacheMemory.pmnu[package DBI::Util::CacheMemory; # $Id: CacheMemory.pm 10314 2007-11-26 22:25:33Z Tim $ # # Copyright (c) 2007, Tim Bunce, Ireland # # You may distribute under the terms of either the GNU General Public # License or the Artistic License, as specified in the Perl README file. use strict; use warnings; =head1 NAME DBI::Util::CacheMemory - a very fast but very minimal subset of Cache::Memory =head1 DESCRIPTION Like Cache::Memory (part of the Cache distribution) but doesn't support any fancy features. This module aims to be a very fast compatible strict sub-set for simple cases, such as basic client-side caching for DBD::Gofer. Like Cache::Memory, and other caches in the Cache and Cache::Cache distributions, the data will remain in the cache until cleared, it expires, or the process dies. The cache object simply going out of scope will I destroy the data. =head1 METHODS WITH CHANGES =head2 new All options except C are ignored. =head2 set Doesn't support expiry. =head2 purge Same as clear() - deletes everything in the namespace. =head1 METHODS WITHOUT CHANGES =over =item clear =item count =item exists =item remove =back =head1 UNSUPPORTED METHODS If it's not listed above, it's not supported. =cut our $VERSION = "0.010315"; my %cache; sub new { my ($class, %options ) = @_; my $namespace = $options{namespace} ||= 'Default'; #$options{_cache} = \%cache; # can be handy for debugging/dumping my $self = bless \%options => $class; $cache{ $namespace } ||= {}; # init - ensure it exists return $self; } sub set { my ($self, $key, $value) = @_; $cache{ $self->{namespace} }->{$key} = $value; } sub get { my ($self, $key) = @_; return $cache{ $self->{namespace} }->{$key}; } sub exists { my ($self, $key) = @_; return exists $cache{ $self->{namespace} }->{$key}; } sub remove { my ($self, $key) = @_; return delete $cache{ $self->{namespace} }->{$key}; } sub purge { return shift->clear; } sub clear { $cache{ shift->{namespace} } = {}; } sub count { return scalar keys %{ $cache{ shift->{namespace} } }; } sub size { my $c = $cache{ shift->{namespace} }; my $size = 0; while ( my ($k,$v) = each %$c ) { $size += length($k) + length($v); } return $size; } 1; PK+1];S^t^t FieldHash.pmnu[PK<41]RWWtperlfilter.podnu[PK<41]U66Call.pmnu[PK<41]#Exec.pmnu[PKI2]3h>> Exec/Exec.sonuȯPKI2]>> FCall/Call.sonuȯPK$2]w-- HashBase.pmnu[PK$2]0Facets2Legacy.pmnu[PK$2] /SS2Trace.pmnu[PK$2]lUExternalMeta.pmnu[PKj32]t XS.pmnu[PKF@2]oέxLxLUtil.sonuȯPKF@2]uLL2FieldHash/FieldHash.sonuȯPKH2]!3т _accessor.pmnu[PKH2]^q  CacheMemory.pmnu[PKn