>>>>> "AQ" == Ala Qumsieh <[EMAIL PROTECTED]> writes:

  AQ> Vicki writes:

    > if (...) {
    >   my @item_parts = split(/\n/, $item);
    >   printf ORDER ("\n%4d   %-50s   %3.2f      %3.2f\n",
    >   $quantity, $item_parts[0], $price, $ext);
    > } else {
    >   printf ORDER ("\n%4d   %-50s   %3.2f     %3.2f\n",
    > }                 $quantity, $item, $price, $ext);

  >> if (...) {
  >> my @item_parts = split(/\n/, $item);
  >> printf ORDER ("\n%4d   %-50s   %3.2f      %3.2f\n",
  >> $quantity, $item_parts[0], $price, $ext);
  >> } else {
  >> printf ORDER ("\n%4d   %-50s   %3.2f     %3.2f\n",
  >> }                 $quantity, $item, $price, $ext);

  AQ> Another reason to use Emacs :)

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. :)

uri

-- 
Uri Guttman  ------  [EMAIL PROTECTED]  -------- http://www.stemsystems.com
-- Stem is an Open Source Network Development Toolkit and Application Suite -
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org

Reply via email to