TraderX has asked for the wisdom of the Perl Monks concerning the following question:
Let's say I have a list domain and servers in the following format : # domain 1 servera serverb # domain 2 serverc serverb What i wanted this little piece of code to do was to have of hash of arrays with the servers assigned for each domain assigned to arrays and the domains stored into each element of the hash table with the array of servers associated with each element of the hash table. (it's 1:28 a.m and if i sound incoherent, i'm tired :) ) What actually is going on is that the first domain is actually being stored in the hashtable, however the 2nd domain is being stored in the array that's associated with the first domain. Is there a problem with my RegEx conditional? If so, where did I go wrong? Any help is greatly appreaciated. Thankswhile (my $curline = <IN>){ #if the current line read is a domain #domain if ($curline =~ /^#/){ print $curline, "\n"; # for debugging my $currentdomain = $curline; while($curline = <IN>){ if ($curline !~ /^#\s/ or $curline !~ /^\s/) { $server++; $currentserver = $curline; push(@serverlist, $currentserver); } ## end if elsif ($curline !~ /^\s/){ $HoA{$currentdomain} = [@serverlist]; $currentdomain = $curline; } #end else } ## end while if ( eof(IN)){$HoA{$currentdomain} = [@serverlist];} } ## end if } ## end while
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Quarms with RegEx
by busunsl (Vicar) on Aug 28, 2001 at 12:37 UTC | |
by blakem (Monsignor) on Aug 28, 2001 at 12:53 UTC | |
by busunsl (Vicar) on Aug 28, 2001 at 12:57 UTC | |
by blakem (Monsignor) on Aug 28, 2001 at 13:31 UTC | |
by busunsl (Vicar) on Aug 28, 2001 at 13:53 UTC | |
by stefan k (Curate) on Aug 28, 2001 at 12:47 UTC | |
|
Re: Quarms with RegEx
by chipmunk (Parson) on Aug 28, 2001 at 16:20 UTC | |
|
Re: Quarms with RegEx
by stefan k (Curate) on Aug 28, 2001 at 12:45 UTC | |
|
Re: Quarms with RegEx
by Chady (Priest) on Aug 28, 2001 at 12:50 UTC | |
|
Re: Quarms with RegEx
by blakem (Monsignor) on Aug 28, 2001 at 12:33 UTC |