I have a flat-file DB and I want the script to just access the rows starting with the prefix
“B00” so that when I print the data in a HTML file it DOES'NT print ALL the records.
The code I am using is
open(INF,"products") or dienice("Can't open productsDB: $!");
@data = <INF>;
close(INF);
foreach $i (@data) { chomp($i); ($productId,$nmPrice,$mPrice,$itemName
+,$shortdesc,$image,$address) = split(/\|/,$i);
The database I am using is a flat file one like below but much much bigger, called
“products”
B001|72.00|65.00|Medicine Hands|Book|medicinehands.gif|medicinehands.html
B002|72.00|65.00|Amma Therapy|Book|medicinehands.gif|medicinehands.html
C001|55.00|65.00|T-shirt|Clothing|tshirt.gif|tshirt.html
C001|100.00|200.00|Jacket|Clothing|jacket.gif|jacket.html
X001|400.00|567.00|Golf Clubs|Sport|golf.gif|golf.html
When I print the data in the HTML file it prints all the records.
I.e. when I use the following command
print qq~ $itemName, $nmPrice ~;
it prints…
Medicine Hands, 72.00
Amma Therapy, 72.00
T-shirt, 55.00
Jacket, 100.00
Golf Clubs, 400.00
I only want to access the rows starting with the prefix “B00” so that
it prints only
Medicine Hands, 72.00
Amma Therapy, 72.00
Thanx in advance
Mark
inlimbo17@hotmail.com
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.