[FR/EN] Initialisationde valeur / Use of uninitialized value in addition (+)

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

•  Subject
• Author
• Posted on
FR ---------------------------------------------------------------

bonjour

j'ai un probl=E8me d'initialisation de valeur, mais c'est un op=E9rateur
!

merci

christophe

EN ---------------------------------------------------------------

hello

I have a problem of initialization of value, but it is an operator!

thank you Christophe

CODE -------------------------------------------------------------
.=2E
.=2E  @DepHM = split(":", "\$TSTART_A");
.=2E  \$DepHH = \$DepHM[0];           # Heures
.=2E  \$DepMM = \$DepHM[1];           # Minutes
.=2E
.=2E  @TimeHMS = split(/([hmns])/, "\$TIME_A", 3);
.=2E  \$TimeHH = \$TimeHMS[0];           # Heures
.=2E  \$TimeMM = \$TimeHMS[2];           # Minutes
.=2E
.=2E
443 \$ESTIM_MM = (\$DepMM + \$TimeMM);
444 \$ESTIM_HH = (\$DepHH + \$TimeHH);

RESULT -----------------------------------------------------------

Use of uninitialized value in addition (+) at Collecte_Networker.pl
line 444,

Re: [FR/EN] Initialisationde valeur / Use of uninitialized value in addition (+)

Alextophi wrote:

\$DepHH or \$TimeHH or both are undef.
Since \$DepMM and \$TimeMM seem to be defined, and from the additional=20
code you give, it is most likely that one of \$DepHH or \$TimeHH (or both) =

lose their values.

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

Re: [FR/EN] Initialisationde valeur / Use of uninitialized value in addition (+)

[snip]

There is no need to enclose \$TSTART_A in quotes.

Do you mean \$TimeHMS[1] ?

\$DepMM can be undefined if \$TSTART_A does not contain a ':' character
and split returns only one element.

\$TimeMM can be undefined if \$TIME_A contains fewer than 2 ':'
characters and split returns fewer than 3 elements.

To the OP: print out the values of \$TSTART_A and \$TIME_A and check if
they contain what you think they do. Use a construct such as this:

\$DepMM = \$DepHM[1] || 0;

to set the value of \$DepMM even if \$DepHM[1] is undefined.

Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com

Re: [FR/EN] Initialisationde valeur / Use of uninitialized value in addition (+)

Jim Gibson wrote:

I disagree. My first reaction was the same.
However, the error was reported in line 444, so apparently \$DepMM and=20
\$TimeMM are both defined.
If \$TSTART_A did not contain a :, split would indeed return a single=20
element and put that into \$DepHM[0], leaving \$DepHM[1] undefined.=20
However, as \$DepHH = \$DepHM[0]; and \$DepMM = \$DepHM[1]; this would le=
ave=20
\$DepMM undefined and \$DepHH defined.

Similar for \$TIME_A, and the values derived from it.

use warnings;
use strict;
my \$TSTART_A = 'No colon';
my @DepHM = split(":", "\$TSTART_A");
my \$DepHH = \$DepHM[0];
my \$DepMM = \$DepHM[1];
print "DepHH=3D\$DepHH\n";
print "DepMM=3D\$DepMM\n";

DepHH=3DNo colon
Use of uninitialized value in concatenation (.) or string at - line 8.
DepMM=3D

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