OK, I am new to perl scripting.
I need help, I have a script that i am trying to do the following:
file1= list of unique ID numbers
file2= list of unique html code with the unique ID numbers within the
code per line(about 16k-bytes each seperated by carage.
For file1.txt
123432
432342
456645
and so on for example..
file2.txt
<html>...... UNIQUE ID..</html>
<html>...... UNIQUE ID..</html>
and so on..
Both are standard text files.
===========UPDATE============
July 4, 2009 12:09:22 AM EST
for example, file1 line 1 has 12345 for example,
file2 has .<html>...... 12345..</html>
on line 1. I need line 1 of file2 to
be made into a new file called 12345.html
==========UPDATE===========
July 4, 2009 12:14:56 AM EST
Now file2 is data_file array,
file1 is names_file array and
the results being several unique (names).html
files.
===========
#!/usr/bin/perl<br>
#read each line in test1.txt into data_file array<br>
$data_file="test1.txt";<br>
open(DATA, $data_file) || die("Could not open file!");<br>
@data_file=<DATA>;<br>
<br>
#read each line in code.txt into a names_file array<br>
$names_file="code.txt"<br>
open(NAMES, $names_file) || die("Could not open file!");<br>
@names_data=<NAMES>;<br>
<br>
#create loop that reads each ID in code.txt (NAMES array), searches fo
+r<br>
#each in array elements for test1.txt (DATA array), redirects a new<br
+>
#(NAMES).html for each element<br>
foreach ( $NAMES )<br>
{<br>
chomp($NAMES);<br>
($NAMES=$DATA<0> > +("$NAMES<0>.html"));<br>
}<br>
<br>
close NAMES;<br>
close DATA;<br>
<br>
I am new to perl but this is absolutely riddled with errors and I have
written this according to examples of similar scripts.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.