473,657 Members | 2,355 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Running a Perl script from another Perl script

Hi all,

I have two scripts:

1/ parser.pl which parses a text file and stuffs the relevant data into a
mySQL DB - works fine no probs there

2/ importer.pl which I want to run through all the relevant files in a
directory and run them through parser.pl

I've got importer.pl to the stage where it can run through a directory and
select the correct files to be processed, but I'm not sure how to pass each
file over to parser.pl. I also need it to wait until parser.pl has finished
processing a file before it passes it another file to process.

I've read the fantastic Perl Cookbook but sadly it's leaving me more
confused than enlightened on this particular issue. :(

Cheers,

Bob

--


Aug 2 '05 #1
5 17133
Bob MacBob wrote:
select the correct files to be processed, but I'm not sure how to pass each
file over to parser.pl. I also need it to wait until parser.pl has finished
processing a file before it passes it another file to process.


1) Post to comp.lang.perl. misc instead of this group (comp.lang.perl ).

2a) Use system() for one file at a time.

system './parser.pl',$_ foreach @files;

2b) Use system() for all files at once (assuming that parser.pl is
written to handle multiple arguments in @ARGV).

system './parser.pl,@file s;
-Joe
Aug 2 '05 #2
In article <mJ************ ********@eclips e.net.uk>, Bob MacBob
<b_******@hotma il.com> wrote:
Hi all,

I have two scripts:

1/ parser.pl which parses a text file and stuffs the relevant data into a
mySQL DB - works fine no probs there

2/ importer.pl which I want to run through all the relevant files in a
directory and run them through parser.pl

I've got importer.pl to the stage where it can run through a directory and
select the correct files to be processed, but I'm not sure how to pass each
file over to parser.pl. I also need it to wait until parser.pl has finished
processing a file before it passes it another file to process.

I've read the fantastic Perl Cookbook but sadly it's leaving me more
confused than enlightened on this particular issue. :(


You should rewrite parser.pl so that it implements a subroutine (better
still a subroutine inside a package) and pass the name of the file to
be processed as an argument to the subroutine, rather than a
command-line argument, which is what you might be doing now. Make sure
there are no global variables shared between parser.pl and importer.pl.
Then, it should be easy to execute 'do "parser.pl" ' in importer.pl,
which will make the subroutine(s) in parser.pl available to the
statements in importer.pl.

If you can't get that to work, post some sample programs (not the real
ones, unless they are very short), but post them to comp.lang.perl. misc
(being sure to follow the guidelines for that newsgroup), because this
newsgroup is defunct.

Thanks.

----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Aug 2 '05 #3
Thanks to both Joe and Jim.

I'll give those solutions a go and if I have any more questions, I'll post
on the misc group.

Cheers,

Bob
Aug 3 '05 #4
Thanks to both Joe and Jim.

I'll give those solutions a go and if I have any more questions, I'll post
on the misc group.

Cheers,

Bob

Aug 3 '05 #5
Thanks to both Joe and Jim.

I'll give those solutions a go and if I have any more questions, I'll post
on the misc group.

Cheers,

Bob

Aug 3 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
6544
by: dpackwood | last post by:
Hello, I have two different scripts that do pretty much the same thing. The main perl script is on Windows. It runs and in the middle of it, it then calls out another perl script that then should run on a Unix box I have. Both scripts run ok, except for the part when Windows try's to call out the Unix script. I have it set up where the Unix is mapped through a drive letter and can drop stuff into the Unix box. It is going through another...
0
2020
by: Fabio | last post by:
Hello, there's something I'd like to understand... I want to connect to the MS SQL Server database, get some records, store them into the text file, send the file through VPN connection and then send the email message about the task success or failure. First steps are quite easy but using the VPN connection makes me feel powerless... How can I start the VPN client from the Perl script?
6
10517
by: Pierre-Yves | last post by:
Hello, I would like to prevent my perl program to be executed several times simultaneously (if the program is already running, I would like to display a message like "another instance of this program is already running, please try again in a couple of minutes). For doing this, I guess I have to check the running processes... but I don't know how to do that and how I can identify my program in the running processes.
10
2555
by: shumaker | last post by:
I don't need a detailed description of a solution(although I wouldn't mind), but I am hoping someone could tell me in general the best path to go about accomplishing a task, since I don't know all the capabilities of what I have available. I can learn the details myself I think. I am trying to set this up to be as simple to use as possible since others will be importing data on a weekly or daily basis. I need to import some text files,...
3
4123
by: sir.linying | last post by:
My php script is to call perl scipt which makes use of Spreadsheet::ParseExcel module to parse Excel file. I am able to launch php script from command line so that perl script can run and properly parse Excel file. However, when I put php script on server side and then launch php through client request, perl program can't run. Anyone has any suggestion re how to fix this problem? Thanks a lot, -Ying
0
1418
by: 123jainmin | last post by:
When I ran a perl script named script.pl which have the the follwing line: system("echo hostname = $HOSTNAME > /tmp/myinfo"); I have another shell script script.ksh which simply call script.pl within the script. the permission on script.ksh is: -rwsr-sr-x WHen I ran script.ksh, I got the error message: Insecure dependency in `` while running setuid at script.pl line 4. If I do not use $HOSTNAME in script.pl, I have no trouble at all. Could...
4
3750
by: benwylie | last post by:
I am running IIS 6.0 on Windows 2003. I would like to be able to run a perl script from a web page and include the output. I have tried doing it with an ssi: <form action='docsearch.shtml' method='get'> <!--#exec cgi="/cgi-bin/docsearch.pl--> </form> This correctly ran the script, but it was unable to include the
6
3216
by: aravindtn | last post by:
i have a netwok,and i have a perl script running on a machine(say machine1). the purpose of the script is to login to each of the other machines using ssh. i am able to logon to other machne (say machine2) byusing the following code system("ssh <host_ip>"); after loging on to the network i need to run another perl script that is saved on the machine2. i want it to be done from the perl script running on machine1. i tried to do it by...
10
6960
by: happyse27 | last post by:
Hi All, I got this apache errors(see section A1 and A2 below) when I used a html(see section b below) to activate acctman.pl(see section c below). Section D below is part of the configuration of section c. Not sure where went wrong as the web page displayed internal server error. Also, what is the error 543? and error 2114. Where to find the list of errors in websites as it is not the standard apache error. I could not find...
0
8399
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8827
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8504
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8606
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7337
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2732
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1959
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1622
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.