
rjoseph
Novice
May 7, 2001, 1:44 PM
Post #5 of 13
(907 views)
|
That is what I was looking for! Ok, so say this is your database: sponsorname|description|yesorno sponsorname|description|yesorno sponsorname|description|yesorno So there are three lines of pipe-delimited text. Say also that this file was called db.txt - here is what I would do to say, print out all of the description fields:
open (DB,"db.txt") or die "Cannot open db.txt: $!\n\n"; while (<DB>) { # Spilt assumes $_ if no varible specified my ($sponsor, $desc, $yesno) = split(/\|/); print "$desc\n"; } And what if I wanted to save all of those fields to a array-of-arrays (assume DB already open, as above)?
my $i = 0; my @data; while (<DB>) { @{ $data[$i] } = split(/\|/); } # And to print the description field from the second line print $data[1][1]; Now, this is all off the top of my head, so there might be some bugs in that code, but I think that you get the idea? If not, just ask! :) Hope this helps! r j o s e p h "Violence is a last resort of the incompetent" - Foundation
|