Re: talking to Perl for a text-cleanup.

From: Date: Wed, 16 Apr 2003 01:22:28 +0000
Subject: Re: talking to Perl for a text-cleanup.
References: 1 2 3 4 5 6 7 8 9  Groups: php.general 
Request: Send a blank email to php-general+get-144048@lists.php.net to get a copy of this message
On Tue, 15 Apr 2003 20:20:59 +0200, you wrote: >On (15/04/03 12:35), John Nichel wrote: >> Okay, try this..... >> >> $clean_text = $unformatted_text | perl -MText::Autoformat >> -e'autoformat' > >nope, it's not working. Three ways that I know of: 1. Echo the text and pipe it to your command. You have to make sure and escape shell metacharacters: $unformatted_text = escapeshellarg($unformatted_text); $clean_text = `echo $unformatted_text | perl -MText::Autoformat -e'autoformat'` Sorry for the wrapping... 2. Write your unformatted text to a tmp file (making sure it's unique so multiple processes don't clobber each other) and use shell redirection: $clean_text = perl -MText::Autoformat -e'autoformat' < tmp_file 3. As someone else suggested, use proc_open(), and fwrite your unformatted text to the STDIN pipe provided by the proc_open() call. HTH

« previous php.general (#144048) next »