Next | Program Repair Shop | 194 |
Many Perl functions are designed to return a sensible result in boolean context
if (@array) { # the array is not empty }
if (%hash) { # the hash is not empty }
if (grep is_interesting($_), ITEMS) { # there was an interesting item }
if (s/this/that/) { # the substitution was performed }
if (ref $x) { # $x is a reference }
Take advantage of this
Use expressions as boolean values
Next | Copyright © 2002 M. J. Dominus |