Greets.

I have a 'config file' that contains a group name (alphanumeric) and
machine name/numbers separated by whitespace.  Each group is on it's
own line.  The file looks like this:

prod01 456 345 234
prod02 789 517 325
...etc, etc, etc...

What I am attempting to do is:
Put the file contents into an array
Pull the first entry off the array
Add the name of the array to a 'master array' list of the machine
groups
Then create another array, which would be referenced by the group
name, and contains the machines associated with the group.

Here is the code I have now that is giving me problems:

# parse the config file
foreach (@filelist){

        # for each line of the config file, place the entries
        # into a temp array
        my @temp=split(/ /);

        # pull the first entry off the array
        my $group=shift(@temp);

        # add the name of the array to the main rg array list
        push (@grouplist, $group);

        # push the rest of the entries into an array that has
        # the same name as the rg in question
        foreach (@temp){
                push (@$group, $_);
        }
}

The idea of the script as a whole is to take the config file and split
it into multiple arrays.  Once that is done, connect to each machine
and pull some files into another directory.

The script flow:
-Read the config file, put each line into an array - @temp = qw {prod1
456 345 234}

-Pull the first value from the temp array ($grp) and place it into the
master list - @master = qw {'prod1 prod2}

-Create a new array on the fly (it needs to be this way as new groups
may be created, or old ones removed) with the name of the pulled value
($grp) and place the machine names/numbers into that array - @prod1 =
qw {456 345 234} @prod02 = qw {789 517 325} etc...

-Loop through the master list, using each value as the pointer to the
individual array that contains the machines

-Connect to each machine in turn and pull the files

The script runs if I do not use strict (which I consider a Bad
Thing).  But when I run it with strict, I receive the following error:

Can't use string ("prod01") as an ARRAY ref while "strict refs" in use

Am I missing something really basic that is covered in the Llama (3rd
edition), and can anyone give me any hints?


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to