r10383 - in /branches/upstream/libtie-regexphash-perl: ./ current/ current/lib/ current/lib/Tie/ current/t/

vdanjean at users.alioth.debian.org vdanjean at users.alioth.debian.org
Sat Dec 1 12:21:27 UTC 2007


Author: vdanjean
Date: Sat Dec  1 12:21:26 2007
New Revision: 10383

URL: http://svn.debian.org/wsvn/?sc=1&rev=10383
Log:
[svn-inject] Installing original source of libtie-regexphash-perl

Added:
    branches/upstream/libtie-regexphash-perl/
    branches/upstream/libtie-regexphash-perl/current/
    branches/upstream/libtie-regexphash-perl/current/Build.PL
    branches/upstream/libtie-regexphash-perl/current/Changes
    branches/upstream/libtie-regexphash-perl/current/MANIFEST
    branches/upstream/libtie-regexphash-perl/current/META.yml
    branches/upstream/libtie-regexphash-perl/current/Makefile.PL
    branches/upstream/libtie-regexphash-perl/current/README
    branches/upstream/libtie-regexphash-perl/current/SIGNATURE
    branches/upstream/libtie-regexphash-perl/current/lib/
    branches/upstream/libtie-regexphash-perl/current/lib/Tie/
    branches/upstream/libtie-regexphash-perl/current/lib/Tie/RegexpHash.pm
    branches/upstream/libtie-regexphash-perl/current/t/
    branches/upstream/libtie-regexphash-perl/current/t/01-RegexpHash.t
    branches/upstream/libtie-regexphash-perl/current/t/02-RegexpHash.t

Added: branches/upstream/libtie-regexphash-perl/current/Build.PL
URL: http://svn.debian.org/wsvn/branches/upstream/libtie-regexphash-perl/current/Build.PL?rev=10383&op=file
==============================================================================
--- branches/upstream/libtie-regexphash-perl/current/Build.PL (added)
+++ branches/upstream/libtie-regexphash-perl/current/Build.PL Sat Dec  1 12:21:26 2007
@@ -1,0 +1,24 @@
+use Module::Build;
+
+my $build = Module::Build->new
+    (
+     module_name => 'Tie::RegexpHash',
+     license => 'perl',
+     requires => {
+       'perl'                       => '5.005',
+       'Carp'                       => 0,
+     },
+     recommends => {
+       'Pod::Readme'      => 0.02,
+       'Storable'	  => 0,
+     },
+     build_requires => {
+       'Test::More'                 => 0,
+     },
+     create_readme      => ($Module::Build::VERSION >= 0.2702),
+     create_makefile_pl => 'traditional',
+     dist_author        => 'Robert Rothenberg <rrwo at cpan.org>',
+     sign => 1,
+);
+
+$build->create_build_script;

Added: branches/upstream/libtie-regexphash-perl/current/Changes
URL: http://svn.debian.org/wsvn/branches/upstream/libtie-regexphash-perl/current/Changes?rev=10383&op=file
==============================================================================
--- branches/upstream/libtie-regexphash-perl/current/Changes (added)
+++ branches/upstream/libtie-regexphash-perl/current/Changes Sat Dec  1 12:21:26 2007
@@ -1,0 +1,40 @@
+Revision history for Perl extension Tie::RegexpHash.
+
+0.15    11 Feb 2006
+	- updated notes on Storable use in documentation
+	- support serialization with Storable, but do not require
+	  Storable
+	- skip serialization tests if Storable is not available
+
+0.14_03 10 Feb 2006
+	- noted use of Storable in documentation
+	- fix for MANIFEST
+
+0.14_02 10 Feb 2006
+	- fix for freeze subroutine (from Russell Harrison)
+	- tests for serialization hooks (from Russell Harrison)
+
+0.14_01 9 Feb 2006
+	- updated test suite to use Test::More
+	- added serialization hooks with Storable
+	  (patch from Russell Harrison)
+	- README built with Pod::Readme
+
+0.13   3 Jan 2005
+	- added Build.PL, META.yml etc. to distro
+	- fixed typos in warning message
+	- reorganized/updated POD
+	- added more modules to SEE ALSO section
+
+0.12  22 Nov 2002
+	- fixed bug with logic in _find() routine
+
+0.11  27 Jan 2001
+	- added SEE ALSO in POD about Tie::Hash::Regex
+	- should run on Perl 5.005
+	- no longer an Exporter
+	- added stub for test suite
+
+0.10  22 Jan 2001
+	- original version
+

