For Quality purpouses, [EMAIL PROTECTED] 's mail on Wednesday 11 February 
2004 22:08 may have been monitored or recorded as:

Hi, 

> I'm still working on the script, though it is cleaning up even better, I
> even have it running cleaner by dumping anything not matching some specs.
> What I am trying to figure out though is this:
>
> I have 42 places for the output to go, 1 of those is a constant dump, the
> others are all based on whether or not there is data in a field.  If the
> data is in the field, the data writes to a file with the same name as the
> data checked.  If not then it writes to a global catch-all.

If I recall your last mail correctly you were opening a lot of file handles, 
than running into the switch kind of thing and than closing all the files 
again.
That was: a lot of system calls (open) to eventually write to a few of the 
files in the SWITCH (the accumulated ifs) and then again a lot of sys calls 
to closethem, where you have actually writen to only a few of the opend 
files.

That sounds slow.
Wiggins allready suggested

if (grep $fields[4] == $_, @cities) {
  $tmptxt = $fields[10];
}
else {
  $tmptxt = '1-' . $fields[10];
}

for the first SWITCH like construct.
For the second one id say, make an array of your filenames and use the contend 
of filed[11] as index, like:

my @file_names=qw (/home/multifax/everyone /home/multifax/
pack-fishbait .....);

if (defined $file_name[$fields[11] - 102]) {
  open OUTFILE ">${file_name[$fields[11] - 102]}" or die "Cant open 
${file_name[$fields[11] - 102]}:$!";

  print OUTFILE "[EMAIL PROTECTED]"; #your trailing ID
  close OUTFILE; 
 }
else {
  open OUTFILE ">default.out" or die "Cant open default.out :$!";
  print OUTFILE "[EMAIL PROTECTED]"; #your trailing ID
  close OUTFILE; 
}

However, this assumes that you have continous values from 102 upwards in 
$fields[11] - if not, come up with a formula that gives you the index of the 
wanted filename in @file_names depending on $fields[11]or use a hash instead:

$file_name{102}="whatever/filename/you.want";

I suggest you tell us, what the logic behind all these different files is, ie, 
what goes where of which cause: maybe someone can come up with a hash 
structure that incoorporates this knowledge.
Dont open and close 42 files if you only will ever print to 2 of them.

Enjoy, Wolf






--
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