What's going on here?

Christopher Shannon cshannon at mdo.net
Tue Sep 21 15:37:29 CDT 1999

>Can you send the code where you took out the defined($1) and the comma

OK, it looks like the problem is solved.  It seems you really pointed out
where the problem was, namely with the while test condition.  Actually, I
was under the mistaken impression that if the next regex was unsuccessful,
the $1 was undefined, or acquired a null value, which is not the case.
Anyway, based on that, the solution I came up with was a little less
elegant, but it works.

Thanks a bunch, Tzadik!

Regards, Chris S.

P.S.  BTW, here is the corrected code:

sub CompileVCodes {
 my $xtype;
 my $regex;
 my @badlist;
 my $vcode;
 my $d;

 ($vcode, $xtype, $regex, @badlist)=@_;
 my $err=\&print_error;
 $vcode->{$xtype}= sub {
  (my $wrd)=@_; # $err is a reference to an error message routine.
  $d=$wrd=~/$regex/i;        # # Here is one change
  while ($d eq '')
   chomp ($wrd=<STDIN>);
   if ($wrd eq '') {return ''}
   $d=$wrd=~/$regex/i;        # # Here is another change, the first regex is
                                          # # at the end of the loop.
  return $wrd;

More information about the Baltimore-pm mailing list