#!/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; open FH_PLAIN, '<', $ARGV[0]; #open FH_TIED, '<', $ARGV[1]; # try uncommenting this tie(*FH_TIED, 'TieTest'); open FH_TIED, '<', $ARGV[0]; my %handles = (PLAIN => \*FH_PLAIN, TIED => \*FH_TIED); for my $title (qw/PLAIN TIED/) { my $fh = $handles{$title}; for my $class (qw/Digest::Perl::MD5 Digest::MD5/) { my $sum = $class->new->addfile($fh)->hexdigest; printf "%-7s%-19s%-32s\n", $title, $class, $sum; seek $fh, 0, 0; } }