From b109933fb09771789b9faded5f1f6c108226ae8f Mon Sep 17 00:00:00 2001 From: NAGAYA Shinichiro Date: Sun, 1 Mar 2009 13:25:00 +0900 Subject: [PATCH] =?UTF-8?q?Perl=205.9=20=E3=81=A7=E5=8B=95=E3=81=8F?= =?UTF-8?q?=E3=82=88=E3=81=86=E3=81=ABphash=20=E3=81=8B=E3=82=89hash=20?= =?UTF-8?q?=E3=81=B8=E3=81=AE=E5=A4=89=E6=8F=9B=E5=87=A6=E7=90=86=E3=82=92?= =?UTF-8?q?=E8=BF=BD=E5=8A=A0=E3=81=97=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PDFJ.pm | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/PDFJ.pm b/PDFJ.pm index fdf2709..50533ef 100644 --- a/PDFJ.pm +++ b/PDFJ.pm @@ -21,6 +21,24 @@ BEGIN { bytes->import unless $@; } +# use hash in place of phash for Perl 5.9 or later +BEGIN { + my $body; + unless ($] > 5.009) { + $body = sub { [ @_ ] }; + } else { + $body = sub { + my($pos) = @_; + my $hash; + foreach my $k (keys(%$pos)) { + $hash->{$k} = $_[$pos->{$k}]; + } + return $hash; + }; + } + eval { sub _hash { $body->(@_) } }; +} + @EXFUNC = qw( PDFJ::Doc::Doc PDFJ::TextStyle::TStyle PDFJ::Text::Text @@ -3201,8 +3219,8 @@ sub _fold { $preskip = $lineskip; } push @lines, - [\%TextLineIndex, $start, $count, $shift, $fixedglues, $preaols, - $postaols, $preskip]; + PDFJ::_hash(\%TextLineIndex, $start, $count, $shift, $fixedglues, + $preaols, $postaols, $preskip); $start = $nextpos; } @lines; @@ -4322,8 +4340,7 @@ my %ChunkIndex = ( sub new { my($class, @args) = @_; - unshift @args, \%ChunkIndex; - bless \@args, $class; + bless PDFJ::_hash(\%ChunkIndex, @args), $class; } sub clone {