Solved

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

Posted on 2000-03-15
6
128 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
6 Comments
 
LVL 5

Accepted Solution

by:
PC_User321 earned 25 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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

708 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now