in reply to Declare array with range operator
Doing the below initialization doesn't get my desired result.
You're essentially doing @array = ( "string" ); </C> The operator, is double quotes "", you want to use the range operator, so
my $range = "1..3,7..9"; my @array; while($range =~ /(\d+)\.\.(\d+)/g ){ my( $left , $right ) = ( $1, $2 ); push @array, $left .. $right; } print "@array\n"; __END__ 1 2 3 7 8 9
"1..3,7..9" is data and 1..3,7..9 is code
|
|---|