Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Unable to extract elements from a split. Kindly Help.

by perl514 (Pilgrim)
on Dec 24, 2011 at 07:18 UTC ( [id://945018]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://945018]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2024-04-25 23:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found