next up previous contents
Next: The Matching Operator (m//) Up: Regular Expressions Previous: Setting the Target Operator

Substitution

We may frequently need to change a pattern in a string. The substitution operator (s) is the simplest form of substitution. It has the form:

s/old_regex/new_string/

So to replace the + characters from CGI input with a space we could do:

$CGI_in_val =~ s/\+/ /ge;

We can qualify the substitution with a g global substitution, i ignore case and e evaluate right side as expression and others.



dave@cs.cf.ac.uk