Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I am working on a Unix system with a Sybase database, wherein PERL scripts were written to extract, transform and load data from 3 sources: viz. Flat files, Access files and Sybase into the target Sybase database. I need to now understand the semantics of the PERL scripts. Could you please let me know if I can find such scripts as described above, with a meaningful explanation of how the script is coded? Any help would be greatly appreciated. Thank you in advance. Please email me at: ash_meh@rocketmail.com
  • Comment on Perl scripts to do extraction into Sybase

Replies are listed 'Best First'.
Re: Perl scripts to do extraction into Sybase
by hotyopa (Scribe) on Jan 09, 2001 at 08:15 UTC
    A big question indeed. I doubt that there is one script that does everything you want all at once, so you would be best to take things one at time.

    First of all, look here for a good introductory tutorial that should head you off in the right direction. Perl Monks' own tutorials contain a wealth of information.

    Next, epoptai's home node has links to a number of online books that you might want to keep handy. You might want to consider reverse engineering the scripts you have using these books, since (I assume) you know what they do, if not exactly how they do it.

    Not sure what a particular function does? Try "perldoc -f" followed by the name of the function at the command line...

    Specifically regarding databases and Perl, I found this tutorial very clear and concise for a newbie like me:

    One of the most confusing things I found about Perl when I first started where the regular expressions (seen something like s/\t.?\\s/ in your code?). Check out String matching and Regular Expressions and Common Regex Gotchas for help on this issue.

    I hope this has been of some help. Good luck...

    *~-}o{-~*

      thank you for the prompt reply.. and apologies for putting so much in one Qs. :) anyways, let me rephrase my Qs: how would you load data from a flat file into a sybase database using perl scripts?

        2 issues for you, best tackled one at a time. I've had to learn to do them both over the last little while, and barely suffered at all :)

        1. Reading flat files. This is a v. basic example which reads the file line at a time and prints the results. You could modify this approach to send to Sybase instead:
          #!/usr/local/bin/perl -w if (open(MYFILE, "path/to/file")) { $line = <MYFILE>; while ($line ne "") { print ($line); $line = <MYFILE>; } }
        2. Talking to a Sybase database. You'll need to come to grips with DBI/DBD. I doubt you will find it too difficult. It is pretty much a case of connecting to the database, executing an SQL command, then retrieving the results. The Tricks with DBI tutorial by btrott should head you off in the right direction.

          Have a look at davorg's reply below as well :)

        *~-}o{-~*

Re: Perl scripts to do extraction into Sybase
by davorg (Chancellor) on Jan 09, 2001 at 13:34 UTC

    Any script to insert data into a Sybase database will probably be using Sybperl or DBI/DBD::Sybase. The author of both of these modules is Michael Peppler and you can get a lot of good information from his web page at

    Also, I've done more than my fair share of Sybase/Perl work, so feel free to ask me anything.

    Oh... and it's Perl, not PERL!

    --
    <http://www.dave.org.uk>

    "Perl makes the fun jobs fun
    and the boring jobs bearable" - me

Re: Perl scripts to do extraction into Sybase
by PsychoSpunk (Hermit) on Jan 09, 2001 at 11:33 UTC
    In addition to hotyopa's advice, it truly looks like you have a specific task at hand which you are trying to understand. To this end, take your mouse from the location of this node and drag it up to the textbox in the left portion of that colored bar. Type anything your heart desires and see what happens.

    Seriously, you're asking for a whole lot of information, and doing it in a very general manner at that. Look through older nodes that deal with Sybase, Access, flat files, and whatever else you may need. You may find that the solution presents itself in a very clear and easy to implement way. Most likely, you'll have to massage the problem.

    You are not far from help, for if you care to post specific problematic areas, someone will know the answer. But remember that a good post is one which helps us as much as we can help you. And from what I've seen, these monks can only help when they fully understand a problem.

    ALL HAIL BRAK!!!

Re: Scripts to extract data..
by hotyopa (Scribe) on Jan 16, 2001 at 03:22 UTC
    ash_meh, nothing has changed since the last time I answered this exact question! What you seem to want is to understand Perl without having to learn it. I don't think that is possible.

    If you think this is a little harsh, perhaps you could highlight some parts of the scripts that you don't understand by posting the code here...

    *~-}o{-~*

Re: Scripts to extract data..
by extremely (Priest) on Jan 16, 2001 at 02:42 UTC
    I've worked with Sybase, and Perl for years and from what you've told us I can't honestly make a good guess about the scripts on your system do at all. Seriously, what you are asking is like: "I have a car and all the screws are metric, can you tell me what brand of oil filter it uses?"

    Unless the scripts themselves are well documented with comments no one here can tell you much of anything useful without seeing the code. You've asked exactly this question before and once again we're all going to tell you we don't email people, we have this whole great website to communicate with.

    --
    $you = new YOU;
    honk() if $you->love(perl)

Re: Scripts to extract data..
by Nakano (Novice) on Jan 16, 2001 at 03:02 UTC
    While I'm not familiar with Sybase, so I don't know wether or not these scripts you speak of were bundled with the software (in which case there might be some unbelieveably slim chance that someone on the net had posted something about them) or whether they were custom writen for your company (in which case no, you won't be able to find any sort of documentation for them).

    However, if you just wish to interpret them, there are several things you could do... The easiest would be simply to try to track down whomever wrote them originally and see if you can get them to explain it to you. Sometimes author's will put an email address in the headers of a script so they can be contacted if bugs are found.
    short of that, you could learn perl, which, even if you had someone sit down and explain to you what the script did, is the only real way you're ever going to be able to actually understand the script. Perl isn't an easy language to learn if you have no expirence, but its a very valueable thing to know.

    -Nakano