Thread Eine Zeile in einer text.txt löschen: Eine Zeile in einer text.txt löschen (2 answers)
Opened by Gast at 2004-04-09 21:56

renee
 2004-04-09 22:15
#29169 #29169
User since
2003-08-04
14371 Artikel
ModeratorIn
[Homepage] [default_avatar]
@format_c: Macht nix :)

Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#! /usr/bin/perl

use strict;
use diagnostics;
use CGI;
use CGI::Carp qw(fatalsToBrowser);

my $cgi = CGI->new();
my %params = $cgi->Vars();
print $cgi->header(-type => 'text/html');

my $string = $params{Vorname}.'|'.$params{Nachname}.'|'.$params{Strasse}.'|'.$params{Nr}.'|'.$params{PLZ}.'|'.$params{Ort}.'|'.$params{Tel}.'|'.$params{EMail}."\n";

my $file = './data.txt';

open(R_FILE,"<$file") or die($!);
my @entries = <R_FILE>;
close R_FILE;

foreach(@entries){
if($_ eq $string){
$_ = "";
}
}

open(W_TXT,">$file") or die($!);
print $_ for(@entries);
close W_TXT;

print "Der Eintrag ".chomp($string)." wurde gelöscht";
OTRS-Erweiterungen (http://feature-addons.de/)
Frankfurt Perlmongers (http://frankfurt.pm/)
--

Unterlagen OTRS-Workshop 2012: http://otrs.perl-services.de/workshop.html
Perl-Entwicklung: http://perl-services.de/

View full thread Eine Zeile in einer text.txt löschen: Eine Zeile in einer text.txt löschen