CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner: unterminated `s' command: Edit Log



abhi
Novice

Mar 7, 2013, 10:17 PM


Views: 748
unterminated `s' command

Hi,
i am new to perl, learning it.
I wrote following script:

Code
 
#!/depot/perl-5.8.3/bin/perl

@file_list = `cat $ARGV[0]`;
@grep_list = `cat $ARGV[1]`;
$i = 0;

foreach $file_name (@file_list)
{
$g_name = @grep_list[$i];
chomp($file_name);
chomp($g_name);
`sed -i "s/$g_name/$g_name \-name \"replace NUMBER\#1234\"/g" $file_name `;
$i = $i+1;
}


fo example input file may be:
cat file1
abc/xyz/my_file
abc/pqr/other_file2

cat file2
name1
name2

When i execute this script i am getting error:
sed: -e expression #1, char 84: unterminated `s' command

I tried running "sed" from shell its working fine and replacing properly but when i put it in perl script it fails.
Please help.
Also please let me know if in perl, there is some better way of replacing word.


(This post was edited by abhi on Mar 7, 2013, 10:42 PM)


Edit Log:
Post edited by abhi (Novice) on Mar 7, 2013, 10:18 PM
Post edited by abhi (Novice) on Mar 7, 2013, 10:41 PM
Post edited by abhi (Novice) on Mar 7, 2013, 10:41 PM
Post edited by abhi (Novice) on Mar 7, 2013, 10:42 PM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives