Dave's Brain

Browse - programming tips - perl tends to operator

Date: 2011aug3
Source: Talk by Damian Conway
Language: Perl

Q.  Any obscure operators in perl 5?

A.  Did you know about the "tends to" operator in Perl?
Like Calculus limits.
Looks like   -->

Example:

$count = 10;
while ($count   -->   0)
{
        print "$count\n";
}






This is a joke.  Its really the familiar decrement (--) and greater than (>) squished together :)
ie:

$count = 10;
while ($count-- >   0)
{
        print "$count\n";
}


Perl will run both these examples the same.
Apparently it works in C and other languages.  Impress your friends with the mysterious "tends to" operator.
What this info useful to you? You can donate to say thanks

Add a comment

Sign in to add a comment
Copyright © 2008-2012, dave - Code samples on Dave's Brain is licensed under the Creative Commons Attribution 2.5 License. However other material, including English text has all rights reserved.
Advertisements: