Home: Perl Programming Help: Beginner:
split record in MM/DD/YYYY format



casa3311
Deleted

Mar 7, 2001, 11:39 AM


Views: 520
split record in MM/DD/YYYY format

This may not be a beginner question, but I am less than 6 months new to Perl. I have a date that is coming from a form in MM/DD/YYYY format (ex. 3/7/2001) and I need to write it to a database in, for example, 03-MAR-2001 format. This date can also be null, so it might come in as MM/DD/YYYY in which case, I set the value to NULL otherwise I convert it to the proper format. I understand how to use the split command if you are separating the fields with a space, or a comma, or or any other character, but how do you split a record that is using the / as the field separator???



wickedxter
User

Mar 7, 2001, 4:58 PM


Views: 515
Re: split record in MM/DD/YYYY format

ok i got it

this is a sample code of what i did to split it

$date = "03/07/2001";
print "$date
";
print "
";
($m, $d, $y) = split(/\//,$date);
print "$m $d $y";






Jean
User


Mar 11, 2001, 12:48 AM


Views: 507
Re: split record in MM/DD/YYYY format

Just a remark:

"\n" can be used as a new line character.
Use
print "abcde\n";
instead
print "abcde
";




Jean Spector
QA Engineer @ Extent Technologies, Ltd.
mage@lycosmail.com