Hello,
i have problem with uninitialised char and i don't know how to resolve a
problem.
I will paste part of code:
#!/usr/bin/perl

use strict;
use warnings;
use diagnostics;

my $temp_buf = 0;
my @buffer = ();
my $all = 255;
my $cardid = "AS12F002312";

for (my $i = 1; $i < 60001; $i++)
{
        if ($i < 6001)
                $buffer[$i] = 0;
                $i++;
                $buffer[$i] = $all;
        };
};

my $cuted_card = cutcard($cardid);

cut card is a function that remove all chars from $cardid to and return:
$cuted_card = "2312";
                $cuted_card = 0 + $cuted_card;
                $temp_buf = 0;
                $temp_buf = $buffer[$cuted_card];
                if ($temp_buf == 0)
                {
                        $temp_buf = 0;
                };
                $temp_buf = sprintf "%d",$temp_buf; # i need number not
char, so tried to
convert char in to number. $buffer recive values 2,3,4 numeric and bellow
of end of file i take chr from $buffer[$cuted_card] and write it to binary
file.
                $temp_buf = 0 + $temp_buf; 
                if ($temp_buf == $all)
                {
                        $temp_buf = 0;
                };
                $buffer[$cuted_card] = $temp_buf;

I have problem with this line 164: if ($temp_buf == 0)
i always recive :
Use of uninitialized value in numeric eq (==) at ./test.pl line 164 (#1)
    (W uninitialized) An undefined value was used as if it were already
    defined.  It was interpreted as a "" or a 0, but maybe it was a mistake.
    To suppress this warning assign a defined value to your variables.

    To help you figure out what was undefined, perl tells you what operation
    you used the undefined value in.  Note, however, that perl optimizes
your
    program and the operation displayed in the warning may not necessarily
    appear literally in your program.  For example, "that $foo" is
    usually optimized into "that " . $foo, and the warning will refer to
    the concatenation (.) operator, even though there is no . in your
    program.

I tryed to compare like char: if ($temp_buf eq chr(0)) but no effect.
also i have problem with this line: $temp_buf = sprintf "%d",$temp_buf;
Use of uninitialized value in sprintf...
I also tried $temp_buf = 0 + $temp_buf; <-- no effect.

Do any body can help me to resolve i problem. If i remove strict, warnings,
diagnostics i do not recive warning messages, but i does not want to remove
these lines.

Regards,
John

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to