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
In reply to Quarms with RegEx by TraderX
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |