LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 06-21-2010, 10:43 PM   #1
ginny2010
LQ Newbie
 
Registered: Jun 2010
Posts: 2

Rep: Reputation: 0
Question Using key to match against source.txt file to add xml tags to names in Perl


Using a list of names (over 4000 of them) painstakingly gleaned from the source file years ago for a database file, I want to match the names against the source file so that they can be updated with the tags <forename></forename> in the original source file.

I placed the list of names in @forenames (only posted a few of them here).

Perl script is:

#!/usr/bin/perl

sysopen(DATA, "+>asource.txt", O_RDWR);

@forenames=(" Alani fratris", "uxori brichtmeri","uxori brihtmari","uxori hugonis","uxori ricardi ","uxori roberti","uxori waldini","uxori willelmi","uxoris alani","uxoris baderun","uxoris gaufridi","uxoris grentonis","uxoris hamonis","uxoris herberti","uxoris hugonis","uxoris oini","uxoris rogeri","uxoris stephani","uxoris thome","uxoris walcini","uxoris willelmi","v","vaganus"
);

@first = (@forenames);

foreach $key (@first)
{
print "<forename>$key</forenames>\n";

}

close(DATA) || die "Couldn't close file properly";

I am able to get the name bracketed by the tags to appear on the console screen but don't know how to apply the output to the source file. Perhaps I need to do a match on the words then some kind of edit to surround the matching words with the xml tags? I'm a rank novice doing this as a labour of love for a friend.

Thank you for any help.
 
Old 06-21-2010, 11:49 PM   #2
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
Quote:
Originally Posted by ginny2010 View Post
...
I am able to get the name bracketed by the tags to appear on the console screen but don't know how to apply the output to the source file.
...
Read

perldoc -f print

and then ask questions if something is not clear.
 
Old 06-22-2010, 11:27 AM   #3
ginny2010
LQ Newbie
 
Registered: Jun 2010
Posts: 2

Original Poster
Rep: Reputation: 0
Cool

Thank you for your prompt reply. It will take me some time to read through and apply the results I've gotten from googling your term, perldoc -f print, but hopefully I'm now on the right track.
 
Old 06-22-2010, 02:16 PM   #4
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
Quote:
Originally Posted by ginny2010 View Post
Thank you for your prompt reply. It will take me some time to read through and apply the results I've gotten from googling your term, perldoc -f print, but hopefully I'm now on the right track.
????

Just enter

perldoc -f print

on command line, in my case it produces just 17 lines of text.

If you do not know what 'perldoc' is, why are you programming in Perl in the first place ? It is as if you do not know what 'man' is, but deal with a UNIXish system.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do you add a .txt file to a domains base directory Trebore General 2 10-14-2009 03:47 PM
display lyrics in banshee(read from 1d3 tags or txt file) sica07 Linux - Software 0 09-23-2009 04:59 AM
shell script to move files from one system to another sytem with file names in a txt coral_km Linux - Newbie 3 02-13-2008 11:23 PM
how to add tags to avi file ? kunalagon Linux - Software 4 11-17-2006 02:57 PM
Does there a software which read RNG format to auto complete tags in XML file? nadavvin Linux - Software 0 11-02-2006 01:49 PM


All times are GMT -5. The time now is 09:11 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration