Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^2: Digest::MD5 addfile() w/ tied filehandle

by Anonymous Monk
on Sep 02, 2015 at 02:36 UTC ( [id://1140741]=note: print w/replies, xml ) Need Help??


in reply to Re: Digest::MD5 addfile() w/ tied filehandle
in thread Digest::MD5 addfile() w/ tied filehandle

Seems like a bug to me :) http://grep.cpan.me/?q=No+filehandle+passed -> https://metacpan.org/source/RJBS/perl-5.22.0/cpan/Digest-MD5/MD5.xs.... -> Perl_sv_2io(pTHX_ SV *const sv)

#!/usr/bin/perl -- package TieTest; sub TIEHANDLE { return bless {}, shift } sub OPEN { open my $fh, $_[1], $_[2]; $_[0]->{fh} = $fh; } sub READ { warn "...tied read\n"; read $_[0]->{fh}, $_[1], $_[2], + $_[3]; } sub SEEK { seek $_[0]->{fh}, $_[1], $_[2]; } package main; use strict; use warnings; use Digest::MD5; use Digest::Perl::MD5; my $filename = $ARGV[0] || __FILE__; open FH_PLAIN, '<', $filename or die $!; #open FH_TIED, '<', $ARGV[1]; # try uncommenting this tie(*FH_TIED, 'TieTest'); open FH_TIED, '<', $filename or die $!; open FH_EEP, '<', $filename or die $!; tie(*FH_EEP, 'TieTest'); open FH_EEP, '<', $filename or die $!; my %handles = ( PLAIN => \*FH_PLAIN, TIED => \*FH_TIED, EEP => \*FH_EEP, PEE => eval { my $pee; tie $pee, 'TieTest'; open $pee, '<', $filename or die $!; $pee; }, ); for my $title ( keys %handles ){ my $fh = $handles{$title}; for my $class (qw/Digest::Perl::MD5 Digest::MD5/) { my $sum = eval { $class->new->addfile($fh)->hexdigest } || $@; printf "%-7s%-19s%-32s\n", $title, $class, $sum; seek $fh, 0, 0; } } #~ use Devel::Peek qw/ Dump /; Dump( $_) for values %handles ; ## unin +formative __END__ $ perl perliotiehandle.pl Odd number of elements in hash assignment at perliotiehandle.pl line 4 +4. ...tied read ...tied read EEP Digest::Perl::MD5 623cf1cdac049dc6527cb0f28fc5aa76 EEP Digest::MD5 623cf1cdac049dc6527cb0f28fc5aa76 PLAIN Digest::Perl::MD5 623cf1cdac049dc6527cb0f28fc5aa76 PLAIN Digest::MD5 623cf1cdac049dc6527cb0f28fc5aa76 ...tied read ...tied read TIED Digest::Perl::MD5 623cf1cdac049dc6527cb0f28fc5aa76 TIED Digest::MD5 No filehandle passed at perliotiehandle.pl l +ine 56. PEE Digest::Perl::MD5 Digest::Perl::MD5 read failed: Bad file desc +riptor at C:/citrusperl/site/lib/Digest/Perl/MD5.pm line 164. Can't use an undefined value as a symbol reference at perliotiehandle. +pl line 58.

Replies are listed 'Best First'.
Re^3: Digest::MD5 addfile() w/ tied filehandle
by Anonymous Monk on Sep 02, 2015 at 02:37 UTC

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1140741]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (4)
As of 2024-03-28 23:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found