Your code is pretty awful, as is your explanation of what you want to do. But as you have put in some effort....

It is hard to know where to begin but I suggest you have a look at New Monks. Here is some code you should be able to get working much easier. It does roughly what you want (I think)

#!/perl/bin -w use strict; # do you opens like this. no hard coded names. $! contains error messa +ges if # the open fails so print out perls helpful message # my $log = "tasco2.log"; # open LOG, $log or die "Can not open $log, Perl says the reason is $! +\n"; # define model types in a hash lookup table my %modhash = ( 9 => "no connect", 18 => "21000bps", 20 => "V34", 28 => "29333bps", 31 => "33333bps", 34 => "V90 digital", 39 => "44000bps", 40 => "45333bps", 43 => "49333bps", 44 => "50666bps", 45 => "V92 PCM Upstream", ); my $sessidlast = 0; my $newsession = 0; my $modtypelast = ''; while (my $line = <DATA> ) { chomp $line; my @temp = split /\s*=\s*/, $line; if ($temp[1] > 100) { # we have a session id my $sessid = $temp[1]; do { $newsession = 0; next } if $sessid == $sessidlast; $sessidlast = $sessid; $newsession = 1; print "\n$sessid\t"; } else { # we have a modtype next unless $newsession; # skip if we don't have a new session my $modtype = $temp[1]; next if $modtype == $modtypelast; $modtypelast = $modtype; print get_modtype($modtype), "\t"; } } sub get_modtype { my $modtype = shift; if (defined $modhash{$modtype}) { return $modhash{$modtype} . "\t"; } else { return "Unknown modtype $modtype!\t"; } } __DATA__ x.x.nas.6.9.1.1.40.1001 = 1134468706 x.x.nas.6.9.1.1.14.1001 = 9 x.x.nas.6.9.1.1.13.1001 = 16 x.x.nas.6.9.1.1.12.1001 = 16 x.x.nas.6.9.1.1.40.1001 = 1134468706 x.x.nas.6.9.1.1.14.1001 = 34 x.x.nas.6.9.1.1.13.1001 = 19 x.x.nas.6.9.1.1.12.1001 = 30 x.x.nas.6.9.1.1.40.1001 = 1134485731 x.x.nas.6.9.1.1.14.1001 = 45 x.x.nas.6.9.1.1.13.1001 = 16 x.x.nas.6.9.1.1.12.1001 = 16 x.x.nas.6.9.1.1.40.1001 = 1134485733 x.x.nas.6.9.1.1.x.x = 9

cheers

tachyon

s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print


In reply to Re: executing the following lines of a script if the value of an elemnt in an array changes by tachyon
in thread executing the following lines of a script if the value of an elemnt in an array changes by splatohara

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.