perl.beginners
[Top] [All Lists]

help on replacing text in a file

Subject: help on replacing text in a file
From: Boxingcat
Date: Thu, 01 Nov 2007 10:52:52 -0700
Newsgroups: perl.beginners

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/$mytempfile/$youtempfile/' $hisfile;

The program reports an error:

Scalar found where operator expected at test line 10 near 's/
$mytempfile/$
youtempfile/' $hisfile
missing operator before $hisfile?)
Syntax error at test line 10, near "pi -e"

I am new to perl, please help!!!

thanks.


<Prev in Thread] Current Thread [Next in Thread>