For Programmers: Free Programming Magazines  


Home > Archive > PERL Miscellaneous > July 2006 > Uninitialized value errors









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Uninitialized value errors
Archimede Pitagorico

2006-07-26, 6:59 pm

This code give me many errors:

http://nopaste.info/6ec866c6ea.html

1) Use of uninitialized value in numeric gt (> ) ....

Why? Thanks.
axel@white-eagle.invalid.uk

2006-07-26, 6:59 pm

Archimede Pitagorico <archimede@linby.net> wrote:
> This code give me many errors:


> http://nopaste.info/6ec866c6ea.html


> 1) Use of uninitialized value in numeric gt (> ) ....


> Why? Thanks.


If you cannot be bothered to actually post your code, why should we
bother to look it up on the web?

Axel

ks

2006-07-26, 6:59 pm

On Thu, 27 Jul 2006 00:50:46 +0200, Archimede Pitagorico
<archimede@linby.net> wrote:

>This code give me many errors:
>
>http://nopaste.info/6ec866c6ea.html
>
>1) Use of uninitialized value in numeric gt (> ) ....


beceuse you haven't read any values into $num1 and $num2 variables.
they remain uninitialized. i haven't used String::Scanf module before
but you don't have to use it to solve your problem. instead of using
sscanf try this:

my $line = <>;
($num1, $num2) = $line =~ /(\d+).*?(\d+)/;

you can also remove $input variable and put some tests after above 2
lines to ensure that both, $num1 and $num2 are defined - contain some
values. be aware that the user can provide any input line - even the
one you aren't expecting.

best regards,
ks
Archimede Pitagorico

2006-07-26, 6:59 pm

On Wed, 26 Jul 2006 23:17:34 GMT, axel@white-eagle.invalid.uk wrote:

>Archimede Pitagorico <archimede@linby.net> wrote:
>
>
>
>
>If you cannot be bothered to actually post your code, why should we
>bother to look it up on the web?
>
>Axel


Sorry but I have think that long code can be a problem in newsgroups.
:(

Archimede Pitagorico

2006-07-26, 6:59 pm

On Thu, 27 Jul 2006 01:21:25 +0100, ks <ksamp@vp_removeit_.pl> wrote:

>On Thu, 27 Jul 2006 00:50:46 +0200, Archimede Pitagorico
><archimede@linby.net> wrote:
>
>
>beceuse you haven't read any values into $num1 and $num2 variables.
>they remain uninitialized. i haven't used String::Scanf module before
>but you don't have to use it to solve your problem. instead of using
>sscanf try this:
>
>my $line = <>;
>($num1, $num2) = $line =~ /(\d+).*?(\d+)/;
>
>you can also remove $input variable and put some tests after above 2
>lines to ensure that both, $num1 and $num2 are defined - contain some
>values. be aware that the user can provide any input line - even the
>one you aren't expecting.
>
>best regards,
>ks



Ok thanks :)
Chris Mattern

2006-07-26, 6:59 pm

Archimede Pitagorico wrote:
> On Wed, 26 Jul 2006 23:17:34 GMT, axel@white-eagle.invalid.uk wrote:
>
>
>
>
> Sorry but I have think that long code can be a problem in newsgroups.
> :(
>


Which is why you make it *short* code. The rule is: "Reduce your
script down to the absolute minimum required to replicate
the error you are seeing. Then post that short *but complete*
script." This is not only courteous to the group but is an
essential debugging method. Much of the time you will find that
simply attempting to so reduce your script will make the cause
of the error obvious to you. Have you read the posting guidelines?
If not, you should.


Chris Mattern
axel@white-eagle.invalid.uk

2006-07-26, 9:58 pm

Archimede Pitagorico <archimede@linby.net> wrote:
> On Wed, 26 Jul 2006 23:17:34 GMT, axel@white-eagle.invalid.uk wrote:


[color=darkred]
[color=darkred]
[color=darkred]
[color=darkred]
[color=darkred]
> Sorry but I have think that long code can be a problem in newsgroups.
> :(


Long code is a problem anyway... the Posting Guidelines give guidance as
to providing the best means of receiving help.

Besides that, posting the code to the newsgroup is much less of a problem
than putting it on a web site.

- People need to start a browser to view the code instead of just
reading it in context with the problem.

- Answers relating to the code are not very meaningful unless those
reading the follow-ups also go to the effort of visiting the web page.
Which manages to destroy guidelines about posting replies in context
unless the replier is willing to cut and paste.

- The web page will no doubt be ephemeral and thus the archives of the
group will contain posts with little meaning since essential
information is lacking (the same as posting material with an
X-No-Archive header).

- In general it just involves a great deal more work for everyone with
no gain whatsoever.

Sorry to go on at length, but it is something which does annoy me... you
are certainly not the only person to do this and doubtless will not be
the last.

Axel

Josef Moellers

2006-07-27, 3:59 am

axel@white-eagle.invalid.uk wrote:
> Archimede Pitagorico <archimede@linby.net> wrote:
>=20
>=20
> =20
>=20
>=20
> =20
>=20
>=20
> =20
>=20
>=20
>=20
> If you cannot be bothered to actually post your code, why should we
> bother to look it up on the web?


Also, the error message given (omitting the line number) would require=20
us to actually run the script. Running an unknown, and in this case=20
*known* *buggy* script is pretty much like eating something found on the =

sidewalk.

--=20
Josef M=F6llers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize
-- T. Pratchett

anno4000@radom.zrz.tu-berlin.de

2006-07-27, 3:59 am

Archimede Pitagorico <archimede@linby.net> wrote in comp.lang.perl.misc:
> This code give me many errors:
>
> http://nopaste.info/6ec866c6ea.html
>
> 1) Use of uninitialized value in numeric gt (> ) ....


That's a rather misleading description of your program's behavior.

Why don't you mention the other 13 error messages you're getting?
Why don't you mention that the program asks you to enter two integers
but doesn't give you the chance to do so?

Anno
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com