For the love of god, can someone show me how to do this shit correctly?I understand what references and pointers are from the C world and I can do it just fine for regular lists (arrays) in perl, but I am fucking something up with hashes and its proceeding to rape me.the call:
%x_hash=&X_BLOCK($fileLines,\@inputFile,\%x_hash);
sub X_BLOCK { ($lineCount, $inFile, %theHash) = @_; for($line= 1; $line<=$lineCount; $line=$line+1) { # foreach $key (keys (%theHash)) { if($theHash{$key}[1] == 1) {next}; if(@$inFile[$line] =~ /($key)(.*)($theHash{$key}[0])/) { print "Key is $key: value is %$theHash{$key}[0]\n"; print "Key is $key value is $2.\n"; $theHash{$key}[1] = 1; next; } } } return %theHash;}
8/5/2005 12:09:09 PM
It's all magic anyway. Just throw some goat's blood on it, that will fix it.
8/5/2005 12:32:07 PM
Fuck it. For the time being I'm just letting the sub access a global, but I hate doing it that way.
8/5/2005 12:56:26 PM
& is reference operator
8/5/2005 12:59:31 PM
http://www.google.com/search?hl=en&lr=&q=how+to+pass+a+hash&btnG=SearchProgrammingTalk - How do I pass a hash reference to a subroutinehttp://www.programmingtalk.com/archive/index.php/t-19136.html
8/5/2005 1:00:16 PM
Fuck I had an epiphany finally
sub TEST { $thehash = shift; foreach $key (keys (%$thehash)) {# $alpg_hash{$key}[$ver+1] = $2; #Store the information in the correct slot in the hash of arrays $alpg_hash{$key}[1] = 1; # indicate that we already found this one on this iteration print "Key is $key: value is $$thehash{$key}[0]\n"; }}
foreach $key (keys (%$thehash))
print "Key is $key: value is %$thehash{$key}[0]\n";
$$thehash{$key}[0]
8/5/2005 1:21:01 PM