in reply to Re: Re: creating hash name from variables
in thread creating hash name from variables

Ah. You were trying to create symbolic references. Don't do that.

Why not use a hash of hashes instead?

use strict; use warnings; my $ComDir='.\\'; my $Inputfile='ProxyFTP'; my $Outputfile='ftpreport.txt'; my $Permsfile='userperms.txt'; open(PERF, "<$ComDir$Permsfile") || die ("died opening source file $Permsfile: $!"); my %data; while (<PERF>) { chomp; my ($name, $val) = split / /, cleanupline($_), 2; $data{$name}{$val} = 1; } # next 3 lines should print Exists my $nam='sapuser'; my $val='1.2.3.4'; print "Exists\n" if exists $data{$nam}{$val}; # next 3 lines should not print Exists $nam='sapuser'; $val='1.2.3.7'; print "Exists\n" if exists $data{$nam}{$val}; sub cleanupline { local ($_) = @_; s/[\n\r]//g; s/^[ \t]+//g; s/[ \t]+/ /g; return $_; }
--
<http://www.dave.org.uk>

"The first rule of Perl club is you do not talk about Perl club."
-- Chip Salzenberg

Replies are listed 'Best First'.
Re: Re: Re: Re: creating hash name from variables
by mcudmore (Initiate) on Oct 09, 2002 at 22:04 UTC
    many thanks for the timely help. Lets leave the 2 slight errors as exercise for other seekers :-)