Hi,
please take this as a starting point:
#!/usr/bin/env perl use strict; use warnings; my $line = <STDIN>; my $day; my $month; my $year; chomp($line); if($line =~ /^([0-3][0-9])-([01][0-9])-([0-9]{4})$/) { $day = $1; $month = $2; $year = $3; } else { die "ERROR: Wrong date format, please provide DD-MM-YYYY: $line"; } print "Date is: $year-$month-$day\n";
You have to add code to check whether the date is a valid date.
McA
In reply to Re: Formatting STDIN for date format
by McA
in thread Formatting STDIN for date format
by Ashley Jordan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |