Is there an efficiency issue with the code? How many times too slow is the code?

Efficiency aside, there is plenty of scope for improving the code. As a first step use strictures (use strict; use warnings;). Then factor out the large lumps of repeated code into a sub. With a few other changes something like the following results:

use strict; use warnings; use Time::Local; my @data = <DATA>; my @component = qw(HPOvXpl HPOvSecCo HPOvBbc HPOvSecCC HPOvCtrl HPOvDe +pl HPOvConf HPOvPacc HPOvPerfMI HPOvGlanc HPOvPerfAgt HPOvPerlA HPOvAgtLc HPOvEaAgt HPOvOpsAgt ); install ($_) for @component; sub install { my ($component) = @_; my @cmpstartinstall = grep {/Installing the $component package/} @ +data; my @startime = map {/^\[(.+?)\]/; $1;} @cmpstartinstall; my $cmpstart = asEpoch ($startime[0]); my @endtime = map {/^\[(.+?)\]/; $1;} grep {/The component package $component installed successfully +/} @data; my $cmpend = asEpoch ($endtime[0]); return if ! defined $cmpstart || ! defined $cmpend; my $diff = $cmpend - $cmpstart; print "$component: $diff\n"; } sub asEpoch { my ($time) = @_; return if ! defined $time; return if $time !~ /^([\d]+)\/(\d+)\/(\d+)\s+(\d+):(\d+):(\d+)/; my ($mon, $mday, $year, $hour, $min, $sec) = ($1, $2, $3, $4, $5, +$6); $mon--; $year += 2000 if $year < 100; return timelocal ($sec, $min, $hour, $mday, $mon, $year); } __DATA__ ... [12/21/10 18:39:22] [oasetup] [oasetup] [INFO] Installing the HPOvXpl +package... ... [12/21/10 18:39:24] [oasetup] [oasetup] [INFO] The component package H +POvXpl installed successfully [12/21/10 18:39:24] [oasetup] [oasetup] [INFO] Installing the HPOvSecC +o package... ... [12/21/10 18:39:24] [oasetup] [oasetup] [INFO] The component package H +POvSecCo installed successfully

Prints:

HPOvXpl: 2 HPOvSecCo: 0

Note that the desired component is passed into the install sub and the entire log is processed for each call to install. That could easily be improved on, but significant changes would be needed to the code.

True laziness is hard work

In reply to Re: Need to optimize my perl code by GrandFather
in thread Need to optimize my perl code by achak01

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.