I currently have the following piece of code to delete numbers from an array:
@greparray = grep(!/$stringdelete/, @inputarray);
The user specifies the numbers to delete on the command line. I'm using Getopt::Long so $stringdelete becomes the numbers e.g. they type -o 100 110 200. I have a few small problems:
1) I need to allow the user to delete a range of numbers e.g. by typing 100-200 any number inbetween that range will be deleted. I've tried a number of things like 100..200 but i'm stuck.
2)I would also like the user to be able to type >100 and all numbers above 100 will be deleted. Or they can type <100. I've tried putting >100 but that doesn't work.
3) Also, a really small question I should know how to do. At the moment the user has to put the numbers in double quotes "100 200". Otherwise it will only delete the first number.
It's not a big problem but I'm thinking that my user might forget the double quotes every now and again and then wonder why it hasn't worked. How do I add a " at the start and end of the string so the user doesn't have to.
Start Free Trial