Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Okay, So after going through the perl, I am now beginnging to see the light. The sql, I am going to assume, (and verify later) is full of useful, albeit unnessacary functions that can be replicated without figuring out 1200 lines of sql. Which brings me to my next point. The code is broken into several subroutines, (actually, 8 to be precise), and the execution runs 4 of them in sequence, then emails the results (good or bad) to the owner of the file. If nobody minds, I will process my thoughts here, and subject them to criticism for robustness.


First Subroutine: initVars
Percieved Usage: To initialize variables (hey, I got one!!!)
Actions:
  • printing debug statements if the variables are set. (I have search for where the variables are set, and even run with strict, and cant find them... any help? the exact code looks like this:
    print STDOUT "\nStarting the initVars routine...\n" if ($L1);
    And I have gathered that $L1 is a command line argument (as there is $L2, $L3, and $L4, and they are all used in the same manner.) The one problem I see is, the code never processes command line args into these variables. Is there a way to do this w/o processesing them?
  • Sets 2 environment variables, and puts them into the $ENV hash.
  • sets up the path name for 4 files (good lines, bad lines, log file, and a lockfile)
  • sets up two paths for in and out directories
  • calls the abortScript function if there are not 3 arguments
  • processes 4 command line arguments into 4 separate variables for d-base info ($SERVER, $LOGIN, $PASSWORD, $USER_OWNER).
    Sidenote: This is another bone of contention. the previous line says, call abortScript if $#ARGV != 3, and then this one shifts ARGV 4 times... am I being an idiot and forgetting that perl's $#ARGV gives the index of the last element in the array, and not the count?
  • places the servername into the $ENV hash
  • sets up the lock file name into a string.
  • sets up true and false variables
  • sets up a var called $anyDataFiles, and inits it to false
  • Logs into the database, using a function &ora_login (its an oracle dbase) || abortScript
    Here is the next problem. The code has NO use statements whatsoever. How can he (yes, it was a he that wrote this. I'd talk to him, but he has left the company since he wrote this) call functions such as &ora_login and others, without using modules or writing them into the code?
subroutine 2: filterUnWanted
Percieved Usage: to filter out unwanted files?
Actions:
  • makes a system call to a shell script (which I dont have)


subroutine 3: checkRecovery
Percieved Usage: to see if script ran fully last time.
Actions:
  • checks for lockfile's existence
    • If one exists, opens it, reads a time from it.
    • emails the user that the prog is running in recovery mode, and that the program wasnt completed last time.
    • deletes all information from what looks to be temporary database tables.
    • Commits the deletes,
    • unlinks the lockfile
    • unlinks the bad file
    • unlinks the log file
    • Otherwise, queries a table for a timestamp from a table
    • checks $anyVendorFileName ne ""
      • if it exists:
      • emails the user that there are unprocessed records
      • sets up errlogfilename
      • sets up the datafilename
      • sets up the baddatafilename
      • sets $anyDataFiles to $TRUE (i assume that this indicates that a file was being processed earlier)
      • calls process log table function
      • otherwise, queries an error log table. || aborts
      • emails the owner (are we seeing a theme here? put it in a sub!!)
      • sets up the errorlogfilename
      • sets up the datafilename
      • sets up the baddatafilename
      • sets $anyDataFiles to #TRUE (again, assuming that this indicates a file was being processed earlier)
      • calls &processLogTable


subroutine 4: processFiles
Percieved Usage: to process and verify all data in input files, and insert if good, email if bad.
Actions:


subroutine 5: processLogTable
Percieved Usage: takes all information from the log table in the dbase, and writes them to the log file
Actions:


subroutine 6: removeCtrlChars
Percieved Usage: to remove all control characters from the file by making a bunch of sed calls.
Actions:


subroutine 7: errorInLine
Percieved Usage: called when a line is found to have an error in it.
Actions:


subroutine 8: abortScript
Percieved Usage: called when an error is generated that prevents the script from continuing
Actions:
(I'll update more later, or if you all dont want to listen, I'll stop).

thanks!
E-Bitch

In reply to Code Breakdown by E-Bitch
in thread Seeking advice about learning another's code by E-Bitch

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (8)
As of 2024-04-18 16:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found