-----Original Message-----
From: sanket vaidya [mailto:sanket.vai...@patni.com] 
Sent: Friday, May 29, 2009 9:20 AM
To: 'beginners@perl.org'
Subject: RE: Range Operator Question

-----Original Message-----
From: Chas. Owens [mailto:chas.ow...@gmail.com] 
Sent: Thursday, May 28, 2009 5:55 PM
To: sanket vaidya
Cc: beginners@perl.org
Subject: Re: Range Operator Question

On Thu, May 28, 2009 at 07:51, sanket vaidya <sanket.vai...@patni.com>
wrote:
> Hi,
>
> I came across this statement about 'range' operators somewhere.
>
> There is very little difference between $x..$y and $x...$y, and if the
> second operand is a constant then they are identical.
>
> What is the difference? Kindly explain with example.
snip

>In list context the ... operator is the same as the .. operator.

>In scalar context, well perlop[1] says it better than I could:

 >      In scalar context, ".." returns a boolean value.  The operator is
  >     bistable, like a flip-flop, and emulates the line-range (comma)
  >     operator of sed, awk, and various editors.  Each ".." operator
  >     maintains its own boolean state.  It is false as long as its left
  >     operand is false.  Once the left operand is true, the range operator
  >     stays true until the right operand is true, AFTER which the range
  >     operator becomes false again.  It doesn't become false till the next
  >     time the range operator is evaluated.  It can test the right operand
  >     and become false on the same evaluation it became true (as in awk),
>but
 >      it still returns true once.  If you don't want it to test the right
   >    operand till the next evaluation, as in sed, just use three dots
    >   ("...") instead of two.  In all other regards, "..." behaves just
>like
 >      ".." does.

>1. http://perldoc.perl.org/perlop.html#Range-Operators

-- 
>Chas. Owens
>wonkden.net
>The most important skill a programmer can have is the ability to read.

Can anyone write few simple codes explaining the behavior that Chas
mentioned, So that I can explore the codes for getting better picture?

Regards,
Sanket Vaidya



_____________________________________________________________________ 

This e-mail message may contain proprietary, confidential or legally privileged 
information for the sole use of the person or entity to whom this message was 
originally addressed. Any review, e-transmission dissemination or other use of 
or taking of any action in reliance upon this information by persons or 
entities other than the intended recipient is prohibited. If you have received 
this e-mail in error kindly delete this e-mail from your records. If it appears 
that this mail has been forwarded to you without proper authority, please 
notify us immediately at netad...@patni.com and delete this mail.
_____________________________________________________________________

-- 
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