On Tue, Oct 21, 2003 at 02:45:50PM -0400, Raghu Murthy wrote:
> How do I include a sed command in perl.
> 
> If i do sed -e"s\./ ...." file_name it works fine at the command prompt. 
> But if i include the sed command in perl it does not return any value.
> 
> I tried doing system("sed -e"s\./.." file_name"); it does not do anything. 
> Is there something wrong in how i have done it in perl.

Yep. :-)

Check this FAQ

    % perldoc -q "output of a command"
    Why can't I get the output of a command with system()?

    You're confusing the purpose of system() and backticks (``).
    ...

And the manual for system

    % perldoc -f system
    ...
    This is *not* what you want to use to capture the output
    from a command, for that you should use merely backticks or
    "qx//", as described in "`STRING`" in perlop.

So for your example, you'd need something like

    my $output = qx{ sed s/foo/bar/ filename };

-- 
Steve

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to