You can try something like this:

if($ts =~ /^(\d{8})/){ #get eight sequential digit chars
        print "$1\n";
}else{
        print "Time stamp format invalid!\n";
}

-----Original Message-----
From: Jose Malacara [mailto:[EMAIL PROTECTED]]
Sent: Thursday, December 12, 2002 4:26 PM
To: [EMAIL PROTECTED]
Subject: stripping characters from a variable


Hello. I have a logfile in which every message begins with a timestamp (ex.
- 20012091500). I would like to be able to remove the last 4 characters
(1500) off each of these to derive the date only (2001209). It works by
chopping of each character individually, but I would like to know if there
is a cleaner way to do this via regex or possibly by chopping multiple
characters off at once.

$ts = "200212091500";
chop ($ts);
chop ($ts);
chop ($ts);
chop ($ts);

print "$ts\n";


Thanks,
Jose


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to