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

A

Alextophi

FR ---------------------------------------------------------------

bonjour

j'ai un problème d'initialisation de valeur, mais c'est un opérateur
!

merci

christophe

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

hello

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

thank you Christophe



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



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

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

Josef Moellers

Alextophi said:
FR ---------------------------------------------------------------

bonjour

j'ai un problème d'initialisation de valeur, mais c'est un opérateur
!

merci

christophe

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

hello

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

thank you Christophe



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



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

Use of uninitialized value in addition (+) at Collecte_Networker.pl
line 444,
$DepHH or $TimeHH or both are undef.
Since $DepMM and $TimeMM seem to be defined, and from the additional
code you give, it is most likely that one of $DepHH or $TimeHH (or both)
lose their values.
 
J

Josef Moellers

Jim said:
Alextophi said:
FR ---------------------------------------------------------------
[snip]
I have a problem of initialization of value, but it is an operator!

thank you Christophe



CODE -------------------------------------------------------------
..
.. @DepHM = split(":", "$TSTART_A");


There is no need to enclose $TSTART_A in quotes.

.. $DepHH = $DepHM[0]; # Heures
.. $DepMM = $DepHM[1]; # Minutes
..
.. @TimeHMS = split(/([hmns])/, "$TIME_A", 3);
.. $TimeHH = $TimeHMS[0]; # Heures
.. $TimeMM = $TimeHMS[2]; # Minutes


Do you mean $TimeHMS[1] ?

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


$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.

I disagree. My first reaction was the same.
However, the error was reported in line 444, so apparently $DepMM and
$TimeMM are both defined.
If $TSTART_A did not contain a :, split would indeed return a single
element and put that into $DepHM[0], leaving $DepHM[1] undefined.
However, as $DepHH = $DepHM[0]; and $DepMM = $DepHM[1]; this would leave
$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=$DepHH\n";
print "DepMM=$DepMM\n";


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

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

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,240
Members
46,830
Latest member
HeleneMull

Latest Threads

Top