in reply to Re^2: Last value update is only happening instead of all.
in thread Last value update is only happening instead of all.
Read File_2 and store the values in a hash. You can then copy File_1 inserting the new lines as required. For example
poj#!/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;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Last value update is only happening instead of all.
by anirbanphys (Beadle) on Aug 26, 2018 at 09:09 UTC |