Home arrow Perl Programming arrow Page 5 - String Processing with Perl

Not My Type - Perl

Perl has always been known for its text processing and manipulation abilities. This article examines the Perl string handling API in greater detail, explaining how you can use Perl's string functions to (among other things) print and format strings, split and join string values, alter string case, and perform regular expression searches.

  1. String Processing with Perl
  2. Jumping Jacks
  3. Choppy Waters
  4. Making New Friends
  5. Not My Type
  6. Of Jumping Cows And Purple Pumpkins
  7. On The Case
  8. Desperately Seeking Susan
By: Harish Kamath, (c) Melonfire
Rating: starstarstarstarstar / 76
April 16, 2003

print this article


The chr() and ord() functions come in handy when converting from ASCII codes to characters and vice-versa. For example,

#!/usr/bin/perl # returns "A" print chr(65); # returns 97 print ord("a");
If you prefer numbers to letters, you can use the hex() and oct() functions to convert between decimals, hexadecimals and octals.

#!/usr/local/bin/perl #returns 170 print hex(AA); # returns 40 print oct(50);
And if you ever find the need to reverse a string, well, you can always reach for the reverse() function...

#!/usr/bin/perl $str = "Wassup, dood?"; # reverse string # $rts now contains ?dood ,pussaW $rts = reverse($str); # returns "Sorry, you seem to be talking backwards - what does
# ?dood ,pussaW mean?"
print "Sorry, you seem to be talking backwards - what does $rts mean?";

>>> More Perl Programming Articles          >>> More By Harish Kamath, (c) Melonfire

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort


- Perl Turns 25
- Lists and Arguments in Perl
- Variables and Arguments in Perl
- Understanding Scope and Packages in Perl
- Arguments and Return Values in Perl
- Invoking Perl Subroutines and Functions
- Subroutines and Functions in Perl
- Perl Basics: Writing and Debugging Programs
- Structure and Statements in Perl
- First Steps in Perl
- Completing Regular Expression Basics
- Modifiers, Boundaries, and Regular Expressio...
- Quantifiers and Other Regular Expression Bas...
- Parsing and Regular Expression Basics
- Hash Functions

Developer Shed Affiliates


Dev Shed Tutorial Topics: