From: Paul Lutus Date: 2006-09-20T10:40:05+09:00 Subject: Re: piping input when shelling out Caio Chassot wrote: > > On 2006-09-19, at 22:05 , Paul Lutus wrote: > >> output = `echo #{s} | perl -pe "s/a/x/g"` >> >> I want to emphasize there are a dozen ways to do this. This one >> happens to >> be simple to understand. Another way is File.popen(), but that >> approach >> makes bidirectional communications difficult. > > I thought about doing it with echo but then I'd have to escape the > string, and what if I was dealing with binary data, and all that... > so popen looks like a more robust solution. Yes, except for the fact that you cannot easily find out what the child process created as a result. But yes, if binary data is an issue, File.popen() will reliably stream the data for you. -- Paul Lutus http://www.arachnoid.com