I really like programming languages that allow you to think less without compromising the quality of your coding practices. Take for instance the new smart match operator '~~
' which was introduced in the latest Perl releases.
if ( '123.0' ~~ 123 ) { ... } # String and number: TRUE
You don't have to keep trying to remember if a given scalar is a string or a number or 'numish' (both), sometimes wrongly using the standard operators ( eq
, ne
, lt
, ==
, >=
) in the wrong places causing bugs which are hard to track down.
Don't forget to enable this functionality by including the following in your code:
use 5.010;
Or you can enable the feature by calling Perl with the '-E
' option at the command line.
I think you mean "use 5.010;" or "use v5.10;". As a side note, saying "use 5.012;" or "use v5.12;" enables strict for you.
Should be use 5.010;, thanks for spotting the typo.
In combination with given and when you can write some very nice code with the smart match operator.