Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2018-07-19 21:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?















    Results (420 votes). Check out past polls.

    Notices?