#!/usr/bin/perl -w use strict; my $script = "http://localhost/cgi-bin/test.pl"; my $file = "/tmp/data.txt"; use CGI; my $q = new CGI; print $q->header(); if ( $q->param('delete') ) { my @deletions = modify_file(); show_done_page(@deletions); show_form(); } else { show_form(); } exit; #### SUBS #### sub show_form { my @lines = get_file($file); # remove newlines; chomp (@lines); my @data = map { [ split ':', $_ ] } @lines; my $html = join "\n", map {qq!
$_->[0]:$_->[1]! } @data;
print <
$html
HTML
}
sub get_file {
my $file = shift;
open FILE, $file or die_nice("Could not open $file, Perl says $!");
my @lines = Deleted these entries:\n $html";
}
sub die_nice {
my $error = shift;
print "Sorry an error occurred: $error";
exit;
}
" } @deletions;
print "