Paul Johnson wrote: > On Thu, Sep 30, 2004 at 08:00:41AM -0500, Errin Larsen wrote:
> > Hi Perlers, > > On 30 Sep 2004 10:11:29 +0100, Jose Alves de Castro > > <[EMAIL PROTECTED]> wrote: > > > On Wed, 2004-09-29 at 21:25, JupiterHost.Net wrote: > > > > perl -l -00pe's/n/t/;s/"//g;' FILENAME > > > It is my opinion that code should be explained, at least in this list. > And it normally is. But if someone posts a message saying "please do > this for me" without (apparently) making any effort to do it themselves, > then a functioning cryptic one-liner response is a succinct way of > saying that as soon as you put a little more effort into this then so > will we. > > So, we get this as the code Perl is running: > > > > LINE: > > while( <> ) { > > s/n/t/; # Change newlines into tabs > > s/"//g; # Remove all double-quotes > > } continue { > > print or die "-p destination: $!n"; > > } > > > > but with the special $/ = 0 as the input separator and $ = n as the > > output separator! > > > > There! Am I right? This is fun ... we should do this more often! > Pretty close: > $ perl -MO=Deparse -l00pe's/n/t/;s/"//g' > BEGIN { $/ = "n"; $ = "00"; } > LINE: while (defined($_ = <ARGV>)) { > chomp $_; > s/n/t/; > s/"//g; > } > continue { > print $_; > } > -e syntax OK > which shows a little confusion over $/ and $, and an unnecessary in the > initial program. > > This taught me a lot. > Good :-) Thanks for your help guys... But the code is performing the logic only for the first set of lines... After the running the above script, the output looks like Object1<...tab...>Description1 Object2 Description2 Object3 Description3 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>