in reply to Trying to understand Perl :-)

Hi harangzsolt33,

Just to mention a few more small things in addition to Corion's excellent post.

print "\nL=".((AA) + BB) ."\n";

An alternate way to tell Perl that the call to AA should take no arguments (instead of taking the return value of the call to BB) is (AA() + BB()).

# sub DDD { # 4+4; # 5+(previous lines' result); # return previous line's result; # }

In the first case, no, you'd need to write 5 + (4+4); or my $v = 4+4; 5+$v;.

In the second case, from perlsub: "If no return is found and if the last statement is an expression, its value is returned." So all you need to write is sub foo { my $v = 4+4; 5+$v; } and foo will return 5+$v.

perlsub also goes on to explain why your sub Y doesn't return the value of $i: "If the last statement is a loop control structure like a foreach or a while, the returned value is unspecified." It's easily achievable though: sub Y { my $i=0; $i while($i++<10); $i }

And some more info on version strings: Version Strings

Hope this helps,
-- Hauke D