Read a file and output to a new file... plz help

here's a cut/paste of my code:

$INFILE="list.txt";
$OUTFILE="out.txt";

open(IN,"$INFILE");
@lines=<IN>;
close(IN);

open(OUT,">$OUTFILE");          
foreach(@lines){
print OUT "@lines";
}
close(OUT);


*The problem is I want it to print out each line with extra characters but it is messing up... I can't figure out why. ex:
print OUT "a @lines b";
would give someting like this in the text file:
ab blah <which is a line in the txt file.


What I'm trying to do is open a input txt file and read that file then write each line to a new file that will add extra words that I place in such as <a href=\"@lines"\>@lines</a> to make each line a URL but it is messing up.

If you can change my code around to make this work or re-write it entirely, please do. I need an answer ASAP! thank you!

Zoned

             
DnguyenAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
PC_User321Connect With a Mentor Commented:
open(IN, $INFILE);
@lines=<IN>;
close(IN);

open(OUT,">$OUTFILE");          
foreach $Line (@lines){
   chomp $Line;
   print OUT "<a href=${Line}></a>\n";
}
close(OUT);
0
 
PC_User321Commented:
Hope that helps.
(You can remove the braces from ${Line})
0
 
maneshrCommented:
can you attach your sample input file and also show how you want the output.
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
ozoCommented:
while( <IN> ){ print OUT "<a href="$_">$_</a>"; }
0
 
ozoCommented:
while( <IN> ){ print OUT qq(<a href="$_">$_</a>); }
0
 
DnguyenAuthor Commented:
Thank you, it worked! I'll release my script to to the world after it's done :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.