introduction to web programming 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;

Previous | Next | Table of Contents