Hello all,
I have a CGI app. that stores data in a text file of format:
--Start of file
FIELD1: VALUE1
FIELD2: VALUE2
FIELD3: VALUE3
FIELD4: VALUE4
/n
FIELD1: VALUE1
...and so on
Note: FIELD1 is unique, others aren't
My program reads this file and stores the data in an array, and saves it back
as a text file when data has been changed. I am able to add new data, but not
remove it. I'm not sure how to go about it as I need to remove all four
fields for a unique record.
Here's the code for reading in the records and placing it into an array. Some
of you may recognise it as it's straight out of the Perl Cookbook:
open( FILE, "records.dat" ) or die "Can't open record file: $!";
$/ = ""; # paragraph read mode
while (<FILE>)
{
my @fields = split /^([^:]+):\s*/m;
shift @fields; # for leading null field
push(@Array_of_Records, { map /(.*)/, @fields });
}
Since I'm still learning Perl and CGI I don't wholly understand this snippet.
Any help (especially a walkthrough of what's going on and why) would be very
much appreciated.
Geraint.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]