#!/usr/bin/perl use strict; use warnings; use diagnostics; use Data::Dumper; # Define Files and assign strings my $DIN_CAP = "0.0005"; my $DIN_PWR_ARC = "0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000,0.000000"; sub mainCSV { # Open the CSV input file open (my $infile_CSV1, '<', "$infile_CSV") or die "Unable to open $infile_CSV: $!\n"; my %hash = (); my $hash_ref = {}; while (my $line = <$infile_CSV1>) { chomp; $line =~ s/\s*\z//; my @array_CSV = split /,/, $line; my $key_CSV = shift @array_CSV; if ($hash{$key_CSV}) { warn "Duplicate key '$key_CSV'"; }; $hash{$key_CSV} = \@array_CSV; } # Explicit scalar context my $size = scalar keys %hash; # Prints Number of Pins (Hash size...) print "Number of Pins: $size\n"; # Open the output file and save hash in $outfile_RX_CSV open (my $outfile2, '>', "$outfile_CSV") or die "Unable to open $outfile_CSV: $!\n"; print $outfile2 Dumper(\%hash); close $outfile2; print "Stored $size list of pins in $outfile_CSV file.\n"; ########ERROR concentrated code################ # Continue print with corresponding hash key and value for AsyncInNoTimingArc my $count = grep { $_ == {AsyncInNoTimingArc} } values %hash; for ($count ; $count >= 0; $count--) { open (my $outfile1, '>>', "$outfile") or die "Unable to open $outfile: $!\n"; print ("\n pin($key_CSV) {\n direction : input ;\n capacitance : $DIN_CAP ;\n }\n \n internal_power(pwr_arc){\n values("$DIN_PWR_ARC");\n related_input : "$key_CSV" ;"\n); } } ##############ERROR#################### mainCSV ();