Michael Alipio wrote:
> Hi,

Hello,

> I wanted to extract the start time of a particular logfile (located at the
> beginning of the file, and also the end time which is located at the end
> of the logfile.
> 
> Is there any way to do this in perl without using "head" or "tail" commands?

##  UNTESTED

use Fcntl ':seek';

my $logfile = 'file.log';

open my $fh, '<', $logfile or die "Cannot open '$logfile' $!";

my ( $start_time ) = <$fh> =~ /(regex to extract logfile time)/;

seek $fh, -1024, SEEK_END or die "Cannot seek on '$logfile' $!";

my $end_time = ( <$fh> =~ /(regex to extract logfile time)/g )[ -1 ];


> By the way, can you point me somewhere perhaps a perl function that lets
> you create directories?

perldoc -f mkdir



John
-- 
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order.       -- Larry Wall

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to