More questions:
  1. Why does the second sqlSelect statement not have a $mydb reference? At the best you are being inconsistent.
  2. The following code will not handle undefined items gracefully. I hope the database can be guaranteed to return empty strings if no data is present for fields.
  3. You should separate getting the data into %ARTICLE from its presentation in HTML. i.e. separate the Model from the View

sub getLastEnchereurDetail { my $article = $query->param("article"); my $ref_max_enchereur; my $max_enchere; ($ARTICLE{'max_enchere'})=$mydb->sqlSelect1("MAX(prix)", "enchere" +, "ref_article = '$article'"); if ($ARTICLE{'max_enchere'} ne '') { ($ARTICLE{'max_enchereur'},$ARTICLE{'id_enchere'})=$mydb->sqlS +elect1("ref_enchereur,id_enchere", "enchere", "ref_article = '$articl +e' AND prix = $ARTICLE{'max_enchere'}"); # why is this not $mydb->sqlSelect1 like above? my @result = sqlSelect("nom_utilisateur,email,lang,adresse,vil +le,npa,no_telephone,nom,prenom", "personne", "id_personne = '$ref_max +_enchereur'"); ($ARTICLE{'nom_utilisateur_acheteur'},$ARTICLE{'email_ +acheteur'}, $ARTICLE{'acheteur_lang'},$ARTICLE{'acheteur_adresse'}, $ARTICLE{'acheteur_ville'},$ARTICLE{'acheteur_npa'}, $ARTICLE{'acheteur_telephone'},$ARTICLE{'acheteur_nom'}, $ARTICLE{'acheteur_prenom'})= @result; } my $string =<<EOF; <td align="left" width="200"><label id="label_category_name">$SERVER{' +last_enchereur'}</label></td> <td align="left"> <a href="/cgi-bin/recordz.cgi?lang=$lang&amp;session=$session_id&p +age=profil_vendeur&username=$ARTICLE{'nom_utilisateur_acheteur'}" cla +ss="menulink"> $ARTICLE{'nom_utilisateur_acheteur'}</a></label> </td> EOF return $string; }
If you spot any bugs in my solutions, it's because I've deliberately left them in as an exercise for the reader! :-)

In reply to Re^3: perl variable displayed as a hash value by space_monk
in thread perl variable displayed as a hash value by *alexandre*

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.