#!/usr/bin/perl -w package IO::Socket::INET::Interceptor; use base qw(IO::Socket::INET); sub write { my ($self, $buf, $len, $offset) = @_; $buf =~ s/cats/dogs/g; $self->SUPER::write($buf, $len, $offset); } package main; my $sock = IO::Socket::INET::Interceptor->new("localhost:80") or die $!; $sock->write("GET /cats/cats/cats.html HTTP/1.0\r\n\r\n"); print <$sock>;