http://qs1969.pair.com?node_id=479437

Angharad has asked for the wisdom of the Perl Monks concerning the following question:

Hi there again :)
I was wondering why this doesnt work. I have an array of numbers. I use a while loop as follows to split the array.
while(<>) { @array = $_; @array = split; }
This splits the array via new line. Every element of the array holds a string of numbers. The element $array[0] for example might contain the following data.
12 44 111 445
The numbers are separated by tabs.
I now want to get at individual numbers from the element $array[0]. So, I attempted the following.
@line1 = $array[0]; print "@line1\n"; # this works @line1 = split(/\t/); $var1 = $line1[0]; print "$var1\n"; # this doesnt work
$var1 doesnt print. Could anyone please tell me why and what I could try to rectify this? Thanks