Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

RE: RE: Re: encryption

by blogan (Monk)
on Nov 07, 2000 at 05:26 UTC ( #40301=note: print w/replies, xml ) Need Help??

in reply to RE: Re: encryption
in thread encryption

Minor change, but now you don't have to define what happens for characters that shouldn't be "decrypted".
#!/usr/bin/perl -w use strict; $_ = "Ohg vg'f ernyyl n irel fvzcyr gnfx..."; my %caesar; @caesar{'A'..'Z','a'..'z'} = ('N'..'Z','A'..'M', 'n'..'z', 'a'..'m'); my $decoded; $decoded .= $caesar{$_} ? $caesar{$_} : $_ for split //; print $decoded, "\n";

Replies are listed 'Best First'.
RE: RE: RE: Re: encryption
by Adam (Vicar) on Nov 07, 2000 at 06:14 UTC
    #!/usr/bin/perl -w use strict; my $line = "Lbh pbhyq rira hfr n gvrq inevnoyr... 3-)"; my %caesar; @caesar{'A'..'Z','a'..'z',0..9} = ('N'..'Z','A'..'M', 'n'..'z', 'a'..'m', 5..9,0..4 ); sub TIESCALAR{bless[pop]} sub FETCH{exists $caesar{$_}?$caesar{$_}:$_} tie my $chars, '', ''; print $chars for split //, $line;
    Although I like the use of transpose more.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://40301]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (3)
As of 2018-03-24 22:34 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (299 votes). Check out past polls.