Hi Stace!

On Sunday 28 Feb 2010 20:14:57 S O wrote:
> sorry guys i apologize for this question,
> 
> how come when writing a program that these are not equivalent:
> 
> @files = readdir(D);
> 
> vs
> 
> readdir(D) = @files;
> 

Well, first of all, use strict and warnings and use lexical filehandles and 
dirhandles.

Otherwise the "A = B" sets A to the value of the expression B (and never vice-
versa). "my @files = readdir($dir_handle);" assigns what readdir returns (in 
list context) to @files, and populates @files with the contents of the 
directory. But setting «readdir($dir_handle)» with some value is not permitted 
by Perl and I'm not sure what it will do.

For more information, see the section about lvalues and rvalues here:

http://en.wikipedia.org/wiki/Value_%28computer_science%29

Regards,

        Shlomi Fish

> 
> thanks for your patience,
> stace

-- 
-----------------------------------------------------------------
Shlomi Fish       http://www.shlomifish.org/
Stop Using MSIE - http://www.shlomifish.org/no-ie/

Deletionists delete Wikipedia articles that they consider lame.
Chuck Norris deletes deletionists whom he considers lame.

Please reply to list if it's a mailing list post - http://shlom.in/reply .

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to