Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Removing charactors from a string 1

Status
Not open for further replies.

davef101

MIS
Mar 3, 2006
34
GB
i have a string:

"16:32:20 19/09/2006"

and i want to remove the 19/09/2006 into seperate strings, $day,$mon,$year ...

anyone ?

Thanks.
 
Code:
my $string = '16:32:20 19/09/2006';

my ( $day, $month, $year ) = ( split /[ \/]/, $string )[2..4];

And if you want the time too:
Code:
my $string = '16:32:20 19/09/2006';

my ( $hour, $minute, $second, $day, $month, $year ) = split /[ \/:]/, $string;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top