T
Tomasz Chmielewski
I have a script which reads the config file and builds the commands
which need to be executed.
It pushes each command to an array.
When everything is read from the config file, it is executed like this:
foreach my $exec_command (@exec_commands) {
execute($exec_command);
}
However, such approach does not guarantee that the commands will be
executed in a proper order.
Supposing I would like to have the guarantee that the commands
containing "someword" will be executed before commands containing
"someotherword" (and this, before "xyz" command), what would be the best
approach here?
1) build a hash, not an array in the first place? I'm afraid it would
complicate it too much.
2)
foreach my $exec_command (@exec_commands) {
if ($exec_command=~m { .... }) {
push(@execute_first, $exec_command);
}
if ($exec_command=~m { .... }) {
push(@execute_second, $exec_command);
}
}
And then, simply execute commands from @execute_first, @execute_second,
and so on?
3) something else?
which need to be executed.
It pushes each command to an array.
When everything is read from the config file, it is executed like this:
foreach my $exec_command (@exec_commands) {
execute($exec_command);
}
However, such approach does not guarantee that the commands will be
executed in a proper order.
Supposing I would like to have the guarantee that the commands
containing "someword" will be executed before commands containing
"someotherword" (and this, before "xyz" command), what would be the best
approach here?
1) build a hash, not an array in the first place? I'm afraid it would
complicate it too much.
2)
foreach my $exec_command (@exec_commands) {
if ($exec_command=~m { .... }) {
push(@execute_first, $exec_command);
}
if ($exec_command=~m { .... }) {
push(@execute_second, $exec_command);
}
}
And then, simply execute commands from @execute_first, @execute_second,
and so on?
3) something else?