Combine many files into one using perl

K

kishore.maheshwari

Hi,

Need some code to read the file name from a given file "listing.txt'
which looks like give here. And combine all the .htm files in that
folder into one file. The file names are index.htm, ch00_01.htm and so
on.

08/19/2002 10:37p 4,238 index.htm
08/19/2002 10:37p 4,238 index.html
08/19/2002 10:37p 7,292 ch00_01.htm
08/19/2002 10:37p 5,249 ch00_02.htm
08/19/2002 10:37p 3,828 ch00_03.htm

Please help,

Thanks in advance.
Kishore
 
P

Paul Lalli

Need some code

jobs.perl.org is ===> that way.
to read the file name from a given file "listing.txt'
which looks like give here. And combine all the .htm files in that
folder into one file. The file names are index.htm, ch00_01.htm and so
on.

08/19/2002 10:37p 4,238 index.htm
08/19/2002 10:37p 4,238 index.html
08/19/2002 10:37p 7,292 ch00_01.htm
08/19/2002 10:37p 5,249 ch00_02.htm
08/19/2002 10:37p 3,828 ch00_03.htm

Please help,

"help" implies that you have made an attempt and would like assistance
in figuring out why it doesn't meet your specifications.

Please post the code you have written so far, and explain how it does
not function the way you would like it to. That way, we have a chance
of helping you correct your errors.

If you just have no idea where to start, I suggest you begin at
http://learn.perl.org, and read the documentation dealing with opening
files, reading files, splitting lines into separate fields, and
printing to files.
perldoc -f open
perldoc -f readline
perldoc -f split
perldoc -f print

Please read the Posting Guidelines for this group. They contain
invaluable information on how to maximize potential help from this
group.

Paul Lalli
 
A

Anno Siegel

Hi,

Need some code to read the file name from a given file "listing.txt'
which looks like give here. And combine all the .htm files in that
folder into one file. The file names are index.htm, ch00_01.htm and so
on.

08/19/2002 10:37p 4,238 index.htm
08/19/2002 10:37p 4,238 index.html
08/19/2002 10:37p 7,292 ch00_01.htm
08/19/2002 10:37p 5,249 ch00_02.htm
08/19/2002 10:37p 3,828 ch00_03.htm

Untested:

perl -le '@ARGV = map /([^ ]+\.htm)$/, <>; print <>' listing.txt

Anno
 
G

greymaus

jobs.perl.org is ===> that way.


"help" implies that you have made an attempt and would like assistance
in figuring out why it doesn't meet your specifications.

Please post the code you have written so far, and explain how it does
not function the way you would like it to. That way, we have a chance
of helping you correct your errors.

I wonder if the produced file would have <html> </html> all through
it, which would look like a mess?.
 
T

Tad McClellan

Need some code to read the file name from a given file "listing.txt'
which looks like give here. And combine all the .htm files in that
folder into one file. The file names are index.htm, ch00_01.htm and so
on.

08/19/2002 10:37p 4,238 index.htm
08/19/2002 10:37p 4,238 index.html
08/19/2002 10:37p 7,292 ch00_01.htm
08/19/2002 10:37p 5,249 ch00_02.htm
08/19/2002 10:37p 3,828 ch00_03.htm

Please help,


What part are you stuck on?

Post the code you have so far, and we will help you fix it.
 
J

John W. Krahn

Need some code to read the file name from a given file "listing.txt'
which looks like give here. And combine all the .htm files in that
folder into one file. The file names are index.htm, ch00_01.htm and so
on.

08/19/2002 10:37p 4,238 index.htm
08/19/2002 10:37p 4,238 index.html
08/19/2002 10:37p 7,292 ch00_01.htm
08/19/2002 10:37p 5,249 ch00_02.htm
08/19/2002 10:37p 3,828 ch00_03.htm


cat `perl -pe'$_=(split" ",$_,4)[3]' listing.txt` > one_big_file



John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top