next up previous contents
Next: Substitution Up: Regular Expressions Previous: Backtracking

Setting the Target Operator (Binding)

We have so far seen how matching can be set up but not how it works in practice.

The =~ lets you match against a specified target (rather than an environment variable $_. In CGI (see Later) and other application we frequently need to match against input name/values.

We usually use an if statement to control the match (

$infile = ; # whatever

if ( $infile =~ /*.gif/)
  { # file is gif format file
    # well at least it ends in a .gif