in reply to Unable to extract elements from a split. Kindly Help.

Hi Honoured GrandFather,

I tried your code but removed the <<TICKSTR with the actual command and the output is the same as yours. Thanks for the pointer.I didn't understand it when you said "but the array is in scalar context in the split". So I tried the following code:

#!/usr/bin/perl use warnings; use strict; my $test = "this is a test and hope this will work.\nif it doesnt, the +n its ok.\n"; my @array = split (/\n/, $test); print "$array[0]\n"; my @splitarray = split (/ /, @array); print "@splitarray\n";

And the output was:

this is a test and hope this will work. 2

So this means that, eventhough I mention my @splitarray = split (/ /, <b>@array</b>);, the @array is still taken in a scalar context. So that means whatever I give inside the bracket in the split function is taken in a scalar context? I am confused on this one. Kindly guide me to some pointer that will clarify this confusion.

Perlpetually Indebted To PerlMonks