The subroutine builds an array of a hashes (easy), however I have tried to assign an array to one of those hashes and I'm having no luck. Any ideas? I'm pretty sure it something to do with the way I'm assigning to the hash or reading from the hash Here's the code.
PS If anyone spots room for improvement in my code please point it out. It's the only way I'll learn :-) Diarmuidsub Parse_Constraint_File { croak("Parse_Constraint_File <filename>") unless(my $filename = shif +t); my $setup_hash_ref = shift; my $open_command = ($filename =~ /\.gz$/) ? "gzip -dc $filename|" : +$filename; my $rec={}; my @path_details=[]; my $i=0; open(CONST,"$open_command") || croak("Can't open $filename"); while(<CONST>){ # find out the important info: if(/Startpoint: ([\w\/]+)$/) { $rec->{'startpoint'} = $1 }; if(/Endpoint: ([\w\/]+)$/) { $rec->{'endpoint'} = $1 }; if(/Path Group: (\w+)$/) { $rec->{'path_group'}= $1 }; if(/Path Type: (\w+)$/) { $rec->{'path_type'}= $1 }; if(/^\s+Point/.../^\s+slack/ && $setup_hash_ref->{'detail'}){ push @path_details,$_; } if(/^\s+slack [\w\(\)]+\s+(-?[\d\.]+)$/) { #last field is reached $rec->{'slack'} = $1; $rec->{'path_details'} = [ @path_details ]; # if we set a startpoint the only pick those paths if (defined($setup_hash_ref->{'startpoint'}) && defined($setup_hash_ref->{'endpoint'})){ if($rec->{'startpoint'} =~ /$setup_hash_ref->{'startpoint'}/ & +& $rec->{'endpoint'} =~ /$setup_hash_ref->{'endpoint'}/){ $timing_paths[$i++] = $rec; print @path_details; } }else{ # otherwise take all points $timing_paths[$i++] = $rec; } @path_details=[]; $rec={}; } } return @timing_paths; close CONST;
In reply to references hashes arrays fun ... again :-( by diarmuid
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |