bluethundr:

Perlbotics already told you about the perl variable vs. environment variable, and has also suggested using DBI to talk to your database, so I won't elaborate on those.

However, if you just want to get something working, I have a suggestion: You're running the same script four times and pulling out a different column each time. I suggest you run the script once, and let perl pull out the columns for you. Something like:

#!/bin/perl # credentials / environment variables $ORACLE_HOME="/u01/app/oracle/product/10.2.0.4"; $ORACLE_SID=qaecom1; $sqlplus="/u01/app/oracle/product/10.2.0.4/bin/sqlplus"; $USERNAME=dbuser; $PASS=pass; $SID=${ORACLE_SID}; # Get all the data at once @TSPACES=`$sqlplus -s -l $USERNAME/$PASS@$SID \@/opt/bin/ops/mlb_table +space.sql`; # Now split the 4 columns you want into separate arrays, # and then join those arrays in the order you want: { my (@col1, @col2, @col3, @col4); for (@TSPACES) { my @cols = split; push @col1, $cols[0]; push @col2, $cols[1]; push @col3, $cols[2]; push @col4, $cols[3]; } @TSPACES = (@col1, @col2, @col3, @col4); } # ... the rest of your script

...roboticus

When your only tool is a hammer, all problems look like your thumb.


In reply to Re: use oracle home in script by roboticus
in thread use oracle home in script by bluethundr

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.