PERL name value pairs substituions


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting PERL name value pairs substituions
# 1  
Old 07-12-2009
PERL name value pairs substituions

I have a main file with variable tokens like this:
Code:
name: File1
===========
Destination/Company=@deploy.company@
Destination/Environment=@deploy.env@
Destination/Location=@deploy.location@
Destination/Domain=@deploy.location@
MIG_GatewayAddresses=@deploy.gwaddress@
MIG_URL=@deploy.mig_url@
Database/URL=@deploy.db_url@
SBU/Domain=@deploy.company@_@deploy.location@

I have another file that provides the variable values...
Code:
name: File2
============
deploy.company=ABC
deploy.location=BLore
deploy.env=DEV
deploy.gwaddress=fnet-ayz3z1:18997;fnetzyx3z1:18997
deploy.mig_url=tibjmsnaming\://ldgcomp.abz.net\:25011,tibjmsnaming\://ldgcomp.abz.net\:25012
deploy.db_url=jdbc:antsoftware:oracle://ldgcomp.abz.net:1521;SID=devd;enablecanceltimeout=true

it is bit urgent that I need to get this done in my project with a little PERL script that can substitute file1 ..can you please help? Many thanks in advance...
# 2  
Old 07-12-2009
Loop through File2 and store the "name=value" records as key/value pairs in a Perl hash.

Then loop through File1, remove those "@" characters from the value to the right side of the "=" character, and substitute the remnant hash key by its value.

HTH,
tyler_durden
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Extracting data between two tag pairs

In a huge log file (43MB, 43k lines) I am trying to extract data between two tag pairs on same line and export it to a file so I can pull it into Excel for a report. One Pair is <Text>data I need</Text> Other pair follows on same line and is <TimeStamp>more data I need</TimeStamp> I would need... (2 Replies)
Discussion started by: NanookArctic
2 Replies

2. UNIX for Dummies Questions & Answers

Sorting by pairs

Can sort sort by pair of lines? infile: ID 15 GNJSMKSNS ID 25 GNJSMKSNS ID 1 GNJSMKSNS outfile: ID 1 GNJSMKSNS ID 15 GNJSMKSNS ID 25 GNJSMKSNS sort -grk 2 obviously does not work (4 Replies)
Discussion started by: Xterra
4 Replies

3. UNIX for Dummies Questions & Answers

Concatenate files by pairs

Hi, I would like to batch concatenate files by pairs. I have quite a few of them so I would not like to do that pair by pair separately. the names of the file is of the type: file1.fastq newfile1_new.fastq file2.fastq newfile2_new.fastq and so on... I would like to concatenate file1... (2 Replies)
Discussion started by: jawad
2 Replies

4. Shell Programming and Scripting

Looping through files in pairs

Hi all, Please guide. It has to do with parsing the input file names. I have a fairly large number of files, I want to do some operations on them in a pairwise fashion (every file has a pair). The names are in the following pattern, with the pairs of files named with _1 and _2 , the... (4 Replies)
Discussion started by: newbie83
4 Replies

5. Shell Programming and Scripting

Extracting key/value pairs in awk

I am extracting a number of key/value pairs in awk using following: awk ' /xyz_session_id/ { n=index($0,"xyz_session_id"); id=substr($0,n+15,25); a=$4; } END{ for (ix in a) { print a } }' I don't like this Index + substr with manually calculated... (5 Replies)
Discussion started by: migurus
5 Replies

6. Shell Programming and Scripting

Need help comparing Base Pairs within PERL

Hi I have a multi-step project I am working on and have been finding it difficult to come up with the correct approach. The data I have been given resembles: Index Chr Genotype Mutation Type 1 Chr1 TT Intronic 2 Chr1 AA ... (27 Replies)
Discussion started by: drossy
27 Replies

7. Shell Programming and Scripting

keep only pairs

Hi, I am trying to paste together two files which are like this- 1 2 4 and 2 3 4 The paste command would work by default for this case, but when there are cases where the number of entries are different in each file. for eg: 1 3 and 1 3 4 I want to make it such that the odd... (11 Replies)
Discussion started by: jamie_123
11 Replies

8. Shell Programming and Scripting

concatenate lines in pairs

Hi, I have a text file with the following contents /C=IT/O=INFN/OU=Personal Certificate/L=Napoli/CN=Some guy /C=IT/O=INFN/CN=INFN CA /O=Grid/O=NorduGrid/OU=uninett.no/CN=Another guy /O=Grid/O=NorduGrid/CN=NorduGrid Certification Authority /C=TW/O=AP/OU=GRID/CN=Someone else... (5 Replies)
Discussion started by: kerl
5 Replies

9. Shell Programming and Scripting

Matching Pairs with AWK or Shell

Hello, I have a file Pairs.txt composed of 3 columns. For simplicity, this is the file: A B C B D W X Y Z Z W K B A C Y J Q F M P Y X Z I am trying to reduce the file such that I only keep the first occurrence of any "pair". In the example above, I would only want to keep one... (6 Replies)
Discussion started by: InfoSeeker
6 Replies

10. Shell Programming and Scripting

perl search and replace pairs

Hello all im facing some kind of problem i have this string : functionA() $" "$ functionB("arg1") $" = "$ i will like to replace all the pairs of opening and closing "$" to be something like that functionA() <#" "#> functionB("arg1") <#" = "#> i cant of course do is with simple ... (1 Reply)
Discussion started by: umen
1 Replies
Login or Register to Ask a Question