Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Formatting STDIN for date format

by McA (Priest)
on Sep 18, 2013 at 09:28 UTC ( #1054628=note: print w/ replies, xml ) Need Help??


in reply to Formatting STDIN for date format

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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1054628]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2016-06-30 21:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred method of making French fries (chips) is in a ...











    Results (403 votes). Check out past polls.