FyD wrote: > Hi, > > Here is a short perl script: > > open (FILE, "<$START");
First of all, we ALWAYS recommend you put "use strict" at the top of your program and delcare your variables with "my". That can save you from lots of trouble with typos, etc. Also, always check the return value from calls like open(), etc. Where did $START come from? > $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 ? The warning happens because $atmnbl has (apparently) never been initialized, so it has the value undef for the purposes of the comparison. When undef is used in an eq comparison, it's treated as an empty string, so your comparison will work OK. I personally find that particular warning extremely annoying, because you often have to jump through a number of unnecessary hoops to avoid it. Fortunately, with recent versions of Perl you can selectively disable this warning with: no warnings 'uninitialized'; You might want to use the defined() function instead. That will get rid of the warning. if (!defined($atmnb1)) { $atmnb1=$atmnb[0];} Which is written more idiomatically as: $atmnbl = $atmnb[0] unless defined $atmnbl; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>