Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Re: Formatting STDIN for date format

by roboticus (Chancellor)
on Sep 18, 2013 at 11:07 UTC ( #1054637=note: print w/ replies, xml ) Need Help??

in reply to Formatting STDIN for date format


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 ...


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

Comment on Re: Formatting STDIN for date format
Download Code

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2015-11-27 02:18 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (712 votes), past polls