> "Use of uninitialized value"

This just means that you haven't given a value to $atmnb yet (which will
happen unless /^XXX/ matches in your loop).

To get rid of the warning you should initialize the variable when you create
it.

Instead of:
my $atmnb;

Use this:
my $atmnb = '';

Rob


-----Original Message-----
From: FyD [mailto:[EMAIL PROTECTED]
Sent: Thursday, July 08, 2004 3:50 PM
To: [EMAIL PROTECTED]
Subject: Use of uninitialized value in string eq


Hi,

Here is a short perl script:

   open (FILE, "<$START");
   $nbc=0;
   foreach(<FILE>){
        if (/^XXX/ig)   { $atmnb[$nbc]++;}
        if (/^YYY/ig)   { $atmnb1=$atmnb[0];}
        if (/^ZZZ/ig)   { $nbc++;}
   }
   if ($atmnb1 eq "")   { $atmnb1=$atmnb[0];}
   close(FILE);
   $nbc++;

When I try to execute it using the '-w' option, I get the following warning:
"Use of uninitialized value in string eq at RED-II.pl line 8"

I do not understand as for me ($atmnb1 eq "") is needed for uninitialized
values.

How can avoid such warnings ?

Thanks, Francois

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to