#!/usr/bin/perl use strict; use warnings FATAL => 'all'; my $str = "DATETIME 09:59:11"; my $time = (split " ", $str)[1]; my ($h,$m,$s) = split ':', $time; print $h;