in reply to Re: Delete lines if matched expression
in thread Delete lines if matched expression

sry, but what i wish to do is to filter out whatever the pins mentioned inside the waiver file, from the input which is the report file, the condition is if the width matched, and the height in waiver file is greater or equal to the height in input report file, the pins and its following information in report file will be deleted, as a sign it is waived, but the problem now is my script didnt delete the pins and the following information, even they are matched. So anyone of you have any ideas?

  • Comment on Re^2: Delete lines if matched expression

Replies are listed 'Best First'.
Re^3: Delete lines if matched expression
by poj (Abbot) on Jul 26, 2017 at 05:44 UTC

    You can't have 2 hash keys as 'es' so you need a 2nd level to your %identifier hash
    eg $identifier{$pins2}{$w2} = $h2

    #! /tools/perl/5.8.8/linux/bin/perl use strict; use warnings; use Data::Dumper; # Source script my $report = $ARGV[1] || 'report.txt' ; my $waiver = $ARGV[3] || 'waiver.csv'; my $result = $ARGV[5] || 'result.txt'; # Set up a hash to receive the information my %identifier = (); # Read the violations file into the hash open my $filter, '<', $waiver or die "Could not open $waiver : $!"; while (my $vline = <$filter>) { next unless $vline =~ /\S/; #skip blank lines $vline =~ s/^\s+//; # trim leading spaces my ($pins2, $w2, $h2) = split /,/, $vline; $identifier{$pins2}{$w2} = $h2; } print Dumper \%identifier; # Read input file line by line and compare 2 files open my $input, '<', $report or die "Could not open $report : $!"; open my $output, '>', $result or die "Could not open $result : $!"; my $header = 1; while (my $wline = <$input>){ # skip checking the heading text if ($header == 1){ print $output $wline; $header = 0 if ($wline =~ /-------/); next; } # delete the contents if matched # undef is leading space my (undef,$pins1, $nets, $w1, $h1, $slack) = split /\s+/, $wline; if (exists $identifier{$pins1}{$w1} && $identifier{$pins1}{$w1} >= $h1) { # skip matched line print "DELETED $wline"; } else { print $output $wline; } } close $filter; close $input; close $output;
    poj