next up previous
Next: Substitution Up: Some useful Perl Previous: Backtracking

Setting the Target Operator

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 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

   ........
   }



Dave Marshall
9/28/2001