[comp.lang.perl] Bug in "$VER =~ /$foo/" when $VER contains "/"

carlton@apollo.HP.COM (Carlton B. Hommel) (03/27/91)

The following program exhibits a bug.  My workaround was to
replace =~ with eq -- but that reduces the functionality.

Invoke it without any options.  The output I get with
    This is perl, version 4.0
    $Header: perl.c,v 4.0 91/03/20 01:37:44 lwall Locked $
    Patch level: 0
is
    "bl24" matches "" 
    "02/05/91" nomatch "" 

Carl Hommel
carlton@apollo.hp.com


#! /usr/local/bin/perl

require 'getopts.pl';
&Getopts('X:');

$VER = "bl24";
if ($VER =~ /$opt_X/) {
    print "\"$VER\" matches \"$opt_X\" \n";
} else {
    print "\"$VER\" nomatch \"$opt_X\" \n";
}

$VER = "02/05/91";
if ($VER eq /$opt_X/) {
    print "\"$VER\" matches \"$opt_X\" \n";
} else {
    print "\"$VER\" nomatch \"$opt_X\" \n";
}