[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[FWP] Re: Poor reverse polish calculator



In article <Pine.GSO.4.21.0103241010190.17017-100000@crusoe.crusoe.net>,
	Jeff Pinyan <jeffp@crusoe.net> writes:
> On Mar 24, Jeff Pinyan said:
> 
>>  1 while s!(\S+)\s+(\S+)\s*([-+*/])!"$1 $3 $2"!ee;print
>>
>>which is 54.
> 
> Kick me for introducing a bit of readability into that.
> 
>   1 while s!(\S+)\s+(\S+)\s*([-+*/])!"$1$3$2"!ee;print
> 
> 52.
> 

so go all the way, and use perl -pe instead of perl -ne and drop the ;print.
The space between the 1 and the while is also unneeded.

#!/usr/bin/perl -pe
1while s!(\S+)\s+(\S+)\s*([-+*/])!"$1$3$2"!ee

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe