I would like to accept a slice argument (string) from the command line that then may be used to select a subset of columns from an input file. Doing this directly apparently does not work (error is that argument (to slice) is not numeric).

Here are some more details.

I use GetOptions to accept a command line string such as 1..5,10..15 (i.e. $col_slice = "1..5,10..15). Next, once I've got a list of items (e.g. words on a line), I would like to simply get the subset (if specified):

if ( $col_slice ) { @words = $words[$col_slice]; }

I'm sure this is "easy" if you know the trick. I don't know the trick.

What I want is to be able to accept a string and (somehow) convert this into a slice argument (without parsing the thing myself). Your eval didn't do this.

My "first language" is C, so I was hoping there was something equivalent to printing a format string (e.g. for printf() ) that might do the conversion for me (I wasn't thinking error checking to make sure the slice syntax was reasonable.. but maybe?). I still think that Perl likely has a means to do what I'm hoping for.