C_WREN,Group1
CAL_CLK,Group1
RX_IBIAS_2_25U[4:0],Group3
REF_RATE[9:0],Group3
AVD0,Group4
SIDDQ,Group7
####
#!/usr/bin/perl
use strict;
use warnings;
foreach my $infile_name (@ARGV)
{
&mainCSV($infile_name);
}
exit;
####
C:\Steve\Dev\PerlMonks\P-2013-11-23@0553-Hash>testhash.pl test.csv
Global symbol "$infile_CSV" requires explicit package name at C:\Steve\Dev\PerlMonks\P-2013-11-23@0553-Hash\testhash.pl line 16.
Global symbol "$infile_CSV" requires explicit package name at C:\Steve\Dev\PerlMonks\P-2013-11-23@0553-Hash\testhash.pl line 16.
Global symbol "$outfile_CSV" requires explicit package name at C:\Steve\Dev\PerlMonks\P-2013-11-23@0553-Hash\testhash.pl line 40.
Global symbol "$outfile_CSV" requires explicit package name at C:\Steve\Dev\PerlMonks\P-2013-11-23@0553-Hash\testhash.pl line 40.
Global symbol "$outfile_CSV" requires explicit package name at C:\Steve\Dev\PerlMonks\P-2013-11-23@0553-Hash\testhash.pl line 43.
Execution of C:\Steve\Dev\PerlMonks\P-2013-11-23@0553-Hash\testhash.pl aborted due to compilation errors.
####
sub mainCSV
{
# Open the CSV input file
open (my $infile_CSV1, '<', "$infile_CSV") or die "Unable to open $infile_CSV: $!\n";
####
sub mainCSV
{
my ($infile_CSV, @extraStuff) = @_;
if (!defined $infile_CSV) { $infile_CSV = ''; }
# Open the CSV input file
open (my $infile_CSV1, '<', "$infile_CSV") or die "Unable to open $infile_CSV: $!\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";
####
# Open the output file and save hash in $outfile_RX_CSV
my $outfile_CSV = &getOutputFilename($infile_CSV);
open (my $outfile2, '>', "$outfile_CSV") or die "Unable to open $outfile_CSV: $!\n";
####
sub getOutputFilename
{
my ($inputFilename, @extraStuff) = @_;
if (!defined $inputFilename) { $inputFilename = ''; }
my @inputElements = split /\./, $inputFilename;
my $inputExtension = pop @inputElements;
if (!@inputElements)
{
push @inputElements, $inputExtension;
$inputExtension = 'csv';
}
$inputElements[-1] .= '_RX';
my $outputFilename = join '.', (@inputElements, $inputExtension);
return $outputFilename;
}
####
C:\Steve\Dev\PerlMonks\P-2013-11-23@0553-Hash>perl testhash2.pl test.csv
Use of uninitialized value $_ in scalar chomp at testhash2.pl line 25, <$infile_CSV1> line 1.
Use of uninitialized value $_ in scalar chomp at testhash2.pl line 25, <$infile_CSV1> line 2.
Use of uninitialized value $_ in scalar chomp at testhash2.pl line 25, <$infile_CSV1> line 3.
Use of uninitialized value $_ in scalar chomp at testhash2.pl line 25, <$infile_CSV1> line 4.
Use of uninitialized value $_ in scalar chomp at testhash2.pl line 25, <$infile_CSV1> line 5.
Use of uninitialized value $_ in scalar chomp at testhash2.pl line 25, <$infile_CSV1> line 6.
Number of Pins: 6
Undefined subroutine &main::Dumper called at testhash2.pl line 45, <$infile_CSV1> line 6.
####
while (my $line = <$infile_CSV1>)
{
chomp;
$line =~ s/\s*\z//;
####
while (my $line = <$infile_CSV1>)
{
chomp $line;
$line =~ s/\s*\z//;
####
#!/usr/bin/perl
use strict;
use warnings;
foreach my $infile_name (@ARGV)
####
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
foreach my $infile_name (@ARGV)
####
C:\Steve\Dev\PerlMonks\P-2013-11-23@0553-Hash>perl testhash2.pl test.csv
Number of Pins: 6
Stored 6 list of pins in test_RX.csv file.
AVD0 => ARRAY(0x4bde48)
SIDDQ => ARRAY(0x4cacf8)
C_WREN => ARRAY(0x4e8f18)
CAL_CLK => ARRAY(0x4a8468)
REF_RATE[9:0] => ARRAY(0x4bdd10)
RX_IBIAS_2_25U[4:0] => ARRAY(0x4bdce0)
####
$hash{$key_CSV} = \@array_CSV;
####
my $key_CSV = shift @array_CSV;
if ($hash{$key_CSV})
{
warn "Duplicate key '$key_CSV'";
};
$hash{$key_CSV} = \@array_CSV;
####
my ($key_CSV, $value_CSV, @extraStuff) = @array_CSV;
if ($hash{$key_CSV})
{
warn "Duplicate key '$key_CSV'";
};
$hash{$key_CSV} = $value_CSV;
####
C:\Steve\Dev\PerlMonks\P-2013-11-23@0553-Hash>perl testhash2.pl test.csv
Number of Pins: 6
Stored 6 list of pins in test_RX.csv file.
AVD0 => Group4
SIDDQ => Group7
C_WREN => Group1
CAL_CLK => Group1
REF_RATE[9:0] => Group3
RX_IBIAS_2_25U[4:0] => Group3
####
chomp $line;
$line =~ s/\s*\z//;
my @array_CSV = split /,/, $line;
my ($key_CSV, $value_CSV, @extraStuff) = @array_CSV;
if ($hash{$key_CSV})
{
warn "Duplicate key '$key_CSV'";
};
$hash{$key_CSV} = $value_CSV;
####
C:\Steve\Dev\PerlMonks\P-2013-11-23@0553-Hash>perl testhash2.pl test.csv
Number of Pins: 6
Stored 6 list of pins in test_RX.csv file.
AVD0 => Group4
SIDDQ => Group7
C_WREN => Group1
CAL_CLK => Group1
REF_RATE[9:0] => Group3
RX_IBIAS_2_25U[4:0] => Group3