Front page | perl.beginners |
Postings from April 2002
Spliting a string on "."
Thread Next
From:
Rajeev Rumale
Date:
April 2, 2002 20:46
Subject:
Spliting a string on "."
Message ID:
001d01c1daca$182aed80$9f01a8c0@Rajeev
Hi I have a sub routine listed at end. I request you to kindly tell me the mistake in this.
I am not able to split the the string "12.12.1975" on the "." seprator.
also when I try ot repace the dot with some other variable useing the statement $date=~s/./#/g;
It is repalcing all the charcters including the dots.
I wonder if we need to use any specail technique to use split or regs with "."
regards
Rajeev
#########################################################################
# #
# Converting the date into sql date format #
# #
#########################################################################
sub sqlDate{
my $date = shift;
#$date=~s/./#/g;
#--- rearranging the date months and year values into sql format yyyy/mm/dd.
my ($day, $month, $year) = split(".",$date);
my $sqldate = "$year/$month/$day";
&ds("date = $date", "$day, $month, $year", " sqldate = $sqldate");
return $sqldate;
}
Thread Next
-
Spliting a string on "."
by Rajeev Rumale