in reply to Re^6: warning: use of uninitialized value
in thread warning: use of uninitialized value
Athanasius gave you the right advice about picking the correct values off split. What you need to realize is, arrays are indexed from zero: if you have an array @myarray with 3 elements, it will have elements at: $myarray[0], $myarray[1] and $myarray[2]. Also, why are you splitting on :: when you have specified the config file to be delimited by spaces?
Now, consider what you have done:$ cat pm_1132055.pl #!perl while(my $line = <DATA>) { chomp $line; my @words = split /\s+/, $line; print join(", ", @words), "\n"; print qq{\$words[1] --> $words[1] and \$words[3] --> $words[3]}, " +\n"; } __DATA__ ChipId 1925 SubVersid 0001 $ perl pm_1132055.pl ChipId, 1925, SubVersid, 0001 $words[1] --> 1925 and $words[3] --> 0001
$ cat pm_1132055.pl #!perl while(my $line = <DATA>) { chomp $line; my @words = split /::/, $line; print join(", ", @words), "\n"; print qq{\$words[1] --> $words[1] and \$words[3] --> $words[3]}, " +\n"; } __DATA__ ChipId 1925 SubVersid 0001 $ perl pm_1132055.pl ChipId 1925 SubVersid 0001 $words[1] --> and $words[3] -->
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^8: warning: use of uninitialized value
by mrityunjaynath (Acolyte) on Jun 26, 2015 at 05:26 UTC | |
by robby_dobby (Hermit) on Jun 26, 2015 at 05:47 UTC | |
by mrityunjaynath (Acolyte) on Jun 26, 2015 at 08:55 UTC | |
by robby_dobby (Hermit) on Jun 26, 2015 at 09:11 UTC | |
by mrityunjaynath (Acolyte) on Jun 26, 2015 at 10:17 UTC | |
|