Hello
mrityunjaynath,
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?
$ 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
Now, consider what you have done:
$ 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] -->