Added: branches/upstream/libtie-regexphash-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/branches/upstream/libtie-regexphash-perl/current/MANIFEST?rev=10383&op=file
==============================================================================
--- branches/upstream/libtie-regexphash-perl/current/MANIFEST (added)
+++ branches/upstream/libtie-regexphash-perl/current/MANIFEST Sat Dec  1 12:21:26 2007
@@ -1,0 +1,10 @@
+Build.PL
+Changes
+lib/Tie/RegexpHash.pm
+MANIFEST			This list of files
+META.yml
+t/01-RegexpHash.t
+t/02-RegexpHash.t
+Makefile.PL
+README
+SIGNATURE    Added here by Module::Build

Added: branches/upstream/libtie-regexphash-perl/current/META.yml
URL: http://svn.debian.org/wsvn/branches/upstream/libtie-regexphash-perl/current/META.yml?rev=10383&op=file
==============================================================================
--- branches/upstream/libtie-regexphash-perl/current/META.yml (added)
+++ branches/upstream/libtie-regexphash-perl/current/META.yml Sat Dec  1 12:21:26 2007
@@ -1,0 +1,25 @@
+---
+name: Tie-RegexpHash
+version: 0.15
+author:
+  - 'Robert Rothenberg <rrwo at cpan.org>'
+abstract: Use regular expressions as hash keys
+license: perl
+resources:
+  license: http://dev.perl.org/licenses/
+requires:
+  Carp: 0
+  perl: 5.005
+build_requires:
+  Test::More: 0
+recommends:
+  Pod::Readme: 0.02
+  Storable: 0
+provides:
+  Tie::RegexpHash:
+    file: lib/Tie/RegexpHash.pm
+    version: 0.15
+generated_by: Module::Build version 0.2707
+meta-spec:
+  url: http://module-build.sourceforge.net/META-spec-v1.2.html
+  version: 1.2

Added: branches/upstream/libtie-regexphash-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/branches/upstream/libtie-regexphash-perl/current/Makefile.PL?rev=10383&op=file
==============================================================================
--- branches/upstream/libtie-regexphash-perl/current/Makefile.PL (added)
+++ branches/upstream/libtie-regexphash-perl/current/Makefile.PL Sat Dec  1 12:21:26 2007
@@ -1,0 +1,15 @@
+# Note: this file was auto-generated by Module::Build::Compat version 0.03
+use ExtUtils::MakeMaker;
+WriteMakefile
+(
+          'NAME' => 'Tie::RegexpHash',
+          'VERSION_FROM' => 'lib/Tie/RegexpHash.pm',
+          'PREREQ_PM' => {
+                           'Carp' => '0',
+                           'Test::More' => '0'
+                         },
+          'INSTALLDIRS' => 'site',
+          'EXE_FILES' => [],
+          'PL_FILES' => {}
+        )
+;

