473,231 Members | 1,739 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,231 software developers and data experts.

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 17121
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,@files;
-Joe
Aug 2 '05 #2
In article <mJ********************@eclipse.net.uk>, Bob MacBob
<b_******@hotmail.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
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...
0
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...
6
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...
10
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...
3
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...
0
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...
4
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'...
6
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...
10
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...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...

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.