Beckett Richard-qswi266 wrote, on Thursday, October 21, 2004 8:01 AM
:  I'm checking a variable with a pattern match...
:  
:  $id = "*" unless ($id =~ /\d{1,3}/);
:  
:  Now, this works everytime, and gives me the result I want, 
:  even if $id is undefined.
:  
:  However, if $id IS undefined, I also get this message:
:  
:  Use of uninitialized value in pattern match (m//) at...
:  
:  So, in a script that will be distributed to others, should I 
:  just turn warnings off, and not worry about it, or should I 
:  add a check for definedness?
:  
:  $id = "*" unless (defined $id);
:  $id = "*" unless ($id =~ /\d{1,3}/);
:  
:  Just wondering how much trouble the average hacker goes to.

You should seriously consider turning warnings off in production code (what
would the warnings mean to the user?). But if you want to leave them on in
general, you can wrap code you "expect" warnings from in:

{
        local $^W = 0;
        ..
}

This turns warnings off locally.

Good luck,

Joe

==============================================================
          Joseph P. Discenza, Sr. Programmer/Analyst
               mailto:[EMAIL PROTECTED]
 
          Carleton Inc.   http://www.carletoninc.com
          574.243.6040 ext. 300    fax: 574.243.6060
 
Providing Financial Solutions and Compliance for over 30 Years
***** Please note that our Area Code has changed to 574! *****  



_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to