CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Get information blocks

 



telekomunist
New User

Aug 21, 2010, 7:19 AM

Post #1 of 1 (257 views)
Get information blocks Can't Post

Hi
I can't make a script to get information blocks from my configuration file
config.cfg (information)
###########
HTTP
port = 80, 8080, 8008
ip = 192.168.100.34
service = iis
protocol = tcp
!
FTP
port = 23
ip = 192.168.100.43
service = filezilla
protocol = tcp
!
ABC
port = 443
ip = 195.143.2.43
service = filezilla
protocol = tcp
!
###############

As you see each configuration block ends with ! sign
I write a script to get config just one block


Code
while ($line = <FILE>) { 
if ($line =~ /$query/i) {
$tag = 1;
}
if ($line =~ /^!/ && $tag == 1) {
print NEWFILE $line if ($tag == 1);
$tag = 0;
}
print NEWFILE $line if ($tag == 1);
}
close (FILE);


Where FILE is my configuration file, $query is block header which i looking

I try to upgrade this script to get info about many services, actually, input its as file

##########
FTP
HTTP
###########

Please help
Thanks in advance

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives