How to execute piped command using exec or system

Hi All,
I want to execute a piped command like 'ls /opt | grep xml' using array as parameters list. How can I do that?

Could you detail your requirement ? I cudn't get your exact requirement.

rgds,

Srini

Hi All,
I want to execute a piped command like 'ls /opt | grep xml' using array as parameters list. How can I do that?

Hi Srinivas,
Actually here i get the command as parameter. Initially I was executing it as `$cmd`. But it has got security issues. So now I want to use exec to do that.
What I did was :
@arrcmd = split(\ \,$cmd);
exec(@arrcmd);
Now assume that user gives a command which contains pipes. as mentioned above . in this case the parameters converted to array do not work. So i want solution to do the same in case of piped commands.

Thanks,
Akshay.