Hi Monk, I am trying to write a program that will start certain services, eg apache etc by choice from a text menu.
The problem is I want the program to check it is being run on the correct host before it starts the service. Some of the services will be able to be started on multiple hosts, but not on others hence the reason I have made a hash of arrays for the list of host(s).
I don't know what data structure to use to store the details. I have tried with this data structure, but not having much luck derefrencing the associative array, when doing a check.
For example the associative array I am using is the following:
use strict;
use warnings;
our %Services = (
{
serviceid => "1",
name => "servicea",
host => [ qw(hosta hostb)],
serviceid => "2",
name => "serviceb",
host => [ qw(hostc) ],
}
);
I know how to check which host it is being run on with the hostname command and storing in a variable, but I don't know how to check that against the values in the hash of arrays.
I think I might be using the wrong data structure. Could anybody help please.
Thanks
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.