Click to See Complete Forum and Search --> : i couldnt find any error in this simple few line of split code


rei
08-11-2004, 05:37 AM
i keep on getting the error of the following.
Usese of uninitialized value at ./test.pl line 10.
Use of uninitialized value at ./test.pl line 14.

But i DO initialized it already, don't i :confused: :confused:

1 #! /usr/bin/perl -w
2
3 my @data="abc:12";
4 my $a;
5 my $b;
6
7 ($a,$b)=split(/:/,@data);
8
9
10 if($b > 0){
11 printf "kigou \n";
12 }
13
14 if($b gt 0){
15 printf "gt\n";
16 }


I tried to check my code with the code checker on the internet, and it says that no error??So what is actually happening with my code?

Result of Perl code checker online:

tmp.pl syntax OK

Source

0001: #! /usr/bin/perl -w
0002:
0003: my @data="abc:12";
0004: my $a;
0005: my $b;
0006:
0007: ($a,$b)=split(/:/,@data);
0008:
0009:
0010: if($b > 0){
0011: printf "kigou \n";
0012: }
0013:
0014: if($b gt 0){
0015: printf "gt\n";
0016: }

CyCo
08-11-2004, 10:26 AM
($a,$b)=split(/:/,$data[$_]);

rei
08-16-2004, 02:13 AM
Originally posted by CyCo

($a,$b)=split(/:/,$data[$_]);


thanks :p

CyCo
08-16-2004, 12:31 PM
Originally posted by rei
thanks :p

you're welcome ;)