Sponsored Content
Full Discussion: string substitution in perl
Top Forums Shell Programming and Scripting string substitution in perl Post 302286122 by melanie_pfefer on Tuesday 10th of February 2009 11:07:39 AM
Old 02-10-2009
string substitution in perl

Hi,

I have a template file and want to replace 3 parameters to the values that I want. these values are in a parameter file.

Any idea how to do this in perl?

the parameter file looks like:

host_name = jupiter
PORT = 1562
IPADDRESS = 10.1.34.10


the template file has lots of entry.


CX_HOST_NAME = host_name
CX_IPADDRESS = ip_address
CX__PORT = port

thanks.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Sed String Substitution

Hi! I've the following script code with an input parameter: sed 's/oldstring/$1/g' myfile > newfile (I launch it with comman line: $ MyShell newstring) Problem: the substituion doesn't work (oldstring becomes $1, instead of newstring). How could I solve this situation? Thanks, ... (2 Replies)
Discussion started by: pciatto
2 Replies

2. Shell Programming and Scripting

Perl Substitution

I have lines in a file that look like this: machine: machinea machine: machineb machine: randomwhatevermachine I want to replace the machine lines with: machine: machinec I tried perl -pi -e "s/#machine:\?*/machine: machinec/" filename But this ended up doing this: ... (2 Replies)
Discussion started by: Lindarella
2 Replies

3. UNIX for Advanced & Expert Users

String Substitution

Hey ppl, Could u tell me how to replace such a string xyz->x with XYZ(x), where x can be any variable accessible by pointer to structure, xyz in an entire file? (1 Reply)
Discussion started by: laxmi
1 Replies

4. Shell Programming and Scripting

string substitution

Hey ppl, Could u tell me how to replace such a string xyz->x with XYZ(x), where x can be any variable accessible by pointer to structure, xyz in an entire file? (3 Replies)
Discussion started by: laxmi
3 Replies

5. Shell Programming and Scripting

String substitution

Hi, I have a properties file (myprop.properties) which contains some values: @oneValue@==tcp://localhost:1234 @twoValue@==tcp://localhost:4563 @threeValue@==tcp://localhost7895 I have a xml file (myXmlFile.xml)which contains some tokens: <application name="aTest"> <NameValuePair> ... (3 Replies)
Discussion started by: ctrl-alt-del
3 Replies

6. Shell Programming and Scripting

Perl:string substitution Pattern: ='abc...',

Hi friends, I want to substitute "a ='....'," with ":" in everywhere in a string using Perl. Details: ---------- my $str= " c1='fgfasfgasggfgff.,akhkhahha', c2='bbbn', c3='hg5 sh' "; Required o/p: $str= " c1:c2:c3 " I tried as below: $str=~ s/=\'.*\',/:/g ; print "str=... (14 Replies)
Discussion started by: Niroj
14 Replies

7. Shell Programming and Scripting

substitution using perl

Hi All, I need the perl version of the below sed command: sed 's/abc.*/&.txt/g' <filename> Because I'm trying to do some replacement recursively using perl and the above replacement is replacing the abc* with "&.txt" exactly. Thanks, Arun (9 Replies)
Discussion started by: arun_maffy
9 Replies

8. Shell Programming and Scripting

perl substitution

Hello all I have a strings like " Watch news 24x7 "."x-wars is glowing" " Watch news like 24 x 7"."x-mas will be celebrated" " Dimensions of box is 24x23x47 ". I have to remove the x(by) in between the number. If i just replace x, it will also remove all x's from text which i do not want.... (1 Reply)
Discussion started by: vasuarjula
1 Replies

9. Shell Programming and Scripting

Perl substitution

Hi, I'm new to Perl, and I want to change a few columns in a file in order to insert them into a database. The input file looks like this: 00001,"01/1234567" ,"Tst2" 00002,"01/4545646" ,"Tst123456" 00003,"01/8979898" ,"" The output should look like this: 01-1234567,00001... (2 Replies)
Discussion started by: Subbeh
2 Replies

10. Programming

COBOL: Substitution in string

We have a formatted screen system where a driver program passes the locations of a list of files that called programs may be using. It will look something like this: /{number of characters varies}/DATA/MASTERFILEBecause of the size of some files we will be splitting older records into a history... (2 Replies)
Discussion started by: wbport
2 Replies
URI::Template(3pm)					User Contributed Perl Documentation					URI::Template(3pm)

NAME
URI::Template - Object for handling URI templates (RFC 6570) SYNOPSIS
use URI::Template; my $template = URI::Template->new( 'http://example.com/{x}' ); my $uri = $template->process( x => 'y' ); # uri is a URI object with value 'http://example.com/y' DESCRIPTION
This module provides a wrapper around URI templates as described in RFC 6570: http://tools.ietf.org/html/rfc6570 INSTALLATION
perl Makefile.PL make make test make install METHODS
new( $template ) Creates a new URI::Template instance with the template passed in as the first parameter. template This method returns the original template string. variables Returns an array of unique variable names found in the template. NB: they are returned in random order. expansions This method returns an list of expansions found in the template. Currently, these are just coderefs. In the future, they will be more interesting. process( \%vars ) Given a list of key-value pairs or an array ref of values (for positional substitution), it will URI escape the values and substitute them in to the template. Returns a URI object. process_to_string( \%vars ) Processes input like the "process" method, but doesn't inflate the result to a URI object. AUTHORS
o Brian Cassidy <bricas@cpan.org> o Ricardo SIGNES <rjbs@cpan.org> COPYRIGHT AND LICENSE
Copyright 2007-2012 by Brian Cassidy This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.14.2 2012-05-30 URI::Template(3pm)
All times are GMT -4. The time now is 10:42 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy