Reading a file

ok, let me explain what I am doing I have a custon list of emails that I need to email. I have a cgiscript that can email them I want to be able to read a file on the server called 'emails.txt' and then put them into a string called addys so my program can work with them...I am very new to CGI. here is an example of what I mean

$addys =  $query->param('addys');

the program uses the string $addys to email the people addys is the emails. I want to read a file on the server and make the file be $addys. Thanks
BrianG14Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ozoCommented:
open EMAIL_FILE,'<emails.txt' or die "Can't open emails.txt for reading because $!";
$addys = join'',<EMAIL_FILE>;
close EMAIL_FILE;
0
BrianG14Author Commented:
okay, thats a nice example and I would like to thank your for posting it but acctully I changed how I want it...I want it so they can type a file name it loads it.

List File: <INPUT NAME='list' TYPE='TEXT'><

thats the input can some one show me how to make it so they can type it in then it loads it and puts it to addy
0
ozoCommented:
use CGI::Carp 'fatalsToBrowser';
$filename = $query->param('list');
open EMAIL_FILE,"<$filename" or die "Can't open $filename for reading because $!";
0
C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

BrianG14Author Commented:
okay, but I need it to read the file line by line and after each line add ac omma so the file would be like this

string1
string2
string3

I want it to take them and make them like this

string1,string2,string3
0
ozoCommented:
chomp(@lines= <EMAIL_FILE>);
$addys = join',',@lines;
0
BrianG14Author Commented:
can to you pease click anwser already so I can give you the points ;]
0
ozoCommented:
use CGI::Carp 'fatalsToBrowser';
$filename = $query->param('list');
open FILE,"<$filename" or die "Can't open $filename for reading because $!";
($addys = join',',<FILE>) =~ tr/\n//d;
close FILE;
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Scripting Languages

From novice to tech pro — start learning today.