The =~ operator 

The =~ operator
  • Pattern matching can also be used to manipulate variables. In particular, many CGI scripts take advantage of the "=~" operator in conjunction with the substitution operator using the format 
  • $variable_name =~
    s/[string_to_remove]/[string_to_add]/gi; 
  • For example, if we want to censor every occurrence of the word "Frack" from the client-defined input field "comment", we might use the line 
  • $form_data{'comments'} =~ s/frack/censored/gi; 

Additional Resources:

String Modifiers
Table of Contents
Using the split and join functions


Graphics & Media Lab. >> Библиотека | Курсы | Графикон

Hosted by Graphics & Media Lab
http://graphics.cs.msu.su
lab_logo
mailto: Laboratory