in reply to Array Problem

Well, if the log entries are consistant, why not just a simple split?

#!/usr/bin/perl -w use strict; my $calog = "/var/log/ca/ca.log"; my $line; my @certs = (); open LOG, "$calog" or die "Can't open $calog: $!\n"; while ($line = <LOG>) { my @entry = split ' ', $line; $certs[@certs] = $entry[7]; } print @certs;

Update: Quick Fix thanks to blakem.

Replies are listed 'Best First'.
Re: Re: Array Problem
by blakem (Monsignor) on Sep 14, 2001 at 04:50 UTC
    $certs[$#certs] = $entry[7];

    Should be one of the following:

    $certs[@certs] = $entry[7]; # OR push(@certs,$entry[7]);
    As you wrote it, $entry[7] would simply overwrite the last element in the array instead of tacking itself onto the end.

    -Blake