Added: branches/upstream/libtie-regexphash-perl/current/README
URL: http://svn.debian.org/wsvn/branches/upstream/libtie-regexphash-perl/current/README?rev=10383&op=file
==============================================================================
--- branches/upstream/libtie-regexphash-perl/current/README (added)
+++ branches/upstream/libtie-regexphash-perl/current/README Sat Dec  1 12:21:26 2007
@@ -1,0 +1,106 @@
+NAME
+    Tie::RegexpHash - Use regular expressions as hash keys
+
+REQUIREMENTS
+    Tie::RegexpHash is written for and tested on Perl 5.6.0, but should run
+    with Perl 5.005. (Because it uses Regexp variables it cannot run on
+    earlier versions of Perl.)
+
+    It uses only standard modules. Serialization is supported through
+    Storable, but Storable is not required for normal operation.
+
+  Installation
+
+    Installation can be done using the traditional Makefile.PL or the newer
+    Build.PL methods.
+
+    Using Makefile.PL:
+
+      perl Makefile.PL
+      make test
+      make install
+
+    (On Windows platforms you should use `nmake' instead.)
+
+    Using Build.PL (if you have Module::Build installed):
+
+      perl Build.PL
+      perl Build test
+      perl Build install
+
+SYNOPSIS
+      use Tie::RegexpHash;
+
+      my %hash;
+
+      tie %hash, 'Tie::RegexpHash';
+
+      $hash{ qr/^5(\s+|-)?gal(\.|lons?)?/i } = '5-GAL';
+
+      $hash{'5 gal'};     # returns "5-GAL"
+      $hash{'5GAL'};      # returns "5-GAL"
+      $hash{'5  gallon'}; # also returns "5-GAL"
+
+      my $rehash = Tie::RegexpHash->new();
+
+      $rehash->add( qr/\d+(\.\d+)?/, "contains a number" );
+      $rehash->add( qr/s$/,          "ends with an \`s\'" );
+
+      $rehash->match( "foo 123" );  # returns "contains a number"
+      $rehash->match( "examples" ); # returns "ends with an `s'"
+
+DESCRIPTION
+    This module allows one to use regular expressions for hash keys, so that
+    values can be associated with anything that matches the key.
+
+    Hashes can be operated on using the standard tied hash interface in
+    Perl, or using an object-oriented interface described below.
+
+REVISION HISTORY
+    A brief list of changes since the previous release:
+
+    0.15    11 Feb 2006
+            - updated notes on Storable use in documentation
+            - support serialization with Storable, but do not require
+              Storable
+            - skip serialization tests if Storable is not available
+    
+    0.14_03 10 Feb 2006
+            - noted use of Storable in documentation
+            - fix for MANIFEST
+    
+    0.14_02 10 Feb 2006
+            - fix for freeze subroutine (from Russell Harrison)
+            - tests for serialization hooks (from Russell Harrison)
+    
+    0.14_01 9 Feb 2006
+            - updated test suite to use Test::More
+            - added serialization hooks with Storable
+              (patch from Russell Harrison)
+            - README built with Pod::Readme
+
+    For a detailed history see the Changes file included in this
+    distribution.
+
+AUTHOR
+    Robert Rothenberg <rrwo at cpan.org>
+
+LICENSE
+    Copyright (c) 2001-2002, 2005-2006 Robert Rothenberg. All rights
+    reserved.
+
+    Portions Copyright (c) 2006 Russell Harrison. All rights reserved.
+
+    This program is free software; you can redistribute it and/or modify it
+    under the same terms as Perl itself.
+
+SEE ALSO
+    Tie::Hash::Regex is a module with a complimentary function. Rather than
+    a hash with Regexps as keys that match against fetches, it has standard
+    keys that are matched by Regexps in fetches.
+
+    Regexp::Match::Any matches many Regexps against a variable.
+
+    Regexp::Match::List is similar, but supports callbacks and various
+    optimizations.
+

Added: branches/upstream/libtie-regexphash-perl/current/SIGNATURE
URL: http://svn.debian.org/wsvn/branches/upstream/libtie-regexphash-perl/current/SIGNATURE?rev=10383&op=file
==============================================================================
--- branches/upstream/libtie-regexphash-perl/current/SIGNATURE (added)
+++ branches/upstream/libtie-regexphash-perl/current/SIGNATURE Sat Dec  1 12:21:26 2007
@@ -1,0 +1,32 @@
+This file contains message digests of all files listed in MANIFEST,
+signed via the Module::Signature module, version 0.53.
+
+To verify the content in this distribution, first make sure you have
+Module::Signature installed, then type:
+
+    % cpansign -v
+
+It will check each file's integrity, as well as the signature's
+validity.  If "==> Signature verified OK! <==" is not displayed,
+the distribution may already have been compromised, and you should
+not run its Makefile.PL or Build.PL.
+
+-----BEGIN PGP SIGNED MESSAGE-----
+Hash: SHA1
+
+SHA1 4e6ce1013448517f691a64b9f4a39c10ed076cb9 Build.PL
+SHA1 43670cb3c2dcd20fdcd93cd5327f960219f370c1 Changes
+SHA1 c9f5eddaac570c55a9845749e4037dd640db518a MANIFEST
+SHA1 1d7af13a2c3251e4f7524e4057f90f1b39726cbd META.yml
+SHA1 e5a3b12a03c095b66cc229bbf4974d88115f1ac9 Makefile.PL
+SHA1 5f66d6a8bf0aa5410e8db4bd9de8e38de4126745 README
+SHA1 49675d42468bdbdd8deb9dac913db3104d186b27 lib/Tie/RegexpHash.pm
+SHA1 98bc693f8980ea388c212d7f15ea8613f70dc991 t/01-RegexpHash.t
+SHA1 7b36e8c9329a8b23458faf7d0dc80b12e0292326 t/02-RegexpHash.t
+-----BEGIN PGP SIGNATURE-----
+Version: GnuPG v1.2.5 (GNU/Linux)
+
+iD8DBQFD7ajpslRBHTHmtSsRAu7kAJ9WAJK6ijGFq8rNeASlFKZcss+S/wCgq2GG
+hQrzCNityOcb/3/tWOyMFoM=
+=T2Q3
+-----END PGP SIGNATURE-----

Added: branches/upstream/libtie-regexphash-perl/current/lib/Tie/RegexpHash.pm
URL: http://svn.debian.org/wsvn/branches/upstream/libtie-regexphash-perl/current/lib/Tie/RegexpHash.pm?rev=10383&op=file
==============================================================================
--- branches/upstream/libtie-regexphash-perl/current/lib/Tie/RegexpHash.pm (added)
+++ branches/upstream/libtie-regexphash-perl/current/lib/Tie/RegexpHash.pm Sat Dec  1 12:21:26 2007
@@ -1,0 +1,488 @@
+package Tie::RegexpHash;
+
+require 5.005;
+use strict;
+
+use vars qw( $VERSION @ISA );
+
+ at ISA = qw( );
+
+# our %EXPORT_TAGS = ( 'all' => [ qw( ) ] );
+# our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
+# our @EXPORT = qw();
+
+$VERSION = '0.15';
+
+use Carp;
+
+sub new
+
+# Creates a new 'Tie::RegexpHash' object. We use an underlying array rather
+# than a hash because we want to search through the hash keys in the order
+# that they were added.
+#
+# See the _find() and add() routines for more details.
+
+  {
+    my ($class) = @_;
+
+    my $self = {
+      KEYS   => [ ], # array of Regexp keys
+      VALUES => [ ], # array of corresponding values
+      COUNT  => 0,   # the number of hash/key pairs (is this necessary?)
+    };
+
+    bless $self, $class;
+  }
+
+sub _convert_key
+
+# Embed any modifiers used with qr// in the pattern.
+
+  {
+    my ($key) = shift;
+
+    my ($flags,$pat) = ($key =~ /^\(\?([ismx]{0,4})-[ismx]*:(.*)\)$/);
+    ($key = qr/(?$flags:$pat)/) if $flags;
+    return $key;
+  }
+    
+sub _find
+
+# Sequentially goes through the hash keys for Regexps which match the given
+# key and returns the index. If the hash is empty, or a matching key was not
+# found, returns undef.
+
+  {
+    my ($self, $key) = @_;
+
+    unless ($self->{COUNT})
+      {
+	return;
+      }
+
+    if (ref($key) eq 'Regexp')
+      {
+	my $i = 0;
+        $key = _convert_key($key); 
+	while  (($i < $self->{COUNT}) and ($key ne $self->{KEYS}->[ $i ])) {
+	    $i++;
+	  }
+
+	if ($i == $self->{COUNT})
+	  {
+	    return;
+	  }
+	else
+	  {
+	    return $i;
+	  }
+
+      }
+    else
+      {
+	my $i = 0;
+	while  (($i < $self->{COUNT}) and ($key !~ m/$self->{KEYS}->[ $i ]/)) {
+	  $i++;
+	}
+
+	if ($i == $self->{COUNT})
+	  {
+	    return;
+	  }
+	else
+	  {
+	    return $i;
+	  }
+      }
+  }
+
+sub add
+
+# If a key exists the value will be replaced. (If the Regexps are not the same
+# but match, a warning is displayed.) If the key is new, then a new key/value
+# pair is added.
+
+  {
+    my ($self, $key, $value) = @_;
+
+    ($key = _convert_key($key)) if (ref($key) eq 'Regexp');
+
+    my $index = _find $self, $key;
+    if (defined($index))
+      {
+	if ($key ne $self->{KEYS}->[ $index ])
+	  {
+		carp "\'$key\' is not the same as \'",
+		  $self->{KEYS}->[$index], "\'";
+	  }
+	$self->{VALUES}->[ $index ] = $value;
+      }
+    else
+      {
+	$index = $self->{COUNT}++;
+
+        ($key = qr/$key/) unless (ref($key) eq 'Regexp');
+
+	$self->{KEYS}->[ $index ]   = $key;
+	$self->{VALUES}->[ $index ] = $value;
+      }
+
+  }
+
+
+sub match_exists
+
+# Does a key exist or does it match any Regexp keys?
+
+  {
+    my ($self, $key) = @_;
+    return defined( _find $self, $key );
+  }
+
+sub match
+
+# Returns the value of a key or any matches to Regexp keys.
+
+  {
+    my ($self, $key) = @_;
+
+    my $index = _find $self, $key;
+
+    if (defined($index))
+      {
+	return $self->{VALUES}->[ $index ];
+      }
+    else
+      {
+	return;
+      }
+  }
+
+sub remove
+
+# Removes a key or Regexp key and associated value from the hash. If the key
+# is not the same as the Regexp, a warning is displayed.
+
+  {
+    my ($self, $key) = @_;
+
+    ($key = _convert_key($key)) if (ref($key) eq 'Regexp');
+
+    my $index = _find $self, $key;
+
+    if (defined($index))
+      {
+
+	if ($key ne $self->{KEYS}->[ $index ])
+	  {
+		carp "'`$key\' is not the same as '`",
+		  $self->{KEYS}->[$index], "\'";
+	  }
+
+	my $value = $self->{VALUES}->[ $index ];
+	splice @{ $self->{KEYS} },   $index, 1;
+	splice @{ $self->{VALUES} }, $index, 1;
+	$self->{COUNT}--;
+	return $value;
+      }
+    else
+      {
+	   	carp "Cannot delete a nonexistent key: \`$key\'";
+	return;
+      }
+
+  }
+
+sub clear
+
+# Clears the hash.
+
+  {
+    my ($self) = @_;
+
+    $self->{KEYS}   = [ ];
+    $self->{VALUES} = [ ];
+    $self->{COUNT}  = 0;
+
+  }
+
+BEGIN
+  {
+    # make aliases...
+    no strict;
+    *TIEHASH = \ &new;
+    *STORE   = \ &add;
+    *EXISTS  = \ &match_exists;
+    *FETCH   = \ &match;
+    *DELETE  = \ &remove;
+    *CLEAR   = \ &clear;
+  }
+
+sub FIRSTKEY
+
+# Returns the first key
+
+  {
+    my ($self) = @_;
+
+    unless ($self->{COUNT})
+      {
+	return;
+      }
+
+    return $self->{KEYS}->[0];
+
+  }
+
+sub NEXTKEY
+
+# Returns the next key
+
+  {
+    my ($self, $lastkey) = @_;
+
+    unless ($self->{COUNT})
+      {
+	return;
+      }
+
+    my $index = _find $self, $lastkey;
+
+    unless (defined($index))
+      {
+	confess "Invalid \$lastkey";
+      }
+
+    $index++;
+
+    if ($index == $self->{COUNT})
+      {
+	return;
+      }
+    else
+      {
+	return $self->{KEYS}->[ $index ];
+      }
+
+  }
+
+sub STORABLE_freeze
+
+# serialize object
+
+  {
+    my ($self, $cloning) = @_;
+
+    my @keystrings;
+    {
+      local *_;
+      @keystrings = map { join(':',
+          ($_ =~ /^\(\?([ismx]{0,4})-[ismx]*:(.*)\)$/)); } @{$self->{KEYS}};
+    }
+
+    my $sref = {
+      KEYSTRINGS => \@keystrings,
+      VALUES     => $self->{VALUES},
+      COUNT      => $self->{COUNT},
+    };
+
+    return (0,$sref);
+  }
+
+sub STORABLE_thaw
+
+# deserialize
+
+  {
+    my($self, $cloning, $serialized, $sref) = @_;
+
+    $self->{KEYS}   = [ ];
+    $self->{VALUES} = $sref->{VALUES};
+    $self->{COUNT}  = $sref->{COUNT};
+
+    {
+      local *_;
+      @{$self->{KEYS}} = map {
+           my ($flags,$pat) = ($_ =~ /^([ismx]{0,4}):(.*)$/);
+           $pat = ($flags) ? "(?$flags:$pat)" : $pat;
+           qr/$pat/;
+      } @{$sref->{KEYSTRINGS}};
+    }
+  }
+
+1;
+__END__
+
+=head1 NAME
+
+Tie::RegexpHash - Use regular expressions as hash keys
+
+=begin readme
+
+=head1 REQUIREMENTS
+
+L<Tie::RegexpHash> is written for and tested on Perl 5.6.0, but should
+run with Perl 5.005. (Because it uses Regexp variables it cannot run on
+earlier versions of Perl.)
+
+It uses only standard modules.  Serialization is supported through
+Storable, but Storable is not required for normal operation.
+
+=head2 Installation
+
+Installation can be done using the traditional Makefile.PL or the newer
+Build.PL methods.
+
+Using Makefile.PL:
+
+  perl Makefile.PL
+  make test
+  make install
+
+(On Windows platforms you should use C<nmake> instead.)
+
+Using Build.PL (if you have Module::Build installed):
+
+  perl Build.PL
+  perl Build test
+  perl Build install
+
+=end readme
+
+=head1 SYNOPSIS
+
+  use Tie::RegexpHash;
+
+  my %hash;
+
+  tie %hash, 'Tie::RegexpHash';
+
+  $hash{ qr/^5(\s+|-)?gal(\.|lons?)?/i } = '5-GAL';
+
+  $hash{'5 gal'};     # returns "5-GAL"
+  $hash{'5GAL'};      # returns "5-GAL"
+  $hash{'5  gallon'}; # also returns "5-GAL"
+
+  my $rehash = Tie::RegexpHash->new();
+
+  $rehash->add( qr/\d+(\.\d+)?/, "contains a number" );
+  $rehash->add( qr/s$/,          "ends with an \`s\'" );
+
+  $rehash->match( "foo 123" );  # returns "contains a number"
+  $rehash->match( "examples" ); # returns "ends with an `s'"
+
+=head1 DESCRIPTION
+
+This module allows one to use regular expressions for hash keys, so that
+values can be associated with anything that matches the key.
+
+Hashes can be operated on using the standard tied hash interface in Perl,
+or using an object-oriented interface described below.
+
+=for readme stop
+
+=head2 Methods
+
+=over
+
+=item new
+
+  my $obj = Tie::RegexpHash->new()
+
+Creates a new "RegexpHash" (Regular Expression Hash) object.
+
+=item add
+
+  $obj->add( $key, $value );
+
+Adds a new key/value pair to the hash. I<$key> can be a Regexp or a string
+(which is compiled into a Regexp).
+
+If I<$key> is already defined, the value will be changed. If C<$key> matches
+an existing key (but is not the same), a warning will be shown if warnings
+are enabled.
+
+=item match
+
+  $value = $obj->match( $quasikey );
+
+Returns the value associated with I<$quasikey>. (I<$quasikey> can be a string
+which matches an existing Regexp or an actual Regexp.)  Returns 'undef' if
+there is no match.
+
+Regexps are matched in the order they are defined.
+
+=item match_exists
+
+  if ($obj->match_exists( $quasikey )) ...
+
+Returns a true value if there exists a matching key.
+
+=item remove
+
+  $value = $obj->remove( $quasikey );
+
+Deletes the key associated with I<$quasikey>.  If I<$quasikey> matches
+an existing key (but is not the same), a warning will be shown.
+
+Returns the value associated with the key.
+
+=item clear
+
+  $obj->clear();
+
+Removes all key/value pairs.
+
+=back
+
+=for readme continue
+
+=begin readme
+
+=head1 REVISION HISTORY
+
+A brief list of changes since the previous release:
+
+=for readme include file="Changes" start="0.15" stop="0.13" type="text"
+
+For a detailed history see the F<Changes> file included in this distribution.
+
+=end readme
+
+=head1 AUTHOR
+
+Robert Rothenberg <rrwo at cpan.org>
+
+=for readme stop
+
+=head2 Acknowledgments
+
+Russell Harrison <rch at cpan.org> for patches adding support
+for serialization.
+
+Simon Hanmer <sch at scubaplus.co.uk> & Bart Vetters <robartes at nirya.eb>
+for pointing out a bug in the logic of the _find() routine in v0.10
+
+=for readme continue
+
+=head1 LICENSE
+
+Copyright (c) 2001-2002, 2005-2006 Robert Rothenberg. All rights reserved.
+
+Portions Copyright (c) 2006 Russell Harrison. All rights reserved.
+
+This program is free software; you can redistribute it and/or
+modify it under the same terms as Perl itself.
+
+=head1 SEE ALSO
+
+L<Tie::Hash::Regex> is a module with a complimentary function. Rather than
+a hash with Regexps as keys that match against fetches, it has standard keys that are matched by Regexps in fetches.
+
+L<Regexp::Match::Any> matches many Regexps against a variable.
+
+L<Regexp::Match::List> is similar, but supports callbacks and various
+optimizations.
+
+=cut

Added: branches/upstream/libtie-regexphash-perl/current/t/01-RegexpHash.t
URL: http://svn.debian.org/wsvn/branches/upstream/libtie-regexphash-perl/current/t/01-RegexpHash.t?rev=10383&op=file
==============================================================================
--- branches/upstream/libtie-regexphash-perl/current/t/01-RegexpHash.t (added)
+++ branches/upstream/libtie-regexphash-perl/current/t/01-RegexpHash.t Sat Dec  1 12:21:26 2007
@@ -1,0 +1,21 @@
+#!/usr/bin/perl
+
+use Test::More tests => 6;
+
+use_ok("Tie::RegexpHash", 0.14);
+
+# Rudimentary test suite of the examples given in the
+# synopsis. Someday it will be oncorporated with POD::Tests.  Someday
+# I'll write a real test suite. Someday....
+
+my %hash;
+
+tie %hash, 'Tie::RegexpHash';
+ok(1);
+
+$hash{ qr/^5(\s+|-)?gal(\.|lons?)?/i } = '5-GAL';
+ok(1);
+
+ok($hash{'5 gal'} eq "5-GAL");
+ok($hash{'5GAL'}  eq "5-GAL");
+ok($hash{'5  gallon'} eq "5-GAL");

Added: branches/upstream/libtie-regexphash-perl/current/t/02-RegexpHash.t
URL: http://svn.debian.org/wsvn/branches/upstream/libtie-regexphash-perl/current/t/02-RegexpHash.t?rev=10383&op=file
==============================================================================
--- branches/upstream/libtie-regexphash-perl/current/t/02-RegexpHash.t (added)
+++ branches/upstream/libtie-regexphash-perl/current/t/02-RegexpHash.t Sat Dec  1 12:21:26 2007
@@ -1,0 +1,45 @@
+#!/usr/bin/perl
+
+use Test::More tests => 13;
+use Data::Dumper;
+
+use_ok("Tie::RegexpHash", 0.14); 
+# Rudimentary test suite of the examples given in the
+# synopsis. Someday it will be oncorporated with POD::Tests.  Someday
+# I'll write a real test suite. Someday....
+
+SKIP: {
+    eval { require Storable };
+
+    skip "Storable not installed", 13 if $@;
+
+    my (%hash);
+
+    tie %hash, 'Tie::RegexpHash';
+    ok(1);
+
+    $hash{ qr/^5(\s+|-)?gal(\.|lons?)?/i } = '5-GAL';
+    ok(1);
+
+    my $serialized = Storable::freeze(\%hash);
+    ok(1, 'freeze');
+
+    %hash = %{ Storable::thaw($serialized) };
+    ok(1, 'thaw');
+
+    ok($hash{'5 gal'} eq "5-GAL");
+    ok($hash{'5GAL'}  eq "5-GAL");
+    ok($hash{'5  gallon'} eq "5-GAL");
+
+    # In case clone semantics change in a future revision... 
+    $href = Storable::dclone( \%hash );
+    ok(1, 'dclone');
+
+    ok($href->{'5 gal'} eq "5-GAL");
+    ok($href->{'5GAL'} eq "5-GAL");
+    ok($href->{'5 gallon'} eq "5-GAL");
+
+    $hash{ qr/^pattern$/i } = 'val1';
+    $hash{ qr/(?i:^pattern$)/ } = 'val2';
+    ok($hash{pAttErn} eq 'val2');
+}




More information about the Pkg-perl-cvs-commits mailing list