i posted this today, but better restate it because i'm ready to jump out the window:
my data is below. it does not have columns, but is indented in some places. the ";"'s separate the records.
I need to:
1. open the file (i can do this)
2. read the contents so that the stuff between the ";"'s are stored as separate records, and so i can access each line as a field within that record. I know this has to be a hash, but i'm not having any luck and i think it's because but i can't figure out what the refs are because i don't really have a first column where the indents are.
3. search for a matching word (i can do this)
4. get stuff out of the record with the matching word and print it out. (i can do this)
CODE____________
open(FILE, "$lfilename") or &dienice;
while(<FILE>) {
@row = split(/\;/);
if ($row[0] eq "A001"){
%data;
@data{@fields} = @row;
push @records, \%data;
}
}
close (FILE);
foreach my $ref ( @records ) {
print $ref->{Don't know what to put here};
}
DATA____________
Begin Product A0001
Small gadget
5.00 0.00
0.25 0.00
No ; Tracking Inventory?
/Images/gadget1.jpg
ProdText\A0001.txt
Begin Option Gadget Color
Red
Green
Blue
Yellow
Black
White
End Option
Begin Option Extra Attachment
No Attachment <NoShow>
Attachment ($5.00 extra) <+5.00> <NoTitle>
End Option
End Product
;
Begin Product A0002
Huge Widget
25.00 2.50
20.00 0.00
Yes ; Tracking Inventory?
/Images/gadget2.jpg
ProdText\A0002.txt
Begin Option Widget Color
Red
Green
Blue
Yellow
Black
White
End Option
Begin Option Monogramming
Include monogramming <NoTitle> <Custom:0.05>
No monogramming <NoTitle>
End Option
End Product
;
Begin Product GPY01A1
GPY Angel 1 Print 8.5x11
140.00 0.00
1.00 3.00
No ; Tracking Inventory?
http://www.monkey-n-around.com/GPY/gallery/images/sang1.JPG|http:/
+/www.monkey-n-around.com/GPY/gallery/images/sang1.JPG
ProdText\GPY01A1.txt
SoftGoodControl: ::0:0
PriceCategory: Wholesale:114.00:114.00 Retail:114.00:114.00 Reside
+ntial:114.00:114.00 Commercial:114.00:114.00
End Product
;
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.