LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-18-2012, 11:56 AM   #1
bobanbarnsley
LQ Newbie
 
Registered: Oct 2012
Posts: 4

Rep: Reputation: Disabled
Smile perl script


I am trying to learn perl as part of web development, mainly done using php & mysql.
I am looking for 2 perl scripts.

1. To extract every text messages from every file/scripts (program files) in a directory tree into a text file.

2. Replace every such text message with a corresponding modified/different text message in stored in a text file.

If such a simple script exists, please let me how to get it or download it.

Thanks
Bob
 
Old 10-18-2012, 12:54 PM   #2
qrange
Member
 
Registered: Jul 2006
Location: Belgrade, Yugoslavia
Distribution: Debian stable, amd64
Posts: 814

Rep: Reputation: 32
I think you can achieve that using commands like: grep, awk, sed...
it should be faster.
 
1 members found this post helpful.
Old 10-19-2012, 05:35 AM   #3
bobanbarnsley
LQ Newbie
 
Registered: Oct 2012
Posts: 4

Original Poster
Rep: Reputation: Disabled
Smile scripts prefered

Thank you grange, for the reply.
I prefer to have scripts so that I can extract all the text/string messages into a text file, eliminating duplicates, create another text file with the help of this text file with an equivalent message (probably in another language) and the second script is executed to replace all the original messages with the alternate messages. This has to be achieved for program files or scripts in all directories of the directory of a project (website).

Regards
Bobs
 
Old 10-19-2012, 11:33 AM   #4
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 18,811

Rep: Reputation: 4180Reputation: 4180Reputation: 4180Reputation: 4180Reputation: 4180Reputation: 4180Reputation: 4180Reputation: 4180Reputation: 4180Reputation: 4180Reputation: 4180
Quote:
Originally Posted by bobanbarnsley View Post
Thank you grange, for the reply.
I prefer to have scripts so that I can extract all the text/string messages into a text file, eliminating duplicates, create another text file with the help of this text file with an equivalent message (probably in another language) and the second script is executed to replace all the original messages with the alternate messages. This has to be achieved for program files or scripts in all directories of the directory of a project (website).

Regards
Bobs
Same question as your other thread, but with some details.

If you post what you've written/tried, and where you're stuck, we will be glad to help you. But, this is not the place to come to get your scripts written for you, without any effort on your part. A brief Google search turns up lots, and the Perl documentation itself has examples/samples:

http://perl.active-venture.com/lib/File/Find.html
http://www.perlmonks.org/?displaytyp...node_id=217166
 
Old 10-19-2012, 02:36 PM   #5
bobanbarnsley
LQ Newbie
 
Registered: Oct 2012
Posts: 4

Original Poster
Rep: Reputation: Disabled
Dear TBOne,
Thank you for the information ans suggestion. I am completely new to perl and i thought it will take long to get it myself. Anyway, I will try to do it (at least something) myself nd will come back, for what ever problems I face.
Thank you once again.
Bobs
 
Old 10-19-2012, 02:51 PM   #6
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 18,811

Rep: Reputation: 4180Reputation: 4180Reputation: 4180Reputation: 4180Reputation: 4180Reputation: 4180Reputation: 4180Reputation: 4180Reputation: 4180Reputation: 4180Reputation: 4180
Quote:
Originally Posted by bobanbarnsley View Post
Dear TBOne,
Thank you for the information ans suggestion. I am completely new to perl and i thought it will take long to get it myself. Anyway, I will try to do it (at least something) myself nd will come back, for what ever problems I face.
We will always be happy to help, but if you want someone to write programs for you, you need to be prepared to pay them. The LQ Job Marketplace is on the right hand side of the site. Post what you need and how much you want to pay, and someone will offer to do it for you.

Otherwise, if YOU are trying to learn, having someone else write it for you is a very poor way to do it.
 
Old 10-20-2012, 01:13 PM   #7
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,397
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Traversal of tree-like structures is very often does using recursive techniques. In this case, the algorithm is roughly:
  • go to the specified node (directory)
  • save a list of all leaf nodes (files) at this directory.
  • save a list of all child nodes (subdirectories) at this level
  • iteratively call this function/subroutine for each child node, passing the name of the child node, and adding the returned lists to the lists accumulated for this node
  • return the complete lists

There are other, non-recursive, methods. Hope someone posts some.

--- rod.
 
  


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
Print output of a script to screen using Perl/Multiple installation of Perl Modules metallica1973 Linux - General 1 02-17-2011 05:59 PM
problem with perl modules declaration and perl/cgi script shifter Programming 9 02-24-2010 09:09 AM
call perl script through another perl script with arguments nanda22 Linux - Newbie 21 07-21-2009 12:18 AM
Converting a Windows Perl script to a Linux Perl script. rubbercash Programming 2 07-19-2004 10:22 AM
Including methods from a perl script into another perl script gene_gEnie Programming 3 01-31-2002 05:03 AM


All times are GMT -5. The time now is 01:26 PM.

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration