We don't bite newbies here... much | |
PerlMonks |
Formatting STDIN for date formatby Ashley Jordan (Novice) |
on Sep 18, 2013 at 08:47 UTC ( [id://1054616]=perlquestion: print w/replies, xml ) | Need Help?? |
Ashley Jordan has asked for the wisdom of the Perl Monks concerning the following question:
Hello Guys,
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
Back to
Seekers of Perl Wisdom
|
|