package String::Parity; use strict; use vars qw( $VERSION $Version $Revision @ISA @EXPORT @EXPORT_OK $even_parity $odd_parity $show_parity ); require Exporter; @ISA = qw(Exporter); $Version = $VERSION = "1.31"; ($Revision = substr(q$Revision: 1.7 $, 10)) =~ s/\s+$//; @EXPORT = qw( setEvenParity setOddParity setMarkParity setSpaceParity EvenBytes OddBytes MarkBytes SpaceBytes isEvenParity isOddParity isMarkParity isSpaceParity ); @EXPORT_OK = qw( showParity showMarkSpace $even_parity $odd_parity $show_parity $even_codes ); my $even_bits = "\0"; my $odd_bits = "\200"; foreach (0 .. 7) { $even_bits .= $odd_bits; ($odd_bits = $even_bits) =~ tr/\0\200/\200\0/; } my $codes = pack('C*', (0 .. 255)); ($even_parity = $codes ^ $even_bits) =~ s/(\W)/sprintf('\%o', ord $1)/eg; ($odd_parity = $codes ^ $odd_bits) =~ s/(\W)/sprintf('\%o', ord $1)/eg; ($show_parity = $even_bits) =~ tr /\0\200/eo/; my $even_codes = ''; while ($even_bits =~ /\0/g) { $even_codes .= sprintf '\%o', (pos $even_bits) - 1; } eval < =head1 SEE ALSO perl(1), Exporter(1) =cut