question
--000e0cd105883510390480ad1cdb
Content-Type: text/plain; charset=ISO-8859-1
sorry guys i apologize for this question,
how come when writing a program that these are not equivalent:
[at] files = readdir(D);
vs
readdir(D) = [at] files;
thanks for your patience,
stace
--000e0cd105883510390480ad1cdb--
Re: question
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:
>
> [at] files =3D readdir(D);
>
> vs
>
> readdir(D) =3D [at] files;
>
Well, first of all, use strict and warnings and use lexical filehandles and=
dirhandles.
Otherwise the "A =3D B" sets A to the value of the expression B (and never =
vice-
versa). "my [at] files =3D readdir($dir_handle);" assigns what readdir returns =
(in
list context) to [at] files, and populates [at] files with the contents of the
directory. But setting =ABreaddir($dir_handle)=BB with some value is not pe=
rmitted
by Perl and I'm not sure what it will do.
=46or 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
=2D-
=2D--------------------------------------------------------- -------
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-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
Re: question
>>>>> "SO" == S O <shogunok [at] gmail.com> writes:
SO> sorry guys i apologize for this question,
SO> how come when writing a program that these are not equivalent:
SO> [at] files = readdir(D);
SO> vs
SO> readdir(D) = [at] files;
my question is why would you think they are the same? your same question
can be asked about $x = $y vs $y = $x. do you know what = means in perl
(and almost all common programming languages)?
uri
--
Uri Guttman ------ uri [at] stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
Re: question
On Sunday 28 Feb 2010 22:08:21 Uri Guttman wrote:
> >>>>> "SO" == S O <shogunok [at] gmail.com> writes:
> SO> sorry guys i apologize for this question,
> SO> how come when writing a program that these are not equivalent:
>
> SO> [at] files = readdir(D);
>
> SO> vs
>
> SO> readdir(D) = [at] files;
>
> my question is why would you think they are the same? your same question
> can be asked about $x = $y vs $y = $x. do you know what = means in perl
> (and almost all common programming languages)?
>
Now that I think about it, I think they may be confusing it with "=="
(numerical equality). So:
20 + 4 == 24
Is indeed equivalent to:
24 == 20 + 4
But naturally "=" is assignment instead of equality.
Regards,
Shlomi Fish
--
------------------------------------------------------------ -----
Shlomi Fish http://www.shlomifish.org/
Rethinking CPAN - http://shlom.in/rethinking-cpan
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-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/