package Encode::ROT13; use strict; use warnings; use parent qw( Encode::Encoding ); __PACKAGE__->Define( 'rot13' ); sub encode($$;$){ my( $obj, $str, $chk ) = @_; $str =~ tr/A-Za-z/N-ZA-Mn-za-m/; $_[1] = '' if $chk; # $_[1] is aliased through the call. Inplace edit. return $str; } no warnings 'once'; *Encode::ROT13::decode = \&encode; # Because rot13( rot13() ) is a round-trip. 1; package main; use strict; use warnings; use Encode 'define_encoding'; use File::Slurp; # define_encoding( $object, 'rot13' ); # Um....? my @words = read_file( \*DATA, chomp => 1, binmode => ':rot13' ); print "$_\n" for @words; __DATA__ Apple cat dog strawberry watermelon