![]() |
Letter to Letter Translations![]() ![]() ![]() ![]() ![]()
The s/// operator is great for simple one-to one changes. Sometimes, you mall want to do a many-to-many change, such as translating uppercase letters lowercase letters. For this, you can use the tr /// operator, The tr/// operator lets you specify individual letters, or range of letters with a hyphen (-). For example, you can use the following to change the case of the uppercase letters in $Test: $Test =~ tr/A-Z/a-z/; The tr /// operator returns the number of changes that it makes. It also has some modifiers that are quite different than those for m// and ///.
The tr /// operator does not use regular expressions, only actual characters and character ranges.
The modifier is useful to keep the list of characters between the first and second slash short. For example, if you want to change all characters other than digits into linefeeds, you could use $Test =~ tr/0-9^n/c,- # Note that "c" to invert range The d modifier allows you to delete instead of replacing certain charcters. For example, if you want to delete all the nondigits, you would use $Test =~ tr/0-9//cd; # Change non-digits into nothing The s modifier is useful for collapsing duplicate characters. It causes Perl to treat all the found characters as one before doing the translation. For example, you may want to change all instances of two or more adjacent commas into just one comma: $Test =~ tr/,/,/s;
|
|
PERL Perl Program Data Types Types of Variables Operator Types Functions String Functions Array Functions Expressions Statement Blocks The if Statement Unless Statement While Loops Until Loop For Loop Foreach Loop Jump Keywords Subroutines Perl References Die Function Exit Function Localtime Function Standard Files File Test Operators File Functions Opening Files Reading into Hash Printing Revisited Globbing Splitting a Record into Fields Perl's Special Variables Regular Expression Simple True-False Searches Inexact Matches in Regular Expressions Matching Any Character Characters with Class Special Locations Quantifiers Greedy Matching Modifiers Localtime Function Subsituations Letter for Letter Translations Generating A Simple Report Defining a Report Template Specifying the Picture Line Specifying the Argument Line Adding a Header Writing the ReportDomain Names Home Importance of a domain name How does a web domain name work? Domain name syntax Choosing a domain name Domain Transfer Domain Parking IP AddressWeb Design HTML DHTML XML JAVASCRIPT VBSCRIPT PHOTOSHOPWeb Hosting Web Server Web Server Software Microsoft Internet Information Server Web hosting ISP Shared web hosting Virtual web hosting Dedicated web hosting Web hosting colocation Managed web hostingE Commerce Principles of E-Commerce E-Banking Electronic Payment System E-Security Credit Cards Smart Cards
The Mailbox POP Server SMTP Server IMAP Protocol |
| Home | Web Hosting | Web Design | Sitemap |
| Copyright (C) 2007. Web Domain design hosting. All rights reserved. |