waytoperl has asked for the wisdom of the Perl Monks concerning the following question:
Hello Master,
I'm stuck with these code in which im having trouble printing data with referring hash values. Can anyone help me. It'll be helpful.
#!/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.0000 +00,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 $o +utfile_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 AsyncIn +NoTimingArc 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 ();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: why i cant print reading hash table?
by Athanasius (Archbishop) on Nov 20, 2013 at 04:05 UTC | |
by GrandFather (Saint) on Nov 20, 2013 at 05:06 UTC | |
by Athanasius (Archbishop) on Nov 20, 2013 at 06:21 UTC | |
by GrandFather (Saint) on Nov 20, 2013 at 07:09 UTC | |
by waytoperl (Beadle) on Nov 20, 2013 at 13:10 UTC | |
by VincentK (Beadle) on Nov 20, 2013 at 17:34 UTC | |
|
Re: why i cant print reading hash table?
by roboticus (Chancellor) on Nov 20, 2013 at 04:05 UTC |