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
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.