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
/ 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]
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
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?
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
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
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
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
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
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
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
[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
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);
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
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;
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
> 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
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
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
> 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
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() {
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;
>>
>>
> 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
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\
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
> 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?
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.
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
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
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'
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
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
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
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
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
35 matches
Mail list logo