Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
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


Comment on Re: Formatting STDIN for date format
Download Code

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 perusing the Monastery: (8)
As of 2015-07-03 16:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (53 votes), past polls