I don't understand your description of your problem or what you want to achieve, so I am guessing here...
I guess you are having difficulty with the output to $outfile at the end of sub mainCSV and that you want "pin" and "related_input : " to be followed by the key and corresponding values from your hash.
If my guess is correct, there are a couple of problems:
The values of %hash are references to arrays, so I don't think the grep just after "Continue print with corresponding hash key and value for AsyncIn" does what you want.
Then, iterating a loop for the number of times there is a particular value in the hash doesn't make it easy to access the keys or values of the hash.
So, you need a different approach, and it is not clear from what you have presented exactly what you are trying to achieve.
Here is something for you to consider but, again, it is only a guess as to what you want and it is untested:
# Continue print with corresponding hash key and value for AsyncIn
+NoTimingArc
# Find the keys for which AsyncInNoTimingArc is in the value array
my @keys = grep {
my @array_CSV = @{$hash{$_}};
grep { $_ eq 'AsyncInNoTimingArc'} @array_CSV;
} keys %hash;
open (my $outfile1, '>>', "$outfile") or die "Unable to open $outf
+ile: $!\n";
foreach my $key (@keys) {
# Get the values corresponding to this key
my $values = join(', ', @{$hash{$key}});
print <<" EOF";
pin(\"$key => {$values}\") {
direction : input ;
capacitance : $DIN_CAP ;
}
internal_power(pwr_arc){
values(\"$DIN_PWR_ARC\");
related_input : \"$key => {$values}\" ;
}
EOF
}
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.