in reply to question on sed

Update: sed doesn't have alternate delimiters, what was I thinking ...
You need to change your sed delimiters as they conflict with the slashes in $c and $b (or you could escape them) e.g
## warn if we get an abnormal exit status system ("sed -e 's[$c][$b]g' $File1 > $Replace_html") == 0 or warn "sed had problems (exit val $?)\n";
Make sure you check your sed exit status in case of errors (check out system for details).
Also beware of using variables called $a or $b due to their automatic global nature (see. sort for more details).

Try this instead as escaping the slashes should do the trick

(my $search = $c) =~ s[/](\\/)g; (my $replace = $b) =~ s[/](\\/)g; system("sed -e 's/$search/$replace/g' $File1 > $Replace_html") == 0 warn "sed had problems (exit val $?)\n";
You also might want to check that $File1 exists and is readable as $Replace_html won't be empty if sed exits normally.
HTH

_________
broquaint

Replies are listed 'Best First'.
Re: Re: question on sed
by LameNerd (Hermit) on May 15, 2003 at 16:46 UTC
    You have to be careful when using system like you are.
    What would happen if some how $File1 was "myfile ;; rm -rf ."?
Re: Re: question on sed
by Anonymous Monk on May 15, 2003 at 16:24 UTC
    looks like it didn't work , ahhhh i am gonna kill myself,