in reply to Re^2: Scope Issue
in thread Scope Issue

I have another question on this topic. I'm also getting a similar warning in another part of the code: "Use of uninitialized value $\ in concatenation (.) or string at C:\scripts\DailyComp2.8.pl line 208 (#1)". This warning comes from the following line of code:

my $match_live = "\/LIVE>.*$\/";

I am defining a pattern match for Net::Telnet to use in various places in the code. The back slash in $\ is there to escape the forward slash which is the end of the pattern match, but it looks like PERL is interpreting it as variable. Any suggestions? Thanks

Replies are listed 'Best First'.
Re^4: Scope Issue
by Corion (Patriarch) on Mar 15, 2011 at 15:08 UTC

    If you are constructing regular expressions, the qr operator is much more convenient:

    my $match_live = qr/LIVE>.*$/;

    If Net::Telnet does not want qr-quoted regular expressions, use single quotes to construct your string and not interpolate variables:

    my $match_live = q'/LIVE>.*$/';

      Thanks, Corion! That worked great. I used q with the single quotes. Thanks again for the help