Hello Can you help me rewrite this part of code in different way. Here I want to open the "counters.conf" file in which I have the OID's (values like this): 1,10e6 2,5e6 3,100e6 4,1e9 50,10 55,124 I used hash function. Here I want to slipt the rows and if I call for example 55, it must return the value of 124. for example I can also use this :
my ($row1, $row2)=split/,/,$row; $values{$row1}=$row2;
How can I write this code in a different way? Code:
my $filename = ('/tmp/A1/counters.conf'); open(my $fh, '<:encoding(UTF-8)', $filename) or die "Could not open file '$filename' $!"; my %values=(); my $t=time(); while (my $row = <$fh>) { chomp $row; my ($row1, $row2) = split /\s*=\s*/,$row; $values{$row1}=$row2; } while (my ($n,$m) = each %values) { if ($OID2-1==$n){ my $var=$m*$t; $request->setValue(ASN_COUNTER,$var); } }

In reply to using change directory within perl script by Anonymous Monk

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.