Front page | perl.perl5.changes |
Postings from March 2012
[perl.git] branch dual/Search-Dict, updated. v5.15.9-59-g50853f7
From:
David Golden
Date:
March 31, 2012 10:36
Subject:
[perl.git] branch dual/Search-Dict, updated. v5.15.9-59-g50853f7
Message ID:
E1SE2EE-0007pV-GX@camel.ams6.corp.booking.com
In perl.git, the branch dual/Search-Dict has been updated
<http://perl5.git.perl.org/perl.git/commitdiff/50853f72ddfe1b1fd1796a17ed411a90c5878354?hp=acb40bf4d41855095824f7e8816c39c76fc6f55c>
- Log -----------------------------------------------------------------
commit 50853f72ddfe1b1fd1796a17ed411a90c5878354
Author: David Golden <dagolden@cpan.org>
Date: Sat Mar 31 19:21:46 2012 +0200
Search::Dict: suppress tied filehandle stat() warnings
-----------------------------------------------------------------------
Summary of changes:
dist/Search-Dict/Changes | 4 ++++
dist/Search-Dict/Makefile.PL | 1 +
dist/Search-Dict/lib/Search/Dict.pm | 4 ++--
dist/Search-Dict/t/Dict.t | 21 ++++++++++++++++++++-
4 files changed, 27 insertions(+), 3 deletions(-)
diff --git a/dist/Search-Dict/Changes b/dist/Search-Dict/Changes
index 09ca617..612baf5 100644
--- a/dist/Search-Dict/Changes
+++ b/dist/Search-Dict/Changes
@@ -1,3 +1,7 @@
+1.06 2012-03-31
+
+ - suppress stat() warnings on tied filehandles
+
1.05 2012-03-31
- no longer requires stat() on filehandle
diff --git a/dist/Search-Dict/Makefile.PL b/dist/Search-Dict/Makefile.PL
index 26f2c84..e55eba7 100644
--- a/dist/Search-Dict/Makefile.PL
+++ b/dist/Search-Dict/Makefile.PL
@@ -13,6 +13,7 @@ my %WriteMakefileArgs = (
"PREREQ_PM" => {
"Exporter" => 0,
"Test::More" => 0.47,
+ "Tie::StdHandle" => 0,
},
INSTALLDIRS => 'perl',
);
diff --git a/dist/Search-Dict/lib/Search/Dict.pm b/dist/Search-Dict/lib/Search/Dict.pm
index 3032054..4c518b7 100644
--- a/dist/Search-Dict/lib/Search/Dict.pm
+++ b/dist/Search-Dict/lib/Search/Dict.pm
@@ -11,7 +11,7 @@ BEGIN {
use strict;
-our $VERSION = '1.05';
+our $VERSION = '1.06';
our @ISA = qw(Exporter);
our @EXPORT = qw(look);
@@ -69,7 +69,7 @@ sub look {
local($_);
my $fno = fileno $fh;
my @stat;
- if ( defined $fno && $fno >= 0 ) { # real, open file
+ if ( defined $fno && $fno >= 0 && ! tied *{$fh} ) { # real, open file
@stat = eval { stat($fh) }; # in case fileno lies
}
my($size, $blksize) = @stat[7,11];
diff --git a/dist/Search-Dict/t/Dict.t b/dist/Search-Dict/t/Dict.t
index f147623..d3d7cdb 100644
--- a/dist/Search-Dict/t/Dict.t
+++ b/dist/Search-Dict/t/Dict.t
@@ -2,7 +2,7 @@
use strict;
use Test::More;
-plan tests => 11;
+plan tests => 14;
my $DICT = <<EOT;
Aarhus
@@ -35,6 +35,7 @@ abating
Abba
EOT
+use Tie::StdHandle;
use Search::Dict;
open(DICT, "+>dict-$$") or die "Can't create dict-$$: $!";
@@ -80,6 +81,24 @@ cmp_ok $pos, ">=", 0;
is $word, "Aarhus";
close DICT or die "cannot close";
+
+{
+ local $^W = 1; # turn on global warnings for stat() in Search::Dict
+
+ my $warn = '';
+ local $SIG{__WARN__} = sub { $warn = join("\n",@_) };
+
+ tie *DICT, 'Tie::StdHandle', "<", "dict-$$";
+
+ $pos = look *DICT, "aarhus", 1, 1;
+ is( $warn, '', "no warning seen" );
+
+ chomp($word = <DICT>);
+
+ cmp_ok $pos, ">=", 0;
+ is $word, "Aarhus";
+
+}
unlink "dict-$$";
{
--
Perl5 Master Repository
-
[perl.git] branch dual/Search-Dict, updated. v5.15.9-59-g50853f7
by David Golden