Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2000-03-15
6
Medium Priority
?
135 Views
Last Modified: 2010-03-05
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

             
0
Comment
Question by:Dnguyen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 5

Accepted Solution

by:
PC_User321 earned 100 total points
ID: 2622635
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
 
LVL 5

Expert Comment

by:PC_User321
ID: 2622650
Hope that helps.
(You can remove the braces from ${Line})
0
 
LVL 16

Expert Comment

by:maneshr
ID: 2623966
can you attach your sample input file and also show how you want the output.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 84

Expert Comment

by:ozo
ID: 2624336
while( <IN> ){ print OUT "<a href="$_">$_</a>"; }
0
 
LVL 84

Expert Comment

by:ozo
ID: 2624350
while( <IN> ){ print OUT qq(<a href="$_">$_</a>); }
0
 

Author Comment

by:Dnguyen
ID: 2632635
Thank you, it worked! I'll release my script to to the world after it's done :)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question