in reply to Pearls (not really) of Perl programming
A lovely ROT-13 encoder:
# $str contains the characters to encode my @chars = split //, $str; for (@chars) { if( $_ eq 'a' ) { $_ = 'n' } if( $_ eq 'b' ) { $_ = 'o' } if( $_ eq 'c' ) { $_ = 'p' } # And so on. I think you all see where this is going }
Hey, how about this one-liner: $str =~ tr/A-Za-z/N-ZA-Mn-za-m/;.
"There is no shame in being self-taught, only in not trying to learn in the first place." -- Atrus, Myst: The Book of D'ni.
|
|---|