Use of uninitialized value $ _ in pattern match (m //) at cursor.pl line 5

0

I have this Perl script:

#!/usr/bin/perl
use strict;
use warnings;
while () {
    if (/^PARSING IN CURSOR/../END OF STMT/) {
        if (/^PARSING IN CURSOR/) {
            s/^PARSING IN CURSOR \#//;
            s/ [a-z]+=/!/g;
            s/\n$/!/;
            $_="$.!$_";
        }
        unless (/^END OF STMT/) {
            print;
        }
    }
}

and it shows me the message:

  

Use of uninitialized value $ _ in pattern match (m //) at cursor.pl line 5

    
asked by Eddie Yair Purisaca Rivera 09.08.2018 в 03:21
source

1 answer

0

The problem is within the while() condition.

Most likely missing <> , which is the operator of reading files passed as arguments or standard input.

The error message refers to the fact that the default variable $_ has no value, it has not been initialized.

    
answered by 09.08.2018 в 04:08