One question to ask is: must all the %<name>Cmd hashes in the .pm files have different names?
If yes, you need alias %<name>Cmd onto %Cmd or something like that. This is kind of cool, but not recommended to do routinely.
If no, then just rename the %<name>Cmd hashes in each of the .pm files to %Cmd.
Either way, you can process all the files in a loop or a subroutine (or both) with code that looks something like this:
Hope this helps.our %Cmd; do "db/$name" . 'Cmd.pm'; $ApidOffset = $Application{$name}{AppApidOffset}; foreach $cmd (keys %Cmd) { if (int($fssbCmd{$cmd}{fixed_pattern}) <= 15) { $opcode = sprintf("0%x",$Cmd{$cmd}{fixed_pattern}); } else { $opcode = sprintf("%x",$Cmd{$cmd}{fixed_pattern}); } $apid = sprintf("%x",$ApidBase+$ApidOffset); $cmdData{$cmd} = {opcode => "0x$opcode", apid => "0x$apid"}; };
In reply to Re: Repeating Code - there has GOT to be a better way!
by cleverett
in thread Repeating Code - there has GOT to be a better way!
by jedikaiti
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |