I have a question concerning pulling an alternate field entry from a flat database. Currently, the program below is set to pull the first field from the pipe delineated DB, but I would like to pull the 8th field. How can I accomplish this?
open DATA,$data; $line=<DATA>; @fields=split('\|',substr($line,0,index($line,";"))); %data=(); while (<DATA>) { my(@flds)=@fields; shift(@flds); my(@temp)=split('\|',substr($_,0,index($_,";"))); my($id)=shift(@temp); while ($#flds>-1) { if ($temp[0] eq "no") { $temp[0]=""; } $data{$id}{shift(@flds)}=shift(@temp); } } close DATA; print "Content-type: text/html\n\n"; open TMPL,$catalog; while (<TMPL>) { $line=$_; chop($line); while ($line=~/^(.*?)<!thumb=(.*?)>(.*)$/) { print $1; $id=$2; $line=$3; if ($data{$id}{'thumb'} ne "") { print "<a href=$show_url?database=database&action=view_product +&productID=$2&category=$data{$id}{'Category'}>\n"; print "<img src=${thumb_src}$data{$id}{'thumb'} border=$border + hspace=0 vspace=0 alt='$alt_text $data{$id}{'Name'}' height=65 width +=65></a>"; } if ($data{$id}{'Name'} ne "") { print "<br><font face='$font_face' size=$font_size><SMALL> $da +ta{$id}{'Name'}<BR></SMALL></FONT><font color=red size=+1>"; print '$', "\n"; print "$data{$id}{'Price'}"; } } print $line,"\n"; } close TMPL;
Thank you so much for any assistance you can give.

Edit kudra, 2001-09-05 Elaborated on subject which was 'Database question'


In reply to Database question: pulling a particular field from a flat database by koacamper

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.