Try this:

echo hello: world | perl -lne '$aref = [ split(/:/, $_) ]; print $aref'

[] synthax gives a ref to the array returned by split()

HTH,
José.

-----Message d'origine-----
De : Binish A R [mailto:[EMAIL PROTECTED] 
Envoyé : samedi 20 août 2005 17:15
À : Perl Beginners
Objet : Forcing array context


How can I force array context ... 
like

# echo hello: world | perl -lne '$aref = split(/:/, $_); print $aref'

but thatz giving the length of the array ... I want $aref to be a
reference ...
How is that possible ??

A workaround is to use the following

# echo hello: world | perl -lne '@ar = split(/:/, $_); $aref = [EMAIL 
PROTECTED];'

But I'm not satisfied with that as I've to use an extra variable @ar ...
:(

Any help ...
 
 

-- 



--
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