#!usr/bin/perl
use strict;
use warnings;
my $file_name = "rem.txt";
open(FILE, $file_name);
while (<FILE>) {
my $line = $_;
if ($line =~ m/(\w*Svr)\b/) {
my $server_name;
$server_name = $1;
my @arr_servername = $server_name;
print "@arr_servername\n";
#print "$server_name\n";
} elsif ($line =~ m/-[dD]\s*\$\{(.*?)_NAME/) {
my $database_name;
$database_name = $1;
my @arr_dbname = $database_name;
print "\n-----------------\n";
print "@arr_dbname\n";
print "\n----------------\n";
#print "....$database_name\n";
}
}
REM.TXT
ewrerfSvr //(extracted---
Rate=rpm
ID=123
RATE=45
ADDR=retriveBal
Grocer="-r -e ${MAIN_ROOT}/logs/stderr -o ${MAIN_ROOT}/logs/stdout -A --"
freedonSvr
BALFSvr //to be extracted
Rate=rpm1
ID=12323
RATE=45etf
ADDR=retriveBal
Grocer="-r -e ${MAIN_ROOT}/logs/stderr -o ${MAIN_ROOT}/logs/stdout -A --"
freedonSvr -D ${REV_AccountBalance_NAME}"// extracted
Refer
Rate =rpm
ID =234
ADDR = calbal
Grocer="-r -e ${MAIN_ROOT}/logs/stderr -o ${MAIN_ROOT}/logs/stdout -A --" -D ${REV_MAx_NAME}"
REstSvr
Grocer="-r -e ${MAIN_ROOT}/logs/stderr -o ${MAIN_ROOT}/logs/stdout -A --"
freedonSvr -D ${REV_MinBalance_NAME}"
The code above retrieves a file name and database name. I want the database name to be mapped to the server name. How shall I do this?
My output retrieves all database names separately in some order and the server name in some other order. I want to use a hash to store the database name and server name, the order must be preserved. How shall I do that?
The primary need for doing this is to identify which server uses which database.