in reply to regex to an array , is there a better way to do this
Your input happens to be valid Perl syntax, so if you know exactly that your input is in this format (and contains no evil things), you can simply write:
my @array = eval $number;
Or you could simplify your code a bit:
for (my $i=$1;$i<=$2;$i++){ push @arraydigit, $i; }
Can be written shorter and clearer as
push @array, $1..$2;
There's really no point in having @array and @arraydigit separate.
|
---|
In Section
Seekers of Perl Wisdom