[32427] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 3694 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun May 20 16:09:22 2012

Date: Sun, 20 May 2012 13:09:04 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sun, 20 May 2012     Volume: 11 Number: 3694

Today's topics:
    Re: DBD::Oracle build on aix 6.1 ( host is a 64 bit db  <xtdkmqc@gmail.com>
    Re: First Commercial Perl Program <ronaldljohnson@gmail.com>
    Re: First Commercial Perl Program <ronaldljohnson@gmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Sun, 20 May 2012 19:55:15 +0000
From: Am Nym <xtdkmqc@gmail.com>
Subject: Re: DBD::Oracle build on aix 6.1 ( host is a 64 bit db server )
Message-Id: <wroaa12ocf0.fsf@mpttdph.xen.prgmr.com>

Ben Morrow <ben@morrow.me.uk> writes:

> Quoth xtdkmqc@gmail.com:
>> On Saturday, May 19, 2012 2:07:10 PM UTC-5, Ben Morrow wrote:
>> > Quoth Am Nym <------@gmail.com>:
>> > > The 64 bit Oracle server is loaded on this host.
>> > > 
>> > > Do I still have to load an Oracle client?
>> > 
>> > Is your perl 32bit or 64bit? 
>> 
>>   $ perl -V
>>   Summary of my perl5 (revision 5 version 8 subversion 8) configuration:
>
> (That's pretty old; both 5.8 and 5.10 are unsupported by the perl
> developers at this point. You should seriously consider upgrading.)

We need to plan for that.

> <snip>
>>       cc='cc_r', ccflags ='-D_ALL_SOURCE -D_ANSI_C_SOURCE
>
> That's the system cc.

Right, the AIX compiler.

>>       intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321
>>       d_longlong=define, longlongsize=8, d_longdbl=define,
>>       longdblsize=8 ivtype='long', ivsize=4, nvtype='double',
>>       nvsize=8, Off_t='off_t',
>
> intsize=4, ivsize=4 and ptrsize=4, so this is an entirely 32bit perl.
> (It's possible, at least on some architectures, to build perl to use
> 64bit integers even if it's using 32bit pointers.)
>
>> > Which version of Oracle are you using?
>> 
>> 11g
>> 
>> > The impression I get from README.{clients,aix}.txt is that if your perl
>> > is 64bit, or if you have Oracle 10g (which apparently comes with 32bit
>> > client libraries), you don't need anything else; 
>> 
>> Is there a way to check for the client libs?
>> 
>> The build made it to near the end; it failed w/error:
>> 
>> --snip
>>         rm -f blib/arch/auto/DBD/Oracle/Oracle.so
>>        
>> LD_RUN_PATH="/products/app/oracle/product/11.2.0/ee_1/lib:/products/app/oracle/product/11.2.0/ee_1/rdbms/lib" ld  -bhalt:4 -bexpall -G -bnoentry
>> -lpthreads -lc Oracle.o  dbdimp.o  oci8.o /usr/lib/crt0_r.o  -o
>> blib/arch/auto/DBD/Oracle/Oracle.so     
>> -L/products/app/oracle/product/11.2.0/ee_1/lib/ -lclntsh -lld -lm -ldl
>> -lc -lm -lpthreads -lodm -lbsd_r -lld -lperfstat -lm -lpthreads
>> ld: 0711-736 ERROR: Input file
>> /products/app/oracle/product/11.2.0/ee_1/lib//libclntsh.so:
>>         XCOFF64 object files are not allowed in 32-bit mode.
>> make: The error code from the last command is 8.
>
> Well, that seems fairly unambiguous: the client libs appear to be there,
> but they are 64bit so you can't link them with your perl. 

Thanks for clearing that up.

> The first section in README.aix suggests you may have 32bit
> libraries in /products/app/oracle/product/11.2.0/ee_1/lib32 and
> .../rdbms/lib32; you may be able to edit the Makefile to link
> against them instead,

There is no lib32 dir or sym link:

    # 15:39:12 Sun 120520 0j 0 48890062
    # /products/app/oracle/product/11.2.0
    # ourdbserver02 txr6 $ find . 2>/dev/null |grep 'lib$' |wc -l
         114
    # 15:39:28 Sun 120520 0j 0 48890062
    # /products/app/oracle/product/11.2.0
    # ourdbserver02 txr6 $ find . 2>/dev/null |grep lib32
    # 15:40:06 Sun 120520 0j 0 48890062 /products/app/oracle/product/11.2.0
    # ourdbserver02 txr6 $

> but tbh it's probably easier just to install the Instant Client. (Unless that's
> something you have to pay for separately?)

I'm not sure.  Last Friday we were thinking we would install the "normal"
32 bit client, that we install on other AIX hosts.  Will ask at work about the
Instant Client.

--
thanks again,



------------------------------

Date: Sun, 20 May 2012 11:37:39 -0700 (PDT)
From: "tbb!/fbr!" <ronaldljohnson@gmail.com>
Subject: Re: First Commercial Perl Program
Message-Id: <c9cd5557-c28b-4e0a-91bc-d78ae588e23e@googlegroups.com>

On Thursday, May 17, 2012 12:00:15 AM UTC-7, Tim Watts wrote:
> tbb!/fbr! wrote:
> 
> > Here's a piece of code which compares lines in one file against lines in
> > the other. I mentioned earlier in the thread it was something I was
> > working on, but can't quit get it right via hashes, splits, working on the
> > data:
> > 
> > foreach $line1 ( @lines1 )
> > {
> >     ( $symb, $company, $excess ) = split( /\t/, $line1, 3 );
> > 
> >  
> >     foreach $line2 ( @lines2 )  #
> >     {
> >         ( $date_y, $symbol_y, $company_y, $cap_y, $open_y, $low_y,
> >         $high_y, $close_y, $pe_ratio_y, $date_div_y, $dividend_y,
> >         $div_yield_y, $date_ex_div_y, $nav_y, $yield_y, $vol_y, $avg_vol_y
> >         ) = split(/\t/, $line2 );
> > if ( $symb eq $symbol_y )
> >         {        
> >            print
> >            
> "$symb\t$company\t$cap_y\t$open_y\t$low_y\t$high_y\t$close_y\t$vol_y\t$avg_vol_y\t$excess\n";
> > print FILEOUT1
> > 
> "$symb\t$company\t$cap_y\t$open_y\t$low_y\t$high_y\t$close_y\t$vol_y\t$avg_vol_y\t$excess\n";
> >         }
> >     }
> > 
> > }
> > 
> > It was mentioned to me that there is a couple of ways to do this. Can I
> > get some input/help on making this piece of code a little more
> > streamlined.
> > 
> > Ron
> 
> Aside from Ben's excellent comments, what exactly isn't working?
> 
> I would put some debugging print's in (or run it through a perl debugger) - 
> 
> 1) print $symb, $company, $excess after the first foreach (add a next; to 
> skip the inner loop) and make sure you are happy that the data is being 
> "split" right.
> 
> 2) Same for inner loop
> 
> 
> If either of those datasets only have one record for each unique SYMBOL, it 
> woudl be a good candidate for preloading into a hash and only looping on the 
> other dataset. If both files have multiple unique SYMBOLS you could still do 
> this, but it would be a hash of arrays, so a little bit fiddlier.
> 
> HTH
> 
> Tim
> -- 
> Tim Watts

