Win has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks,

Please could somebody suggest why I get the following warning message.
Use of uninitialized value in regexp compilation at Program.pl line 15 +2, <FLAT_FILE_B> line 1.
The snippit of code for this is below.
while (<FLAT_FILE_B>){ chomp; s/"//g; my $chosen_C = $_; my @EXEC_block_array; if ($rewrite_file_status == 1){ if (defined $chosen_C && $chosen_C =~ /;(\d{1,3});\d{1,3};Stand_me +thod;'SMRxsxtxmx(\d\d\d\d)x(\d\d\d\d)x(\d\d)x(\d\d\d\d).{0,10}'/){ # + Here I get the warning message

Replies are listed 'Best First'.
Re: Use of uninitialized value in regexp compilation
by ysth (Canon) on Jan 30, 2006 at 12:07 UTC
    Been a real flurry of this lately...check for an undef variable in a regex in an elsif condition.

    See recent discussion at die/warn bug in elsif.

Re: Use of uninitialized value in regexp compilation
by GrandFather (Saint) on Jan 30, 2006 at 11:06 UTC

    That snippet of code contains errors. The following snippet of code works as expected. Perhaps you could modify it to show your problem?

    use strict; use warnings; my $str = ";123;1;Stand_method;'SMRxsxtxmx1234x1234x12x123­1.'"; print "ok" if defined $str && $str =~ /;(\d{1,3});\d{1,3};Stand_method +;'SMRxsxtxmx(\d\d\d\d)x(\d\d\d\d)x(\d\d)x(\d\d\d­\d).{0,10}'/;

    Prints:

    ok

    DWIM is Perl's answer to Gödel
Re: Use of uninitialized value in regexp compilation
by Anonymous Monk on Jan 30, 2006 at 11:04 UTC
    The line you've shown doesn't use variables in regex compilation, and is not the line that triggers the warning.
Re: Use of uninitialized value in regexp compilation
by Anonymous Monk on Jan 30, 2006 at 11:11 UTC
    perl -we'$_ = qr{$_}' Use of uninitialized value in regexp compilation at -e line 1.
Re: Use of uninitialized value in regexp compilation
by Anonymous Monk on Jan 30, 2006 at 11:07 UTC
    perl -we'$_ =~ $_' Use of uninitialized value in regexp compilation at -e line 1. Use of uninitialized value in pattern match (m//) at -e line 1.