I have a delimited file that is formatted like this:
Altech|[EMAIL PROTECTED]:[EMAIL PROTECTED] Specialties Steel Corp.
|[EMAIL PROTECTED] Specialty Steel Corp.
|[EMAIL PROTECTED]|[EMAIL PROTECTED]:[EMAIL PROTECTED]
Starwood|[EMAIL PROTECTED] foods|[EMAIL PROTECTED]:[EMAIL PROTECTED]
starwood|[EMAIL PROTECTED]:[EMAIL PROTECTED]
Authentic Fitness Corp.|[EMAIL PROTECTED]
Basically that's one continuous line; there are no line breaks. Don't ask
me, I just inherited the file. The records are delimited by * and then each
individual record is split as company/email by a pipe | character. If more
than one person wants to track a particular company, their e-mail address is
appended to the first with a colon and split on same for processing.
My question is this: If I want to remove an e-mail address from the list
associated with one of the companies, as in deleting that address from the
flat file, how would I go about it?
Any help is appreciated.
Thanks,
Scot R.
The input is coming from a form that is generated by the data file itself
like so:
#!/usr/bin/perl -w
use CGI;
use CGI::Carp qw(fatalsToBrowser);
$q = new CGI;
$file = '/path/to/file';
print $q->header;
open(TRACKFILE,"<$file") or die "Could not open datafile: $!";
while($line = <TRACKFILE>) {
@entries = split(/\*/,$line);
}
close(TRACKFILE);
print <<FORM_ACTION;
<form action="trackdel.cgi" method="post">
<table border="1" cellpadding="1" cellspacing="1">
FORM_ACTION
foreach $entry(sort(@entries)) {
chomp($entry);
$entry =~ s/::/:/g; # this is just to clean up one
# entry that seems errant but I
# don't want to mess with it
($company,$address) = split(/\|/,$entry);
if($address =~ /:/) {
($addy1,$addy2) = split(/:/,$address);
print <<EOF;
<tr>
<td><input type="checkbox" name="deleteentry"
value="$company|$addy1|$addy2|*"></td>
<td>$company</td>
<td>$addy1,$addy2</td>
</tr>
EOF
}
else {
print <<EOF;
<tr>
<td><input type="checkbox" name="deleteentry"
value="$company|$address"></td>
<td>$company</td>
<td>$address</td>
</tr>
EOF
}
}
print <<END_OF_FORM;
</table>
<br><br>
<center><input type="submit" name="Submit" value="Delete highlighted
entry"></center>
</form>
</body>
</html>
END_OF_FORM
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]