René Nyffenegger's collection of things on the web | |
René Nyffenegger on Oracle - Most wanted - Feedback
- Follow @renenyffenegger
|
Transforming each character in a string with perl | ||
If each character in a string needs to be transformed, a possible way to do
that is using split and map:
my $str = 'Usbotgpsn!uijt!tusjoh"'; print map {chr ord ($_) - 1} split //, $str;
This code snippet takes a string and replaces each character with the one
whose ascii value is one less, resulting in
Transform this string!.
|