John W. Krahn wrote:
Noah wrote:
response inline below

John W. Krahn wrote:
Noah wrote:

I have a routine returning a perl reference and I am trying to figure out how to properly use the hash tables in the main section of my perl proggie.

--- from the main program

my $templateConfiguation = &readConfigTemplate($templateConfigFilename, $sortedTemplateConfigFilename);

.... and later on how do I properly use the hash $templateConfiguation ....

        } else {
print DIFF "d> $key" if !exists ($templateConfiguation{$templateType}{$key}); print MATCH "m> $key" if exists ($templateConfiguation{$templateType}{$key});

if ( exists $templateConfiguation->{ $templateType }{ $key } ) {
    print MATCH "m> $key";
    }
else {
    print DIFF "d> $key";
    }

okay so I get a peculiar error message that I am not sure how to correct:

Can't use string ("") as a HASH ref while "strict refs" in use at ./compare.configs.pl line 900.

--- line 900 to line 904 ---

            if (exists $templateConfiguation->{$templateType}{$key}) {
                print MATCH "m> $key";
            } else {
                print DIFF "d> $key";
            }

That means that either $templateConfiguation or $templateConfiguation->{$templateType} has a value of "" and not a hash reference.



Okay I see why $templateConfiguration is defined inside a for loop. how can I make sure the referenced hash that is returned inside the for loop is passed to the main portion of the program.

Here is the for loop.

--- snip ---

foreach my $templateConfigFilename (@templateConfigFilenames) {
    $templateConfigFilename = "$TemplateDirectory/$templateConfigFilename";
(my $sortedTemplateConfigFilename = $templateConfigFilename) =~ s/.(configuration.txt)/.sorted-$1/; push (my @sortedTemplateConfigFilenames, $sortedTemplateConfigFilename);

    # go read template files and save as sorted
my $templateConfiguation = &readConfigTemplate($templateConfigFilename, $sortedTemplateConfigFilename);
}



---- snip ---





John

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to