in reply to Test if list is range
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].
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Test if list is range
by DeepThought (Initiate) on Oct 01, 2012 at 10:09 UTC |