system("sed -e '1d' $path" . "$_[0] | more > $path" . $_[0]);
Oops! You want to edit a file "in place", but by redirecting output to the same location as your input is supposed to be, you effectively truncate that file before it can be processed.
When updating file contents you should make sure input and output don't interfere. One approach could be like this: Since you already use perl to read the first line, why don't you just read on until you find a "From" line, and then start copying that and what follows to another file. Finally you can move the result back to the original location.
Of course, perl has builtins that can do most of the work for you. Like, for example:
This snippet removes all lines before the first occurence of a line starting with the four letters F, r, o, m from mail_file, leaving a backup of the original in mail_file.bak.perl -n -i.bak -e 'print if /^From/..-1' mail_file
You should also make sure no mails are delivered while you are working on real life mailbox hierarchies.
In reply to Re: Strange problem trying to clean garbage from start of mailbox file
by martin
in thread Strange problem trying to clean garbage from start of mailbox file
by capoeiraolly
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |