> 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";

$ts = "200212091500";

$ts =~ s/(\d+)\d{4}/$1/;

print "$ts\n";


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

Reply via email to