Link to home
Start Free TrialLog in
Avatar of jmingo
jmingo

asked on

Printing 2 Arrays??

here's my code.. $emailfile string for example would be "test-user1.html, test-user2.html" i want to break them up which i'm doing but how can i print it out??


my @mailnames=split(/ *, */,$mailperson) ;
foreach(@mailnames) {

open(SENDMAIL, "|$sendmail -t") || die "Unable to open sendmail";

print SENDMAIL "to: $_\n";
print SENDMAIL "BCC: $bccemail\n";
print SENDMAIL "CC: $ccemail\n";
print SENDMAIL "from: $fromname <$fromemail>\n";
#print SENDMAIL "Reply-to: $fromname <$fromemail>\n";
print SENDMAIL "MIME-Version: 1.0\n";
print SENDMAIL "subject: $subject\n";
print SENDMAIL "Content-Type: text/html; charset=us-ascii\n\n";


my @filenames=split(/ *, */,$emailfile) ;


open (HTMLFILE, "/usr/home/test/upload/ ?? ? ?? ??  ") || die "can't open HTML file: $!";
while (defined($line = <HTMLFILE>)) { print SENDMAIL $line; }
close (HTMLFILE) || die "can't close HTML file: $!";

}

close(SENDMAIL);

}


thanks
Avatar of jmingo
jmingo

ASKER

sorry, ignore the { in here

close (HTMLFILE) || die "can't close HTML file: $!";

}
Avatar of ozo
{local @ARGV=map{"/usr/home/test/upload/$_},split(/ *, */,$emailfile);
  while( <> ){ print SENDMAIL; }
}
Avatar of jmingo

ASKER

so what does that replace?? what's the complete new code ??

thanks!
Avatar of jmingo

ASKER

so this code is going to email a html file also right??
That replaces

  my @filenames=split(/ *, */,$emailfile) ;

  open (HTMLFILE, "/usr/home/test/upload/ ?? ? ?? ??  ") || die "can't open HTML file: $!";
  while (defined($line = <HTMLFILE>)) { print SENDMAIL $line; }
  close (HTMLFILE) || die "can't close HTML file: $!";

Assuming I understood what you meant to do with that code.
Avatar of jmingo

ASKER

that code causes an error. the script works when i take out your code... any ideas??? thanks again.

my @mailnames=split(/ *, */,$mailperson) ;

foreach(@mailnames) {

open(SENDMAIL, "|$sendmail -t") || die "Unable to open sendmail";

print SENDMAIL "to: $_\n";
print SENDMAIL "BCC: $bccemail\n";
print SENDMAIL "CC: $ccemail\n";
print SENDMAIL "from: $fromname <$fromemail>\n";
print SENDMAIL "MIME-Version: 1.0\n";
print SENDMAIL "subject: $subject\n";
print SENDMAIL "Content-Type: text/html; charset=us-ascii\n\n";


{local @ARGV=map{"/usr/home/winstorm/public_html/cma/upload/$_},split(/ *, */,$emailfile);
while( <> ){ print SENDMAIL; }
}

close(SENDMAIL);

}
Avatar of jmingo

ASKER

changed it to this

{local @ARGV=map "/usr/home/winstorm/public_html/cma/upload/$_" ,split(/ *, */,$emailfile);
while( <> ){ print SENDMAIL; }
}

works... kinda. but it sends 2 html files to each user. i want to send for ex. test-user.html to user1@here.com and test-user2.html to user2@here.com if i'm passing a URL like this

http://1.1.1.1/test.cgi?user=user1@here.com,user2@here.com&emailfile=test-user1.html,test-user2.html

thanks
ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jmingo

ASKER

so if it was in an upload directory i'd put something like this

open (HTMLFILE, "/usr/local/test/upload/<$filenames{$_}") || die "can't open HTML file: $!";

???
Avatar of jmingo

ASKER

open (HTMLFILE, "</usr/home/winstorm/public_html/cma/upload/$filenames{$_}") || die "can't open HTML file: $!";


this did it... thanks so much for your help!!