Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Formatting STDIN for date format

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


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.


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://1054637]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (9)
As of 2014-08-28 11:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (259 votes), past polls