First and foremost, I'm a novice.
Just want to make that clear because some of what I may ask may sound stupid but I'm trying to understand here so any help would be appreciated.
I'm working on extending a function in MailScanner ( that will allow me to implement priority service levels on my gateways. So looking through the MailScanner code, I found some examples and managed to write some functions that look like they should work. What it is supposed to do is to read a directory, store all the files in that directory as an array then open up each file and store the values as another array that I can use later to make queuing decisions on later. The direcotry will contain at least two files. One file will be named "default". It will contain a single column file of all domains that are supposed to get priority treatment. All other files will be domain related files where individual email addresss can get priority treament.
So I don't fill the post with text, I'll only post snippets of code where I am a bit confused or need further explanation. Google is hard to search for stuff like "perl -> array"
Just for clarification, the last line in that says "read any file" right?
Now, this is where i'm confused a bit. I think this is where the array gets stored as "$prioritydefaultlist". Is this the case? And what does the last line do? And what does the '1' signify? Furthermore I actually need to process two files; the default file and the other domain files. But I'm not sure how I go about doing that. I want to read the directory then first, process the default file. After that, I wan to then process all other files. How do I do this?
TIA
Errol
Just want to make that clear because some of what I may ask may sound stupid but I'm trying to understand here so any help would be appreciated.
I'm working on extending a function in MailScanner ( that will allow me to implement priority service levels on my gateways. So looking through the MailScanner code, I found some examples and managed to write some functions that look like they should work. What it is supposed to do is to read a directory, store all the files in that directory as an array then open up each file and store the values as another array that I can use later to make queuing decisions on later. The direcotry will contain at least two files. One file will be named "default". It will contain a single column file of all domains that are supposed to get priority treatment. All other files will be domain related files where individual email addresss can get priority treament.
So I don't fill the post with text, I'll only post snippets of code where I am a bit confused or need further explanation. Google is hard to search for stuff like "perl -> array"
Code:
my($dirname, $prioritydefaultlist) = @_;
my($dir, $filename, $fh, $domains, $lines);
$dir = new DirHandle;
$dir->open($dirname) or return 0;
$lines = 0;
$domains = 0;
while ($filename = $dir->read()) {
next if $filename =~ /^\./;
Just for clarification, the last line in that says "read any file" right?
Code:
$fh = new FileHandle;
$fh->open("$filename");
$filename = lc($filename);
while(<$fh>) {
chomp;
s/#.*$//; # Strip comments
s/\S*:\S*//g; # Strip any words with ":" in them
s/^\s+//g; # Strip leading whitespace
s/^(\S+)\s.*$/$1/; # Use only the 1st word
s/^\*\@//; # Strip any leading "*@" they might have put in
s/^\s*\@//; #No usernames allowed here
next if /^$/; # Strip blank lines
$lines++;
$prioritydefaultlist->{$filename}{lc($_)} = 1;
}
Now, this is where i'm confused a bit. I think this is where the array gets stored as "$prioritydefaultlist". Is this the case? And what does the last line do? And what does the '1' signify? Furthermore I actually need to process two files; the default file and the other domain files. But I'm not sure how I go about doing that. I want to read the directory then first, process the default file. After that, I wan to then process all other files. How do I do this?
TIA
Errol