I have a Perl application that takes from command line an input as:
application --fields 1-6,8
I am required to display the fields as requested by the user on command line.
I thought of substituting '-' with '..' so that I can store them in array e.g.
$str = "1..15,16" ;
@arr2 = ( $str ) ;
@arr = ( 1..15,16 ) ;
print "@arr\n" ;
print "@arr2\n" ;
The problem here is that @arr works fine ( as it should ) but in @arr2 the entire string is not expanded as array elements.
I have tried using escape sequences but no luck.
Can it be done this way?