#!/usr/bin/perl use strict; use warnings; my $done = 0; while (not $done) { print "\n\nPlease type the numbers of the messages that are to be released (n-n and n \nare allowable, A for all): "; my $input = ; chomp($input); foreach my $range (split(/,/, $input)) { $range =~ s/\s*//g; # Remove whitespace if ($range =~ /[Aa]/) { # All messages, assume we're done print "All messages!\n"; # ... $done = 1; } elsif ($range =~ /(\d+) # Single message number (?: # Can be followed by a dash with a -(\d+) # second number (which denotes the end )? # of the range /x) { if ($1 and $2) { print "Message range: #$1 to #$2\n"; # ... } else { print "Single message: #$1\n"; # ... } } elsif ($range =~ /[Qq]/) { # Give the user the option to quit. $done = 1; } else { # Wrong input print "Wrong input!\n"; # ... } } }