[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] <MAIL> chunk 113. ?




[In a message on Mon, 11 Oct 1999 09:45:17 EDT,
	""Karl Long"" wrote:]
>This works fine but when I add the $file++; then I get:
>Use of uninitialized value, <MAIL> chunk 113.
>
>thanks,
>karl
>
>
>#!perl -w
>
>$inPath = "test y";
>
>$outPath = "test x";
>
>$file=0;  #init my file count
>
>open (MAIL, $inPath) || die "can't open: $!";
>open (MAILOUT, ">$outPath$file.html") || die "can't open: $!";
>@a = <MAIL>;
>foreach (@a) {
>	 chomp;
>	if (/From:/) {
>	$file++; #if I take this out it runs fine
>	#if I leave it I get # Use of uninitialized value, <MAIL> chunk 113.
>	$auther[$file] = $_;
>print STDOUT "this is $auther[$file] and the file is $outPath$file\n 
>and this is the @auther\n\n";
>		}
>}
>close (MAIL) || die "can't close  MAIL: $!";
>close (MAILOUT) || die "can't close  MAILOUT: $!";

A more typical perl routine wouldn't attempt to read the entire inbox
in one fell swoop into memory.  This can cause bizaar memory problem
(I've seen it before on my Mac, but never my .5gig Ultra2 sparcstaton)
I.e. (OK, I also threw in a slight mod on how I handle looking for
specific things by using next.  Oh, and one more thing, you probably
didn't really mean to look for "From:" inside a message, but "^From:"):

#!perl -w

$inPath = "test y";
$outPath = "test x";
$file=0;  #init my file count

open (MAIL, $inPath) || die "can't open: $!";
open (MAILOUT, ">$outPath$file.html") || die "can't open: $!";
while (<MAIL>) {
      chomp;
      next unless /^From:/;
      $file++;
      $auther[$file] = $_;
      print STDOUT "this is $auther[$file] and the file is $outPath$file\nand this is the @auther\n\n";
}
close (MAIL) || die "can't close  MAIL: $!";
close (MAILOUT) || die "can't close  MAILOUT: $!";

Sean

# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org