On Sun, 24 Jan 2016 20:03:29 +0100
Paul Johnson <p...@pjcj.net> wrote:

> On Sun, Jan 24, 2016 at 05:44:14PM +0200, Shlomi Fish wrote:
> > Hi lee,
> > 
> > On Sun, 24 Jan 2016 13:11:37 +0100
> > lee <l...@yagibdah.de> wrote:
> >   
> > > Paul Johnson <p...@pjcj.net> writes:  
> > > >
> > > > In scalar context the comma operator evaluates its left-hand side,
> > > > throws it away and returns the right-hand side.    
> > > 
> > > What is the useful use for this operator?
> > >   
> > 
> > Well, I believe its use was originally inherited from
> > https://en.wikipedia.org/wiki/C_%28programming_language%29 where one can do
> > something like:
> > 
> >     x = (y++, y+2);
> > 
> > In Perl 5 though it is preferable to use do { ... } instead:
> > 
> >     $x = do { $y++; $y+2; };  
> 
> In both Perl and C the comma operator is probably most usually (deliberately)
> seen in for statements:
> 

Good point, Paul! I forgot about it.

-- Shlomi

-- 
-----------------------------------------------------------------
Shlomi Fish       http://www.shlomifish.org/
Rethinking CPAN - http://shlom.in/rethinking-cpan

Sisko: Q: would it be OK if my crew brought along their phasers with them?

Q: Of course. They can also bring some photon torpedoes if they wish. None of
them will work, but I don’t mind them taking them.

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