I have a script reading from a file that should return a string when it comes across a certain value in an array created in the script using data from the file but it does not seem to be working as it should an array is created from a file containing below
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 = 1134485731 x.x.nas.6.9.1.1.x.x = 9 #!/perl/bin open (In,"tasco2.log") or die ("can not open file "); open (Out,">tasfinrpt.txt") or die ("cannot open output file maybe you + should create one"); #print "\n\n Session id Modulation \n\n"; #$firstlineFlag = 1; $sessid= 100; $modtyplast =1; $modtypv34 = "V34"; my $sessidlast ; while (my $line = ) { @temp = split (/[=]/, $line); if ($temp[1] > $sessid) { $sessid =$temp[1]; chomp $sessid; print "\n $sessid "; } if ($temp[1] < 100){ $modtyp = $temp[1]; } if ($modtyp ne $modtyplast&&($sessid ne $sessidlast)){{ print " "; if ($modtyp == 9){ print "no connect"; # goto $breakp; } if ($modtyp == 20) { print "V34"; } elsif($modtyp == 34){ print " V90 digital"; } if ($modtyp == 45){ print " V92 PCM Upstream"; } elsif ($modtyp == 44){ print " 50666bps"; } # elsif ($modtyp == 28){ # print " 29333bps\n "; # } elsif ($modtyp == 31){ print " 33333bps "; } elsif ($modtyp == 18){ print "21Kbps "; } # elsif ($modtyp == 21){ # print " 28Kbps"; # } elsif ($modtyp == 43){ print " 49333\n"; } elsif ($modtyp == 39){ print "44Kbps\n"; } elsif ($modtyp == 40){ print "45333bps"; } } breakp: $modtyplast = $modtyp; $sessidlast = $sessid ; # } }
the results are as follows......I don't see why the last two values can not have a string returned for them
1134468706 no connect 1134485731 1134502756
The idea of the script is to create an array for each line in the file and then depending on whether is comes a cross an a different value for an element it either executes the next few lines of the script or reads in the next line of the file etc etc etc I have tried to break from the script if it came across the the same value and return to the top but could not get it working properly any ideas thanks /splat

Edit davorg: Added code tags


In reply to 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.