Link to home
Start Free TrialLog in
Avatar of dileepav
dileepavFlag for India

asked on

How to create and compile a perl script?

Hi Experts,

I want to study perl script, could you please help me in finding out how to create  and compile a perl script?

Thx
Dileep.
Avatar of sjm_ee
sjm_ee
Flag of United Kingdom of Great Britain and Northern Ireland image

perl programs are usually not compiled but executed directly from source code. Create your source code with any text editor. Run the program using the "perl" command. The first program that most programmers write is "hello world". See the following URL for "hello world" in perl.

http://perl.about.com/od/gettingstartedwithperl/a/testperl.htm
Avatar of Amick
Perl is ordinarily a semi-compiled language, although there are utilities that generate c code from perl and then compile that.  It ends up being pretty fast though in any case.

There are many Perl tutorials on the web, and the documentation supplied with Perl is extensive and complete.

CPANis a good place to learn about the language.
Avatar of dileepav

ASKER

Currently I am supporting an application, the database (Oracle 10g) is hosted in UNIX, The program is developed by another person who is not in our team now. I am the single point of contact for this application. We have development Environment as well as Live Environment. I wanted to know how this program will be deployed in DEV & PROD, how can I find out that, and How can i understand the flow of this application. For example how can I print a query etc, the program is using lots of queries for interacting with the db.

THx
Dil.
I present to you a very old and famous resource to learn the basics of Perl.  You can go over it in one day.  It is very readable and despite being very old, is one of the best tutorials of Perl ever written.  It is not advanced at all.  It just introduces you to Perl in a day in the most friendly way.

I present the Camel tutorial
http://www.comp.leeds.ac.uk/Perl/start.html
Can we create and run perl program in Windows XP?

Thx
Dil
perl is an interpreted language.

http://www.perl.org/get.html
Yes, you can install perl from activeperl
Have not used the strawberry perl.

Activeperl will likely include all the modules you need.
Could you add detail to your deployment?

Are you looking through the existing perl scripts to understand what they do and their purpose?
Hi Arnold,

The first step I am trying to do is, I need to find out the how this program is deployed in PROD and DEV, then which is the best way to debug and understand the flow, then If some errors happened in PROD How can I understand where the error has happened? Because Now I am the SPOC for this application I have experience in supporting and development of ASP and ASP.NET web applications as well as little bit UNIX and Oracle.

Thx
Dil
First thing first, how is this application accessed?  Are you using a web interface (PHP)?

The issue with this question is that you start with how to while you first need to get info on how the application is used.
Once you know how it is used, it is easier to narrow down what might be involved in deploying it.

Presumably this is a PHP based web application.

You could approach it the same way you would have if this was an ASP driven site that you are now in charge of supporting.

Do you have access to zend studio which is likely what would have been used to create/manage a PHP based app.
This is not a PHP Web Application, Business Users are accessing this application thorugh a front end program which is supplied by a third party company, This front end program is taking the data from the Oracle DB, this DB is hosted in UNIX server. We have a relay program, which is accepting feed from Mainframe System, when we run the relay program it will take this feed and upload the database, the front end program is taking data from this database and displaying it to the business users.

Also, this perl program is running twice everyday for example one is at BST 2:00 pm, accepting the feed and do different processes and uploading the data to the database.

Hope this asnswers your questions, but I don't know how it is deployed, Please can you help me to find out this.

Thanks
Dil
My guess will be that it is copied.  You could use a packaging tool to deploy it.
Is it running as a service or does it run as a scheduled task?
This is more of a custom setup.
Is the perl program running as a daemon i.e. listening for connections on a specific port?
This program might be a post/pre processing script that merges newly entered data/or clears up/archives marked data.

On which system does it run? Does it run on the unix system?
 
It is running as a scheduled task.

Absolutely this is a custom setup.

Relay is the perl program written by some developers, and they left the company.

Relay is running on a thread.

Yes, this is a post/pre processing script that merges newly entered data/or clears up/archives marked data.

The databse is hosted on unix, some times in development environment, we are running the perl program manually from UNIX using putty.

The front end application in which the business users are using is installed in Windows application, and Dotnet 2.0 framework is mandatory for this.

Thx
Dil.



dileepav,

