package PerlIO::via::Rotate; # Make sure we don't have any strange encoding issues # Make sure we do things by the book from now on # Set the version info $VERSION = '0.06'; use strict; use bytes; # Initialize the base rotational strings my @rotate = ('',qw( b-za c-zab d-za-c e-za-d f-za-e g-za-f h-za-g i-za-h j-za-i k-za-j l-za-k m-za-l n-za-m o-za-n p-za-o q-za-p r-za-q s-za-r t-za-s u-za-t v-za-u w-za-v x-za-w yza-x za-y ),''); # Satisfy -require- 1; #----------------------------------------------------------------------- # IN: 1 class to bless with # 2..N parameters passed in -use- sub import { # Obtain the class we're working for # Initialize to do all if so specified # Set to do only rot13 if none specified my $class = shift; @_ = 0..26 if @_ == 1 and $_[0] eq ':all'; @_ = 13 unless @_; # For all of the rotations specified # Die now if it is an invalid rotation # Create the name of the version variable # Reloop now if already defined foreach (@_) { die "Invalid rotational value: $_" if !m#^\d+$# or $_ < 0 or $_ > 26; my $version = "PerlIO::via::rot$_\::VERSION"; no strict 'refs'; next if defined( $$version ); use strict 'refs'; # Initialize the source of the module for this rotation my $module = <:via(rot14)','file.rotated' ) or die "Can't open file.rotated for writing: $!\n"; =head1 DESCRIPTION This module implements a PerlIO layer that works on files encoded using rotational deviation. This is a simple manner of encoding in which pure alphabetical letters (a-z and A-Z) are moved up a number of places in the alphabet. The default rotation is "13". Commonly this type of encoding is referred to as "rot13" encoding. However, any rotation between 0 and 26 inclusive are allowed (albeit that rotation 0 and 26 don't change anything). You can specify the rotations you would like to use as a list in the -use- statement. The special keyword ":all" can be specified in the -use- statement to indicate that all rotations between 0 and 26 inclusive should be allowed. =head1 REQUIRED MODULES (none) =head1 CAVEATS This module is special insofar it serves as a front-end for 27 modules that are named "PerlIO::via::rot0" through "PerlIO::via::rot26" that are eval'd as appropriate when the module is -use-d. The reason for this approach is that it is currently impossible to pass parameters to a PerlIO layer when opening a file. The name of the module is the implicit parameter being passed to the PerlIO::via::Rotate module. =head1 SEE ALSO L, L, L, L, L. =head1 ACKNOWLEDGEMENTS Inspired by Crypt::Rot13.pm by Julian Fondren. =head1 COPYRIGHT Copyright (c) 2002-2003 Elizabeth Mattijsen. All rights reserved. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut