Binish A R wrote:
> How can I force array context ... 

Sorry, you can't.  You can have either list context or scalar context or void
context.

perldoc -f wantarray


> like
> 
> # echo hello: world | perl -lne '$aref = split(/:/, $_); print $aref'
> 
> but thatz giving the length of the array

That is impossible as there is no array there.

perldoc -q "What is the difference between a list and an array"


> ... I want $aref to be a reference ...
> How is that possible ??

You need to copy the list returned from split into an anonymous array and
assign that to the scalar variable.

# echo hello: world | perl -lne '$aref = [ split /:/ ]; print $aref'

perldoc perldata
perldoc perldsc
perldoc perllol



John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to