It's also "better" that way - if you have to backtrack into the array
and then alter the value in the array, it's much less convenient. As
usual, Perl is optimized for maximum programmer convenience at the
expense of understandability.
Ok. How is an lvalue defined? Is it something to which we can assign
something?
lvalue means "left value". Look at
$x = $y
Here $x is on the left of the equals sign, so it's an "lvalue".
$x = "baby" # OK
$x = $y # OK
"baby" = $y # Not OK, "baby" is not an lvalue.
Something which can be the part of the left hand side of an assignment
expression right?
No, not right, left.
But, here the list @a contains literal strings and not references to
other variables.
I know I am wrong but would like to understand how an lvalue is
defined in general and
how particularly in perl. It will also be helpful if somebody can give
examples for non-lvalues...
You shouldn't really ask for examples on a newsgroup like this, it's
not a teaching forum. You need to read up on this from web pages, or
books, or try running example programs.