http://www.perlmonks.org?node_id=1054637


in reply to Formatting STDIN for date format

AshleyJordan:

You can't format STDIN, you can only look at what came in and see if it matches what you want. You can do it something like this:

# Get a line from the user (or file if redirected) my $line = <STDIN>; while ($line !~ /regex to check input/) { # input didn't match regex, so tell the user and get another line +of data print "Sorry, I don't understand that, please enter the date like: + DD-MM-YYYY\n"; $line = <STDIN>; } ... code that uses properly formatted date ...

...roboticus

When your only tool is a hammer, all problems look like your thumb.