At 14:04 -0500 2/17/02, Uri Guttman wrote:
>another reason to write better perl code. the two printf's are so
>similar that they should be reduced to one and only the 2nd arg needs to
>be dealt with.
>
>
>       my $p_item = ( ... ) ? (split( /\n/, $item ))[0] : $item ;
>       printf ORDER ("\n%4d   %-50s   %3.2f     %3.2f\n",
>               $quantity, $p_item, $price, $ext);
>
>that eliminates the brace issue, and the duplication of the printf
>format (which is annoying to have to change in both places later).
>
>better code is what i call fun. :)

You realize, don't you, that I didn't post the whole script...?

There is also a loop that prints the rest of @item array...

Also (especially since I am writing this for a client whose Perl knowledge is
very slight) it's arguable whether this is all "better".  Cute - yes, heavily
idiomatic - natch, obfuscated - surely, but better... eh.

p.s. to Bill -OSX- Jones, I do use BBEdit, the only real Perl editor.  But
this was some wort of cut-paste error.  Not sure still how it got there.
-- 
- Vicki

Vicki Brown     ZZZ                  Journeyman Sourceror:
P.O. Box 1269      zz  |\     _,,,---,,_        Scripts & Philtres
San Bruno, CA       zz /,`.-'`'    -.  ;-;;,_     Perl, Unix, MacOS
94066     USA         |,4-  ) )-,_. ,\ ( `'-'
mailto:[EMAIL PROTECTED]  '---''(_/--'  `-'\_)  http://www.cfcl.com/~vlb

Reply via email to