Hi to all,
thanks for your answers. While you have been answering I was on the search for a solution by myself and I have found one. The major part for me is the change should be saved imedeatly to the file - after deleteing the line, because I need to have the actual status saved in the file even if the script crashes. And I did not want to ope/close/reoepn the file while each loop. I have found also Tie::File and with a litle trick it does exactly what I want.
#!/usr/bin/perl
use strict;
use Tie::File;
tie my @list, 'Tie::File', $list or die "Can't open list of files as array\n";
my $records = @list;
print"## Start: Found $records records in $list ##\n";
my ($count, $counter);
for ($count = 0; $count < $records; $count++ ) {
#The important part ist to keep [0] here because it uses always the first line
my $file = $list[0];
#do some processing with the file from record. . .
#delete line
shift(@list) or die "Can't delete record $file in $list\n";
}
Regards Alex
| [reply] |