Hello Monks,
I want to do something that I am not sure I am able to do, so any help would be appreciated.
A brief summary of what I think I want to do:
I have a file I want to load into a hash table, this is just a plain csv file, with either a BLANK or an X in its fields.
Why? I have a script that needs to determine if the hash field is something I want to turn off. I could use a multi dimenisonal array, but it would be more clear to other developers if I could use a Hash to represent the name of what I want to turn off.
I tried to create and initialize the hash table like this:
%HashTempRec =
(
'Name' => '',
'AlarmConsistencyMgr' => '',
'AlarmForwarder' => '',
'AlarmForwarderServer' => '',
'alert_publisher' => '',
'AnalogGatewayMain' => '',
'AssetTracking' => '',
'CallerPosition' => '',
);
There are more fields, but for readability I've removed them.
So now when I read the csv file, ace.dll,,,X,X,,X,X,X,X,X,X,X,,,,,,,X,X,X,,,,X,,,,,,,,X,,,,,X,,, -- there are more records, but I want to keep this post reasonable.
I want to populate the Hash Table with the elements from this file.
So I tried to do
for each $item (@Dependency)
{
@HashTempRec = $item;
}
This obvisuouly fails and I don't know where to go from here.
Is there a way to load a hash table is this fashion?
--Hash table definiion here--
$Test1 = "D:\\Profiles\\p57571\\Desktop\\Book3.csv";
if( -e $Test1)
{
print "Opening $Test1\n";
open(PACKAGEINPUT, "<$Test1");
my(@lines) = <PACKAGEINPUT>;
foreach $temp(@lines)
{
chomp $temp;
if( $temp =~ m/\S/ig)
{
#find the extension
my $fileExt = substr( $temp, -3 ) ||'';
#this searches for exe's then any coresponding dlls
+
if( $fileExt eq 'exe' )
{
foreach my $element( split /,/, $temp)
{
if( $element =~ m/\.exe/)
{
#print "element = $element\n";
}
}
}
else
{
print "temp = $temp\n";
%HastTempRec = $temp;
}
}
}
}
else
{
print "$Test1 does not exist\n";
}
thanks in advance.
I hope my question and reasons why are clear enough.