June 2005
Beginner
480 pages
10h 31m
English
| Q1: | Are substr, index, and rindex really necessary? Why do they exist when regular expressions can be used for most of those operations? |
| A1: | First, regular expressions for simple string searches are generally slower than index and rindex. Second, writing substitution expressions for fixed character positions with regular expressions can be messy; substr is a much more elegant solution sometimes. Third, Perl is a rich language. Use what you like; you have plenty of choices. |
| Q2: | What happens with substr (or index or rindex) if I specify an index that's beyond the end of the scalar? |
| A2: | One nice thing about computers is that they're consistent and have limitless amounts of patience. With questions like “What happens if I…?” sometimes just trying ... |
Read now
Unlock full access