Peter,
Is it possible to-do this?
in the config file I have (as you have seen b4)
backint:maple aspen pine
online:orange palm cherry
is it possible to read in this file and what ever is before the : would
become the name of
the array?
IE:
I add this to the config file
full:apple grape chestnut
I would like the per script to parse the config file and when it hits the
full line, it would pick off the word full and use that name for the array
of servers after the : ??
Regards,
Ron
-----Original Message-----
From: Peter Cornelius [mailto:[EMAIL PROTECTED]]
Sent: Thursday, May 17, 2001 1:32 PM
To: Yacketta,Ronald J
Subject: RE: help with arrays
When I do this...
#!/usr/local/bin/perl
open(BINT,"junk") || die "could not open $BACKINT: $!";
while ($line = <BINT>)
{
#chomp $line;
my ($type) = split(/:/,$line);
$line =~ s/:/ /g;
print $line;
if ( $type eq backint )
{
push @backint, split(/ /,$line);
}
if( $type eq online )
{
push @online, split(/ /, $line);
shift @online;
}
}
close(BINT);
print"\n\n";
for (@backint ) {
print "---> $_ <---\n";
}
foreach $server (@backint) {
print "-->$server<--";
}
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
I get this...
---------------------------------
backint maple oak pine aspen
online palm chestnut cherry
archive palm chestnut cherry
---> backint <---
---> maple <---
---> oak <---
---> pine <---
---> aspen
<---
-->backint<---->maple<---->oak<---->pine<---->aspen
<--
notice the \n after aspen? If you tried to do something like system ("scp
$server:$file $server2:$file") the shell would complain if the server was
aspen\n. It would be like hitting the <return> part way through typing the
command. One thing that might help here is if you print out whatever
command you are trying to run exactly as you are calling it from the loop.
Peter C.