It will only take an afternoon to become conversant with perl.  The perl debugger is easy to use and the language is straightforward..  The links at CPAN cover it all, including documentation, tutorials, and modules to do just about every task you can imagine.  The camel tutorial mentioned above is a classic of perl literature.  

Just take the time to familiarize yourself with the language, then you can examine your perl environment on the servers and walk through your code confidently.
If some thing happened in PROD which is the best way to debug and under stand where this has happened?
Use the perl debugger.  There is a tutorial at cpan.

http://perldoc.perl.org/perldebug.html
Hi Arnold,

What do you feel? Please share your views as well.

Thx
Dil.
Based on the information you've provided thus far, the only way the perl breaks if if the system on which it runs dies. or the database schema is changed.

I am getting a clearer picture into your environement/setup but it is still missing a large amount of information.


When you say something breaks it can mean many things.
I.e. the .NET application can not connect to the mainframe/database?

My advice would be the best way to know where to look when something breaks, is to know the operation of the application the user is using so that when you are told, "When I do X, I get an error Y" you know where to look.
Do you have access to the code on the front end? Presumably based on your knowledge of ASP ASP.net and the windows environment you could get a clearer picture of the front end. What/how it interacts with the backend and then determine what the perl script does.
One way you can replicate its function with an application that you are familiar with.  This way you will have two mechanisms to do the same thing as a backup as well as during this process learn perl.

Based on the question and what it took to get you to fill in the blanks, your approach was seemingly what should I do when things break or Where do I start when things break.

Could you provide all the technical details, i.e.
database server version
unix OS version
windows OS version
Mainframe type

Possibly the perl script was created because the oracle version that was initially setup did not have a job scheduler built in. And if it has since been upgraded to a newer version that has that, the perl script can be replaced with a scheduled job within the Oracle database server setup.

The thread of perl that provides the communication/interaction with the (relay) has to be determine what it provides. I.e. does it get a connection from one and establishes a connection to the other while translating/transforming data on the request side, on the response side or both.

The database version is: Oracle 10g
Windows OS Version: Windows 2000
Mainframe type: ZOS.

I don't have access to Frontend source code, becasue it is a third party application, we will be getting the setup file, double clicking that will install the application, then we need to create a DSN, after that we would be connecting to the db using the DSN. Our work comes at the backend side, like you know, though relay is a scheduled task, it is doing series of tasks called L2, L3, L4 etc..., some times that will fail at that time I need to find out where it has failed thorugh looking at the perl script, after that I need to rerun the batch file, for example if L2 fails I need to rerun the L2Rerun script. that is the reason I wanted to know how can I debug the relay program, that will fix this issue.

hope this answers your question.

THx
Dil
Also, in PROD it is scheduled task, but in development we are running it manually, after logging into UNIX server by using putty.

Thx
Dil.
Historically, what were the problems encountered?  Is it an issue that the front end keeps working but those changes/additions do not propagate which is what the scheduled perl script does.

You could of course add mechanism to the perl script to generate an email to notify you when it runs and what succeeded and more importantly if something failed, where and possibly what the error was.
i.e. it tried to execute an query, but oracle rejected it etc.

All I can do is suggest approaches to consider, there is no way to provide a solution.

Good luck.
Example Issue Occured Earlier:
=========================
L2L3 Run Out Of Order


Problem

Due to data errors we have had to hold L2L3 for a feed for 20060331. However, we have inadvertently run L2L3 for this Lot Type for 20060410 and 20060411. There is no data to process for those days (it is only a monthend feed). Do we need to take any action before running L2L3 for the missing days ?


Solution

One of the validations we perform inside the script checks that the previous feed exists in the storage area. In your case, this validation fails.

Rather than providing a workaround script(that doesn't have this validation) to remove the feed, I believe we can simply ignore that the feed 20060410 exists in the storage area. I verified that this will not impact further processing.

So the next steps would be:

3) RunUnprocessFeedFromStaging.fas "lotType=10" "LotDate=20060331"
--> Removes data that doesn't pass validation from the staging area

4) RunPrepareDB.fas "lotType=10" "LotDate=20060331"
6) RunPrepareDB.fas "lotType=10" "LotDate=20060411"
--> Fills in the gaps left by previous steps; reenters feeds in the system.

7) Reload the data on 20060331(OST)
ASKER CERTIFIED SOLUTION
Avatar of arnold
arnold
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thx Experts.