Perhaps Perl's (v5.10+) smart-match operator can help:
use strict; use warnings; my @array = qw/1 2 3/; print 'The variable is ' . ( is123(@array) ? '' : 'not ' ) . '[1 .. 3] +.'; sub is123 { @_ ~~ [ 1 .. 3 ] }
Output:
The variable is [1 .. 3].
In reply to Re: Test if list is range
by Kenosis
in thread Test if list is range
by DeepThought
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |