Re: help on replacing text in a file

2007-11-01 Thread John W . Krahn
On Thursday 01 November 2007 11:25, boxingcat wrote: > / Sorry if it is a repost. didn't see the first one in the group. > > > I would like to replace string 1 with string 2 in file3.dat, here is > what I did: > > #!/usr/bin/perl use warnings; use strict; > @inputfile= ("string1"); # need to h

help on replacing text in a file

2007-11-01 Thread boxingcat
/ Sorry if it is a repost. didn't see the first one in the group. I would like to replace string 1 with string 2 in file3.dat, here is what I did: #!/usr/bin/perl @inputfile= ("string1"); # need to have an arrary later @outputfile=("string2"); @attfile=("file3.dat"); $mytempfile=$inputfile[0]

help on replacing text in a file

2007-11-01 Thread boxingcat
I would like to replace string 1 with string 2 in file3.dat, here is what I did: #!/usr/bin/perl @inputfile= ("string1"); # need to have an arrary later @outputfile=("string2"); @attfile=("file3.dat"); $mytempfile=$inputfile[0]; $youtempfile=$outputfile[0]; $hisfile=$attfile[0]; perl -pi -e 's

Re: Newbie having problems replacing text

2004-12-03 Thread Jonathan Paton
Dear Pam, Obviously, $title is undef. This is a great example for warnings & strict, as otherwise this would just silently not do what you want. Your task is to move the text within the tags to the tags. You are processing the file, line by line. When can you expect to know the page title?

Newbie having problems replacing text

2004-12-03 Thread Pam Derks
Hi all, I'm trying to read in a bunch of files and insert the contents of the tag into the tag, writing the output to a temp file. Am getting this error: Use of uninitialized value at title.pl line 28, chunk 14. Which is this line: $_ =~ s#$pattern2#$title#g; I'm not sure why I'm getting t

Re: Searching and replacing text

2004-08-02 Thread Zeus Odin
Could you post the code you have written thus far? It would be a great help. -ZO "Chris Richards" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] Hi Everyone, This is my first post to the list Please be gentle :) Just so we are all clear... I am completely lost right from the st

RE: Searching and replacing text

2004-08-02 Thread Chris Richards
Fair enough. -Chris -Original Message- From: Gunnar Hjalmarsson [mailto:[EMAIL PROTECTED] Sent: Monday, 2 August 2004 10:08 PM To: [EMAIL PROTECTED] Subject: Re: Searching and replacing text Chris Richards wrote: > This is my first post to the list Please be gentle :) S

Re: Searching and replacing text

2004-08-02 Thread Gunnar Hjalmarsson
Chris Richards wrote: This is my first post to the list Please be gentle :) Sure. Just so we are all clear... I am completely lost right from the start with this one. It is far beyond my current Perl skills Oh? and I need some serious help :) Then, this is the most serious (and gentle) help I c

Searching and replacing text

2004-08-02 Thread Chris Richards
Hi Everyone, This is my first post to the list Please be gentle :) Just so we are all clear... I am completely lost right from the start with this one. It is far beyond my current Perl skills and I need some serious help :) I want to create a script that searches file_b for the first entry i

Re: Replacing text

2003-12-06 Thread John W. Krahn
Dan Anderson wrote: > > I have a script that reads text from a file and inserts text > into different places depending on what it needs to do. But I use > split to replace the text, i.e.: > > ($first_part, $second_part) = split "#INSERT#TEXT#HERE#", $document, 2; > print FILEHANDLE

RE: Replacing text

2003-12-05 Thread Tom Kinzer
appens more than once on a line. print OUT; } close IN; close OUT; print "Munge complete.\n"; -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Dan Anderson Sent: Friday, December 05, 2003 3:11 PM To: [EMAIL PROTECTED] Subject: Replacing text

RE: Replacing text

2003-12-05 Thread Wagner, David --- Senior Programmer Analyst --- WGO
[EMAIL PROTECTED] wrote: > I have a script that reads text from a file and inserts text > into different places depending on what it needs to do. But I use > split to replace the text, i.e.: > > ($first_part, $second_part) = split "#INSERT#TEXT#HERE#", $document, > 2; print FILEHAND

Re: Replacing text

2003-12-05 Thread Philipp Traeder
Hi Dan, have you tried using a regular expression? I am using something like this for a similar purpose: open ($fh, $filename); # go through each line of the file while ($_ = <$fh>) { # replace globally in the default variable $_ s/#INSERT#TEXT#HERE/$text_to_insert/g; } close ($fh);

Replacing text

2003-12-05 Thread Dan Anderson
I have a script that reads text from a file and inserts text into different places depending on what it needs to do. But I use split to replace the text, i.e.: ($first_part, $second_part) = split "#INSERT#TEXT#HERE#", $document, 2; print FILEHANDLE $firstpart, $text_to_insert, $sec

Re: replacing text in a file

2003-06-09 Thread Tassilo von Parseval
On Mon, Jun 09, 2003 at 03:22:52PM +0100 Rob Dixon wrote: > Tassilo Von Parseval wrote: > > You can use the same underlying technique from within a Perl script. You > > have to set two special variables accordingly and Perl can even do an > > inplace-edit: > > > > local $^I = 1;

Re: replacing text in a file

2003-06-09 Thread Rob Dixon
Tassilo Von Parseval wrote: > On Mon, Jun 09, 2003 at 02:46:48AM -0500 christopher j bottaro wrote: > > > what is the easiest way to replace text in a file? say i have file blah.txt > > and i want to replace some regular expression found in that file with > > something. also, i want to do this fr

RE: replacing text in a file

2003-06-09 Thread Dan Muey
> hello, > what is the easiest way to replace text in a file? say i > have file blah.txt > and i want to replace some regular expression found in that file with > something. also, i want to do this from within the perl > program, not by > invoking perl with the -e option. #!/usr/bin/perl -w

Re: replacing text in a file

2003-06-09 Thread Tassilo von Parseval
On Mon, Jun 09, 2003 at 02:46:48AM -0500 christopher j bottaro wrote: > what is the easiest way to replace text in a file? say i have file blah.txt > and i want to replace some regular expression found in that file with > something. also, i want to do this from within the perl program, not by

replacing text in a file

2003-06-09 Thread christopher j bottaro
hello, what is the easiest way to replace text in a file? say i have file blah.txt and i want to replace some regular expression found in that file with something. also, i want to do this from within the perl program, not by invoking perl with the -e option. thanks, -- christopher -- To uns

RE: Problem with replacing text in a variable...

2002-04-12 Thread David Gray
> OK! > > my script works! But when I use: > > my $rvar = ; > > I have the same problem! Jesus, that's a hard one :-) After you read it in, do you have a '$' in the string? If so, you need to escape it like so: $rvar =~ s/\$/\\\$/g; That should fix the problem. If it doesn't, could you paste

Re: Problem with replacing text in a variable...

2002-04-12 Thread drieux
On Friday, April 12, 2002, at 04:59 , Wim wrote: > OK! > > my script works! But when I use: > > my $rvar = ; > > I have the same problem! Jesus, that's a hard one :-) are you expecting a single line of input to come at you? if not why not 'nest' it in a line read cycle while() {

Re: Problem with replacing text in a variable...

2002-04-12 Thread Wim
OK! my script works! But when I use: my $rvar = ; I have the same problem! Jesus, that's a hard one :-) Greetz... David Gray wrote: >>An update on previous post... >>It seems that I typed some errors :-( >> >>This is a small rewrite of my script... >>#!/usr/bin/perl >> >>use warnings; >> >>

RE: Problem with replacing text in a variable...

2002-04-11 Thread David Gray
> An update on previous post... > It seems that I typed some errors :-( > > This is a small rewrite of my script... > #!/usr/bin/perl > > use warnings; > > my $var = "test"; > my $rvar = "\$interface"; > my $cmd = "int \$interface\n"; > > print "$var\n"; > print "$cmd\n"; > > $cmd =~ s/$rva

Re: Problem with replacing text in a variable...

2002-04-11 Thread bob ackerman
On Thursday, April 11, 2002, at 10:57 AM, wim wrote: > my $var = "test"; > my $rvar = "\$interface"; > try: my $rvar = '\$interface'; so it doesn't look like a variable to be interpolated when you get to the substitution. > my $cmd = "int \$interface\n"; > > print "$var\n"; > print "$cmd\

Re: Problem with replacing text in a variable...

2002-04-11 Thread wim
An update on previous post... It seems that I typed some errors :-( This is a small rewrite of my script... #!/usr/bin/perl use warnings; my $var = "test"; my $rvar = "\$interface"; my $cmd = "int \$interface\n"; print "$var\n"; print "$cmd\n"; $cmd =~ s/$rvar/$var/g; print "$cmd\n"; If y

RE: Problem with replacing text in a variable...

2002-04-11 Thread David Gray
> I have a problem with substitutions... > In the piece of code, here below, > "display $var1, $var"' should be "display val1, val2"; > I don't see why, but the if condition doesn't seems to > work... and if I remove the if condition, the replacement > doesn't occur... Does any of you know why?

Re: Re: Problem with replacing text in a variable...

2002-04-11 Thread p
Wim, Sorry, I forgot to mention escaping/single quoting the hash keys too... As you defined it, your hash is empty as you are trying to set 'val1', 'val2' to VarValue{undef} ($Var1 hasn't been defined). Try VarValue{'$Var1'} or VarValue{"\$Var1"} Now the string '$Val1' is a the key, not undef.

Re: Re: Problem with replacing text in a variable...

2002-04-11 Thread p
Wim, I can't believe how long it's taken me to figure out what you're on about, and what the problem (probably) is. My brain's far too slow to be at work today :) If cmd came from standard input or something, your script would work. But you're using a string to simulate that input, and because

Re: Problem with replacing text in a variable...

2002-04-11 Thread Wim
Tristan, I'm writing a script to send command from a textfile to cisco devices... I the textfile, I like to have variables, something like conf t int $interface . when my script reads the line, it should replace $interface by the value asked from the value the user enters... $var{$interfa

Re: Problem with replacing text in a variable...

2002-04-11 Thread p
Wim, You're not declaring $var1 or $var2 anywhere. Instead you're assigning 'val1' and 'val2' to elements in the hash %VarValue. So something like... $VarValue{$var1} = 'val1'; print "I like $VarValue{$var1}!"; will print out... I like val1 To define $var1, do something like: $var1 = 'cheese'

Problem with replacing text in a variable...

2002-04-11 Thread Wim
Hello people from the mighty list, I have a problem with substitutions... In the piece of code, here below, "display $var1, $var"' should be "display val1, val2"; I don't see why, but the if condition doesn't seems to work... and if I remove the if condition, the replacement doesn't occur... Does

Re: Replacing text in only certain sections of a file.

2002-02-08 Thread Jeff 'japhy' Pinyan
On Feb 8, Steven M. Klass said: >I am having some problems and I can't seem to get it right. In short, I >want to only modify text in a specific section. That section is denoted >by the following > >*DESCRIPTION > > > >*END > This sounds like a job for the .. operator. Let's see. >Here is w

Replacing text in only certain sections of a file.

2002-02-08 Thread Steven M. Klass
Hi all, I am having some problems and I can't seem to get it right. In short, I want to only modify text in a specific section. That section is denoted by the following *DESCRIPTION *END Here is what I have. I know the problem, I am reading this line by line so when I find the

Re: replacing text, excluding what's between tags.

2001-08-24 Thread Christopher Solomon
I'm not sure exactly what you want to do... Do you want to replace all of the marked a's: On Fri, 24 Aug 2001, Danial Magid wrote: > > This is a link to another place ^ ^ ^ or do you just want to replace the word 'a'? If you just want to repl

replacing text, excluding what's between tags.

2001-08-24 Thread Danial Magid
HI, Here is a snippet of an html page.. This is a link to another place Here is what I am trying to do.. Replace the letter 'a' with the following: "a" I need to replace the letter 'a', only when it's not within the html tags. This is what I tried.. $newline = s/[^<.*?]($pattern).*?[^>]/$pa