On Tue, Sep 22, 2009 at 05:09:26AM -0400, Shawn H Corey wrote: > Roman Makurin wrote: > >Hi All! > > > >right now im doing it in following way: > >$size = @{[func_that_return_list_value]}; > > > >is there any best way to do it ? > > > See `perldoc -f scalar` http://perldoc.perl.org/functions/scalar.html
I read the perldoc on scaler and then tried every combination I could think of: perl -le ' sub farr{ return qw( k l m ); } $a = @{[farr]}; $b = scalar farr; $c = scalar (farr); $d = scalar [farr]; $e = scalar @{farr}; $f = scalar @{[farr]}; $g = () = farr; print "\n\$a = $a, \$b = $b, \$c = $c, \$d = $d, \$e = $e, \$f = $f, \$g = $g";' $a = 3, $b = m, $c = m, $d = ARRAY(0x814f8e4), $e = 0, $f = 3, $g = 3 Unless there is a syntax I've missed, only a, f & g give the desired answer. To my thinking a is clearly preferable to f but the winner has to be g. =()= is much more legible than @{[]}, less prone to mistyping. Thank you Paul Johnson for bringing this to my attention. The original question was what's 'best'. Does anyone know of a case where one of these expressions would fail? TIA, Mike -- Satisfied user of Linux since 1997. O< ascii ribbon campaign - stop html mail - www.asciiribbon.org -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/