Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

RE: RE: Re: encryption

by blogan (Monk)
on Nov 07, 2000 at 05:26 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://40301]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2024-04-24 09:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found