wire [130 : 0] dgrs;
wire [130 : 0] dgrs;
wire [130 : 0] dgrs;
wire [130 : 0] grs;
wire [130 : 0] grs;
wire [130 : 0] grs;
####
wire [130 : 0] dgrs_1;
wire [130 : 0] dgrs_2;
wire [130 : 0] dgrs_3;
wire [130 : 0] grs_1;
wire [130 : 0] grs_2;
wire [130 : 0] grs_3;
####
#!/usr/bin/perl
use strict;
use warnings;
my $file = 'xyz.txt';
my %seen = ();
{
local @ARGV = ($file);
local $^I = '.bac';
while(<>){
$seen{$_}++;
next if $seen{$_} > 1;
print;
}
}
print "finished processing file.";
my $target_file = 'xyz.txt';
{
open my $in_fh, '<', $target_file or die "Cannot open input file: $!\n";
flock $in_fh, LOCK_EX | LOCK_NB or die "Cannot obtain a lock on $target_file: $!\n";
my $temp_out = File::Temp->new(TEMPLATE => "$0-$$-XXXXX");
while ( my $line = ) {
if ( $line =~ /^dgrs/ ) {
for my $x (1..3) {
print "dgrs$x\n";
}
}
else {
print $line;
}
}
close $in_fh or die "Failed to close $target_file. Aborting. $!\n";
$temp_out->flush;
eval {
move($temp_out->filename, $target_file);
} or do {
warn "Failed to swap $temp_out into $target_file: $!\n";
# There may need to be more cleanup here, or possibly a die is more appropriate.
};
}