Read File_2 and store the values in a hash. You can then copy File_1 inserting the new lines as required. For example

#!/usr/bin/perl use strict; use warnings; #use Data::Dumper; open FINAL1,'<','File_2.txt' or die "Can not open Input File_2 : $!"; my %max_trans = (); while (<FINAL1>){ next unless /\S/; # skip blanks chomp; my ($pin,$value) = split ',',$_; $max_trans{$pin} = $value; } close FINAL1; #print Dumper \%max_trans; open OUTFILE,'>','File_3.txt' or die "Can not open Output File_3 : $!"; open IFILE,'<','File_1.txt' or die "Can not open Input File_1 : $!"; my $pin_name; while ( my $line4 = <IFILE>){ print OUTFILE $line4; if ($line4 =~ m/\s*pin\s*\(([^)]+)/g){ $pin_name = $1; $pin_name =~ s/"//g; print "$pin_name\n"; } if ( $line4 =~ m/^\s*direction\s*:\s*output/g){ if (exists $max_trans{$pin_name}){ print OUTFILE " max_transition : $max_trans{$pin_name};\n"; } } } close IFILE; close OUTFILE;
poj

In reply to Re^3: Last value update is only happening instead of all. by poj
in thread Last value update is only happening instead of all. by anirbanphys

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.