Hi,

I'm writing a little script for removing "rustle" from a log file from chat channels, in order to do linguistic research on them. I took the file and tied it with Tie::File, in order to easily acces it. This probably isn't all necessary here, but I want to modify the file itself, not writing the output to a new one.

The first thing is stripping of a date and time at the beginning of each line. My re seems to be correct, as it works. I do not understand why I need the /g modifier though. If I remove it, only the first line that matches gets stripped. I thought the substitution was started all over again for every line?

Well, in writing this, I solved half of my problem, but one still remains: how can I remove a line? I tried with delete, as you see below, but (of course) this does not work, as $lijn is no array element. How can I totally remove that line from my file?

This is my code:

use strict;
use warnings;
use Tie::File;

my @bestanden_lijst = <*.log>;
for my $best (@bestanden_lijst){
tie my @bestand, 'Tie::File', $best or die "Kon het bestand niet binden: ", $!;
for my $lijn (@bestand){
$lijn =~ s{\[\d+/\d+/\d+\s\d+:\d+\]\s}{}g;
#delete $lijn if $lijn !~ /^<.*>/;
}
untie @bestand;
}


I'm sorry if the variable names feel uncomfortable, I like to program in my own language...

Thanks for reading this far, appreciate any help & suggestions,
Hendrik


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to