Ashley Jordan has asked for the wisdom of the Perl Monks concerning the following question:
Relativity new to Perl so i will go ahead and try to explain what i am trying to do etc!
I am trying to configure the input to only accept DD-MM-YYYY Format, but i also need to have the day, month and year as variables allowing me to use those variables in a mysql command.
At the moment i have this, it most likely is completely wrong, but if you could give guide me that would be great;
(<STDIN> =~$day/(\d{2})-$month(\d{2})-$year(\d{4})/) { $date = <STDIN>; } else { print "Invalid date, not in DD-MM-YYYY Format\n"; }
My main worry of the above is that the variables are not in the correct place ? Heres an example of the mysql command ( just to let you know where the variables will be used )$sql = "UPDATE table SET day='$day' month='$month' year='$year' WHERE field='$variable' AND field='$variable'\G"
I Have changed the names of the fields/table/variables in the mysql to just a generic example. i am just looking for assistance in regards to the 3 fields below;
The three fields in the mysql table i would like to update are as follows;
day
month
year
Any help would be great,
Thanks in advance!
Ashley
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Formatting STDIN for date format
by McA (Priest) on Sep 18, 2013 at 09:28 UTC | |
|
Re: Formatting STDIN for date format
by roboticus (Chancellor) on Sep 18, 2013 at 11:07 UTC | |
|
Re: Formatting STDIN for date format
by kcott (Archbishop) on Sep 19, 2013 at 07:19 UTC | |
|
Re: Formatting STDIN for date format
by boftx (Deacon) on Sep 19, 2013 at 06:09 UTC |