Dave's Brain

Browse - Programming Tips - Any obscure operators in perl 5?

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

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

Add a comment

Sign in to add a comment
Copyright © 2008-2017, 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.