Perl Question on How to Design an Effective Script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Perl Question on How to Design an Effective Script
# 1  
Old 10-05-2009
Perl Question on How to Design an Effective Script

Hello All,

This is my situation and I am new to perl scripting so I am trying to figure out the best way to tackle this problem. I need help in creating the logic to analyze the data.

Problem: I need to access an oracle database, gather information from a specific query and then analyze the query results. There are two pieces of information that are retrieved from the db, a number and a name. I need to analyze the number as well as the name. For the number it will have to be between 500 or 1000 to be acceptable. For the name I will have a static list and the query name will have to be on the list if it is not then an error will have to be outputted.

What I have done so far:
I am using the perl dbi/dbd module with oracle. I am able to access the db, run the query, and get the results from the db. I am gathering the information into an array ref. To print it out just to see the output I run a foreach.

Code:
my $array_ref = $sth->fetchall_arrayref();

foreach my $row (@$array_ref) {
    ### Split the row up and print each field ...
    my ( $feeder_qty, $feeder ) = @$row;
    print "Items: $feeder_qty, from feeder $feeder\n";
}


Question:
My issue is how can I put my conditional logic in? Is an array_ref the correct method? I am trying to grab the data, close the db connection and then process the data. Trying to keep any database connection activity to a minimum. Can I manipulate the array_ref similar to the way the foreach statement does?

Thank you in advance,
-jack
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Programming

Not a repeated question (Perl Script Create Football Formation)

https://www.unix.com/programming/252468-perl-script-create-football-formation.html https://www.unix.com/members/43551.html, it is not repeated question. please read it before u block my question. Unblock it for me. Thanks:mad: (0 Replies)
Discussion started by: Tzeronone
0 Replies

2. Shell Programming and Scripting

wrapper script design for gnu ed text editor i/o

Hi. I'm having trouble writing a wrapper script for the command line text editor gnu ed. I want to be able to run the following algorithm on ed: 1. Display, on stdout, a command which I intend to feed into ed (before I actually feed it to ed). 2. Actually feed the command into ed's stdin.... (2 Replies)
Discussion started by: vomv1988
2 Replies

3. Shell Programming and Scripting

Perl script question

Hi, I have a unix machine that hosts 5 oracle databases. Each database has its own "ORACLE_HOME" with is actualy an oracle software . Each software is installed in its own directory. For example : /u01/app/oracle/product/11.2.0/TERP11gR2 /u01/app/oracle/product/11.2.0/QERP11gR2... (0 Replies)
Discussion started by: yoavbe
0 Replies

4. Shell Programming and Scripting

can you design/create a script for this?

Hello ALL, I have a file say test.txt, data in that file is in format such that 1st column represents number of executions of particular function 2nd column represents total amount of time 3rd column represents function name I want to get the poor/slow performing function from this file.... (6 Replies)
Discussion started by: Rahulpict
6 Replies

5. UNIX for Advanced & Expert Users

AIX, Solaris, Linux Test Environment Design Question

AIX, Solaris, Linux Test Environment Design Question We want to set an AIX, Solaris & Linux test environment. Here are the hardware equipments: (1) A Sunfire v100 (or v120), 1GB memory, two 36GB HDD. (2) An IBM pSeries 7026, 1 GB memory, 4 9GB HDD. (3) Five external HDD with SCSI... (1 Reply)
Discussion started by: aixlover
1 Replies

6. Solaris

AIX, Solaris, Linux Test Environment Design Question

AIX, Solaris, Linux Test Environment Design Question We want to set an AIX, Solaris & Linux test environment. Here are the hardware equipments: (1) A Sunfire v100 (or v120), 1GB memory, two 36GB HDD. (2) An IBM pSeries 7026, 1 GB memory, 4 9GB HDD. (3) Five external HDD with SCSI... (4 Replies)
Discussion started by: aixlover
4 Replies

7. Shell Programming and Scripting

To design a report using shell script

Short Description: To find the core files from a directory for the previous day and e-mail it across to a particular id. 1) Finding the core files in a directory. 2) The time is divided into eight fields and based on the time the respective field should be updated with the flag 1. ... (1 Reply)
Discussion started by: venkatesht
1 Replies

8. Shell Programming and Scripting

question on perl script

LOGFILE ======== My name is: ?Anthony Perkins I am an American citizen. My name is: ?Donte Suarez I am a Spanish citizen. My name is: ? lenny Davis I am an Australian citizen. My name is: ?allen rigodeau I am a French citizen. My name is: ? manuel williams I am a Mexican citizen. ... (2 Replies)
Discussion started by: gholdbhurg
2 Replies
Login or Register to Ask a Question