Warnings in program

R

Rita

Hi All
I am getting 1 warning in my program that
Use of uninitialized value in print at C:/Perl/site/lib/Bio/Root/IO.pm
line 407,<FILE> line 4.
I check my programm it is correct and it is giving me right output too
..
should I ignore this warning or solve it?
for which reason i can get it?
Thanks
 
I

Ingo Menger

Rita said:
Use of uninitialized value in print at C:/Perl/site/lib/Bio/Root/IO.pm
line 407,<FILE> line 4.
for which reason i can get it?

You use an unitialized value on line 407 of
C:/Perl/site/lib/Bio/Root/IO.pm

Perhaps you are calling a subroutine in your main program and pass some
undefined value as parameter?
 
C

Chris Richmond - MD6-FDC ~

I am getting 1 warning in my program that
Use of uninitialized value in print at C:/Perl/site/lib/Bio/Root/IO.pm
line 407,<FILE> line 4.
I check my programm it is correct and it is giving me right output too
should I ignore this warning or solve it?

Probably not. I consider all such warnings non-fatal errors that must
be fixed.

Did you pass it an uninitialized variable? Try duplicating the call
line and wrapping it in a print to make sure everything has a value.
Cheap and easy. The debugger is a good option too.

Chris
 
R

Rita

Probably not. I consider all such warnings non-fatal errors that must
be fixed.

okay can you tell me that Is
perl -w filename.pl and
perl filename.pl -w both commands has any difference because when I am
giving first command it is giving me that warnings and when I am giving
second one it is running perfectly.
Thanks
 
G

Gunnar Hjalmarsson

Rita said:
okay can you tell me that Is
perl -w filename.pl and
perl filename.pl -w both commands has any difference because when I am
giving first command it is giving me that warnings and when I am giving
second one it is running perfectly.

That's because in the second one you don't enable warnings at all, but
'-w' is interpreted as an argument.
 
X

xhoster

Rita said:
okay can you tell me that Is
perl -w filename.pl and
perl filename.pl -w both commands has any difference

In the first one, -w is an argument to the perl interpreter. The
interpreter sees this switch and turns on warnings.

In the second one, -w is an argument to your Perl program (i.e. your
program will find '-w' in @ARGV). Unless you programmed your Perl program
to inspect @ARGV and do something meaningful with it, then this form has no
effect.

because when I am
giving first command it is giving me that warnings and when I am giving
second one it is running perfectly.

That is a dubious conclusion. Failing to produce warnings when warnings
ought to be produced is not perfection.


Xho
 
A

Anno Siegel

In the first one, -w is an argument to the perl interpreter. The
interpreter sees this switch and turns on warnings.

In the second one, -w is an argument to your Perl program (i.e. your
program will find '-w' in @ARGV). Unless you programmed your Perl program
to inspect @ARGV and do something meaningful with it, then this form has no
effect.



That is a dubious conclusion. Failing to produce warnings when warnings
ought to be produced is not perfection.

It would be interesting if the warning still occurs with "use warnings"
in the main program, instead of "perl -w ...". If the Bio-something module
(name snipped and forgotten) was written without warnings and *expects*
to print undef as an empty string, the warning should disappear. If
so, that casts an unfavorable light on the module, but the warning (under
-w) would have to be considered spurious. If the warning remains with
"use warnings" (but not -w), something is happening the module didn't
expect and it should be cleared up.

Anno
 
R

Rita

It would be interesting if the warning still occurs with "use warnings"
in the main program, instead of "perl -w ...". If the Bio-something module
(name snipped and forgotten) was written without warnings and *expects*
to print undef as an empty string, the warning should disappear. If
so, that casts an unfavorable light on the module, but the warning (under
-w) would have to be considered spurious. If the warning remains with
"use warnings" (but not -w), something is happening the module didn't
expect and it should be cleared up.

ya i am using Use warnings in my main program . but it is running
perfectly.without any warning.But when i use this command
perl -w filename.pl
it is giving me warning.
I have no idea what is going on.Please Help.
Thanks
 
B

Brian McCauley

Rita wrote:

[ Attribution to Anno omitted by Rita - please don't do that! ]
ya i am using Use warnings in my main program . but it is running
perfectly.without any warning.But when i use this command
perl -w filename.pl
it is giving me warning.
I have no idea what is going on.Please Help.

I think what Anno is telling you to do is stop running Perl with the -w
switch.

The point of having the lexically scoped warnings pragma is to that
each module can choose what warning level it has.
 
R

Rita

Brian said:
Rita wrote:

[ Attribution to Anno omitted by Rita - please don't do that! ]
ya i am using Use warnings in my main program . but it is running
perfectly.without any warning.But when i use this command
perl -w filename.pl
it is giving me warning.
I have no idea what is going on.Please Help.

I think what Anno is telling you to do is stop running Perl with the -w
switch.

The point of having the lexically scoped warnings pragma is to that
each module can choose what warning level it has.

ohh okay thanks.
 
J

Joe Smith

Rita said:
ya i am using Use warnings in my main program . but it is running
perfectly.without any warning.But when i use this command
perl -w filename.pl
it is giving me warning.
I have no idea what is going on.Please Help.

You're probably looking at the wrong line. Take this example:

linux% cat test.pl
$a=3; # 1
if ($a == 1) { # 2
print "The variable $a is 1\n"; # 3
} elsif ($b == 1) { # 4
print "The variable $b is 1\n"; # 5
} else {
print "neither\n"
}
linux% perl -w test.pl
Use of uninitialized value in numeric eq (==) at test.pl line 2.
neither

Clearly the uninitialized warning is not caused by $a in line 2.
The uninitialized value is $b in the parenthesized part (on line 4)
of the elsif() clause part of the if() statement, which started
on line 2.

If the line+package reported in the warning is something you wrote,
you should investigate. Put in statements like
warn "Problem with \$a" unless defined $a;
warn "Problem with \$b" unless defined $b;
to track down which variable is causing the warning.

If the warning came from someone else's module, then either report
the problem to the author or just stop using the -w switch.

-Joe
 
R

Rita

Joe said:
You're probably looking at the wrong line. Take this example:

linux% cat test.pl
$a=3; # 1
if ($a == 1) { # 2
print "The variable $a is 1\n"; # 3
} elsif ($b == 1) { # 4
print "The variable $b is 1\n"; # 5
} else {
print "neither\n"
}
linux% perl -w test.pl
Use of uninitialized value in numeric eq (==) at test.pl line 2.
neither

Clearly the uninitialized warning is not caused by $a in line 2.
The uninitialized value is $b in the parenthesized part (on line 4)
of the elsif() clause part of the if() statement, which started
on line 2.

If the line+package reported in the warning is something you wrote,
you should investigate. Put in statements like
warn "Problem with \$a" unless defined $a;
warn "Problem with \$b" unless defined $b;
to track down which variable is causing the warning.

If the warning came from someone else's module, then either report
the problem to the author or just stop using the -w switch.

-Joe
Okay Thanks,I corrected this problam , I write code again than it is
working properly.May be i am doing some mistake in writing to code.
Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,176
Messages
2,570,950
Members
47,503
Latest member
supremedee

Latest Threads

Top