As I mentioned to Ben, it works 100% as is. I was just looking for a better way to write it. It seems to me there must be some better way than reading all of @lines2 for each line in @lines1. And yes, SYMBOL is unique.

Thanks,
Ron


------------------------------

Date: Sun, 20 May 2012 11:34:40 -0700 (PDT)
From: "tbb!/fbr!" <ronaldljohnson@gmail.com>
Subject: Re: First Commercial Perl Program
Message-Id: <28bcd869-3f76-4e27-81a8-d64662044dd0@googlegroups.com>

On Wednesday, May 16, 2012 2:23:09 PM UTC-7, Ben Morrow wrote:
> Quoth "tbb!/fbr!" <ronaldljohnson@gmail.com>:
> > Here's a piece of code which compares lines in one file against lines i=
n
> > the other. I mentioned earlier in the thread it was something I was
> > working on, but can't quit get it right via hashes, splits, working on
> > the data:
>=20
> You haven't explained what isn't working. AFAICS the code below should
> do *something*; I can't tell whether or not it what you want it to do.
>=20
> > foreach $line1 ( @lines1 )=20
>=20
>     foreach my $line1 ( @lines1 )
>=20
> Are you using 'strict'?
>=20
> You should give your variables more meaningful names than '@lines1'.
> What does this file actually contain?
>=20
> [I've rewrapped the code below since the lines were too long; since the
> wraps were inside strings it no longer does what it did. Please wrap any
> posted code to 76 columns: if necessary you can divide a long string up
> with .]
>=20
> > {
> >     ( $symb, $company, $excess ) =3D split( /\t/, $line1, 3 );
> >=20
> > =20
> >     foreach $line2 ( @lines2 )  #=20
> >     {
> >         ( $date_y, $symbol_y, $company_y, $cap_y, $open_y, $low_y,
> > $high_y, $close_y, $pe_ratio_y, $date_div_y, $dividend_y, $div_yield_y,
> > $date_ex_div_y, $nav_y, $yield_y, $vol_y, $avg_vol_y ) =3D split(/\t/,
> > $line2 );
> > 	if ( $symb eq $symbol_y )
> >         {       =20
> >            print "$symb\t$company\t$cap_y\t$open_y\t$low_y\t
> >    $high_y\t$close_y\t$vol_y\t$avg_vol_y\t$excess\n";
> > 	   print FILEOUT1 "$symb\t$company\t$cap_y\t$open_y\t
>=20
> Don't use global bareword filehandles. Keep your filehandles in
> variables: that is, instead of
>=20
>     open FILEOUT, ">", ... or die ...;
>=20
> write
>=20
>     open my $FILEOUT, ">", ... or die ...;
>=20
> and then use
>=20
>     print $FILEOUT ...
>=20
> later on. Also, use a meaningful name for your filehandle variables.
>=20
> >    $low_y\t$high_y\t$close_y\t$vol_y\t$avg_vol_y\t$excess\n";
>=20
> You can make this a lot less messy by noticing that $cap_y--$close_y and
> $vol_y--$avg_vol_y stay together, so you can treat them as one field.
> Also, you are printing the same string twice, so put it in a variable
> rather than writing it out all over again.
>=20
>     # create a pattern to match a single field, and a pattern to match a
>     # field plus a delimiter
>     my $f   =3D qr/[^\t]*/;
>     my $fd  =3D qr/$f\t/;
>=20
>     # extract the fields we want
>     my ($symbol, $data, $vols) =3D $line2 =3D~ m{
>         ^ $fd ($f) \t $fd ($fd{4} $f) \t $fd{7} ($fd $f) $
>     }x;
>=20
>     # strip the trailing tab from the field values
>     s/\t$// for $symbol, $data;
>=20
>     if ($symbol eq $symb) {
>         my $new =3D join "\t",=20
>             $symb, $company, $data, $vols, $excess;
>         print $new;
>         print FILEOUT $new;
>     }
>=20
> An alternative would be something like this:
>=20
>     # outside the loop
>     my @in =3D qw/
>         date symb company
>         cap open low high close pe_ratio=20
>         date_div div div_yield date_ex_div
>         nav yield vol avg_vol
>     /;
>     my @out =3D qw/
>         cap open low high close vol avg_vol
>     /;
>=20
>     # inside
>     my %f;
>     @f{@in} =3D split /\t/, $line1;
>=20
>     if ($f{symb} eq $symb) {
>         my $new =3D join "\t",=20
>             $symb, $company, @f{@out}, $excess;
>         # print as above
>     }
>=20
> which is likely to be more use if you want to do more processing of this
> data later.
>=20
> Ben

I apologize, but it is working, There is nothing wrong with the way it's wr=
itten, other than it's written by a novice perl programmer.  You provided e=
xcellent help on how to streamline it. It works 100% the way it is; I was j=
ust looking for a better or more efficient way to write it.

Thanks,
Ron


------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests. 

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V11 Issue 3694
***************************************


home help back first fref pref prev next nref lref last post