I see two possible solutions: - Although you cannot change the files, nobody says you have to use them "as is": you could pre-process them and turn them into a more workable data-format and then work with this data; or
- You could write a subroutine that takes two arguments: the first is the <name> and the second is the %<name>Cmd hash:
sub process {
my ($name, %Cmd) = @_;
$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"};
};
}
Of course you will still have 11 subroutine calls to make, but I think you can survive that!
Update: fixed a typo in the subroutine (%Cmd instead of %cmd)
CountZero A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|