in reply to Using a lookup table(?)
Assuming I understand you correctly, and you are using a file of the format:
you could do the following:server1 Webserver server2 DMZ Server server4 Oracle Server
Keep in mind I haven't tested this and this is off the top of my head. There's some error detection logic missing in that code (for instance, nothing for the value $host in the input file) and stuff like that.use strict; use Tie::File; | mumble. | sub get_comments { my $host=shift; my @ry=(); tie @ry,"Tie::File","myfile.txt" or die "myfile.txt: $!"; my @lines = grep $host,@ry; my $line = shift @lines; # should only be one. my @f=split(/[\s\n\t]+/,$line); shift @f; untie @ry; return join(" ",@f); }
Hope this is a help...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Using a lookup table(?)
by ikegami (Patriarch) on Feb 07, 2007 at 18:16 UTC | |
by blue_cowdawg (Monsignor) on Feb 07, 2007 at 19:22 UTC | |
by ikegami (Patriarch) on Feb 07, 2007 at 19:27 UTC |