in reply to save regex in a file?

There are a number of builtin ways to do this, partucularly if the regex is stored in perl syntax.

  1. do FILE;
  2. open FL, $fname; $re = <FL>; close FL;
  3. require FILE
  4. use MODULE
Each listed way has it's own conventions for getting a value out. The elegant way if to make the file a module:
package VIR; our $vir = qr/My\s+[Rr]egex/; 1;
Usage:
#!/usr/bin/perl -w use strict; use lib '/location/of/lib/'; use VIR; $_="My regexen"; print "found\n" if m/$VIR::vir/;
Each listed way has it's own conventions for getting a value out.

After Compline,
Zaxo