in reply to compound structure? 4way-hash

I'm parsing a dhcpd.conf file and expect the number of entires to reach probably 1000 at long turn.. At the moment I don't look so much at speed, but will need it may be !!!
At the moment there is only one case when I will resolv-all entiries (mac->name)...

my code up to the moment is :
...... sub parse { my $self = shift; #parse the classes my @clases = $$self{_data} =~ /class\s+?"(.+?)"\s+?\{.*?=\s*(.+?)\s*; +/gs; while ($#clases > 0) { $$self{_clases}{pop @clases} = pop @clases; } my @hosts = $$self{_data} =~ / host\s*(.+?)\s*\{.*? filename\s*"(.+?)"\s*;.*? ethernet\s*(.+?)\s*;.*? fixed-address\s*(.+?)\s*; /xgs; while ($#hosts > 0) { my $h = shift @hosts; ($$self{_hosts}{$h}{file}, $$self{_hosts}{$h}{mac}, $$self{_hosts}{$h}{ip}) = splice @hosts,0,3; } } sub name2 { my ($self, $name, $to) = @_; $$self{_hosts}{$name}{$to} } 1;
One thing on which i would like to hear your comment is the while cycles ... did u see "my $h", if i try this :
(my $h, $$self{_hosts}{$h}{file}, $$self{_hosts}{$h}{mac}, $$self{_hosts}{$h}{ip}) = splice @hosts,0,4;
it wont work... not a big deal but it is interesting to know why ?

Replies are listed 'Best First'.
Re^2: compound structure? 4way-hash
by Aristotle (Chancellor) on Aug 26, 2002 at 15:52 UTC
    How often is this script running? "1000 lines" doesn't say much. If you run it once a day, 1000 lines is a pretty miniscule burden.

    Makeshifts last the longest.