[32381] in Perl-Users-Digest
Perl-Users Digest, Issue: 3648 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Mar 24 09:09:22 2012
Date: Sat, 24 Mar 2012 06:09:06 -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 Sat, 24 Mar 2012 Volume: 11 Number: 3648
Today's topics:
indent based on stack <bjlockie@lockie.ca>
Re: indent based on stack (Tim McDaniel)
Re: yet another question about numbers and strings (hymie!)
Re: yet another question about numbers and strings <ben@morrow.me.uk>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 23 Mar 2012 11:40:46 -0700 (PDT)
From: bjlockie <bjlockie@lockie.ca>
Subject: indent based on stack
Message-Id: <f63e6582-7965-4002-a37f-98c2b21d1469@v2g2000vbx.googlegroups.com>
I am doing this for each subroutine.
print 'START.' . (caller(0))[3] . "\n"; and
print 'END.' . (caller(0))[3] . "\n";
What I would like to do is add a space after the START. for each level
down the stack it is.
eg.
START.1
START.2
START.3
END.3
END.2
END.1
------------------------------
Date: Fri, 23 Mar 2012 19:22:21 +0000 (UTC)
From: tmcd@panix.com (Tim McDaniel)
Subject: Re: indent based on stack
Message-Id: <jkiihd$bh9$1@reader1.panix.com>
In article <f63e6582-7965-4002-a37f-98c2b21d1469@v2g2000vbx.googlegroups.com>,
bjlockie <bjlockie@lockie.ca> wrote:
>I am doing this for each subroutine.
>print 'START.' . (caller(0))[3] . "\n"; and
>print 'END.' . (caller(0))[3] . "\n";
>
>What I would like to do is add a space after the START. for each level
>down the stack it is.
>
>eg.
>START.1
> START.2
> START.3
> END.3
> END.2
>END.1
([3] is the name of the subroutine, so 1, 2, and 3 above represent
subroutine names.)
A little experimentation shows that caller(N) returns a zero-length
list when N is larger than the number of layers of call. So you can
loop, calling "my @a = caller($i);" until scalar @a == 0.
The "x" operator, for A x B, returns a string being B copies of the
string value of A, so ' ' x $n returns a string of $n spaces.
--
Tim McDaniel, tmcd@panix.com
------------------------------
Date: 23 Mar 2012 18:31:17 GMT
From: hymie@lactose.homelinux.net (hymie!)
Subject: Re: yet another question about numbers and strings
Message-Id: <4f6cc175$0$19544$882e7ee2@usenet-news.net>
In our last episode, the evil Dr. Lacto had captured our hero,
Ben Morrow <ben@morrow.me.uk>, who said:
>
>Quoth hymie@lactose.homelinux.net (hymie!):
>> I'm now running DBD::Sybase 1.14 , and I'm still having the same
>> problem.
>>
>> ID bigint 8 not null
>> 9.21814636810375e+18
>
>Odd. What do you get from this?
>
> use DBI;
> use Devel::Peek;
>
> my $dbh = DBI->connect("dbi:Sybase:...", ...);
> my $bigint = $dbh->selectcol_arrayref(<<SQL);
> SELECT bigint FROM table WHERE ...
> SQL
>
> Dump $bigint;
SV = PVNV(0x7c9f60) at 0x7eef40
REFCNT = 1
FLAGS = (NOK,POK,pNOK,pPOK)
IV = 9218146368103748608
NV = 9.21814636810375e+18
PV = 0x7ee710 "9.21814636810375e+18"\0
CUR = 20
LEN = 35
The perldoc that I have does not identify what a PVNV is, nor the NOK
flag. But the doc implies that, because the POK and NOK flags are set,
it will refer to the NV and PV fields, and not the IV field because the
IOK flag is not set.
Oh, I found it in perlguts. NV is a double.
But beyond that, I don't know what this is telling me. :)
--hymie! http://lactose.homelinux.net/~hymie hymie@lactose.homelinux.net
-------------------------------------------------------------------------------
------------------------------
Date: Fri, 23 Mar 2012 19:48:20 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: yet another question about numbers and strings
Message-Id: <4l0v39-j5l.ln1@anubis.morrow.me.uk>
Quoth hymie@lactose.homelinux.net (hymie!):
> In our last episode, the evil Dr. Lacto had captured our hero,
> Ben Morrow <ben@morrow.me.uk>, who said:
> >Quoth hymie@lactose.homelinux.net (hymie!):
>
> >> I'm now running DBD::Sybase 1.14 , and I'm still having the same
> >> problem.
> >>
> >> ID bigint 8 not null
> >> 9.21814636810375e+18
> >
> >Odd. What do you get from this?
> >
> > use DBI;
> > use Devel::Peek;
> >
> > my $dbh = DBI->connect("dbi:Sybase:...", ...);
> > my $bigint = $dbh->selectcol_arrayref(<<SQL);
> > SELECT bigint FROM table WHERE ...
> > SQL
> >
> > Dump $bigint;
>
> SV = PVNV(0x7c9f60) at 0x7eef40
Have you stripped some of the Dump output, or did you run something
different? I was expecting $bigint to be an arrayref.
> REFCNT = 1
> FLAGS = (NOK,POK,pNOK,pPOK)
> IV = 9218146368103748608
Is this the correct value, or is it supposed to be ...09 or something?
This number is large enough that ...08 can be represented as a NV but
...07 and ...09 can't, so it would be useful to know whether this IV
came from the database or from a NV.
> NV = 9.21814636810375e+18
> PV = 0x7ee710 "9.21814636810375e+18"\0
> CUR = 20
> LEN = 35
>
> The perldoc that I have does not identify what a PVNV is,
A scalar which can hold a PV, an IV and a NV (a string, an integer, and
a double) simultaneously.
> nor the NOK
> flag. But the doc implies that, because the POK and NOK flags are set,
> it will refer to the NV and PV fields, and not the IV field because the
> IOK flag is not set.
That's correct.
> Oh, I found it in perlguts. NV is a double.
>
> But beyond that, I don't know what this is telling me. :)
Well, it seems to be telling you that DBD::Sybase is still returning
these values as NVs, despite you having IVs large enough to hold them.
Are you *sure* you're using the newer version? (And that you didn't
define SYB_NATIVE_NUM?) I can't see any way for the code in DBD::Sybase
to return a NV here, but I admit I can't follow it very well.
My next step here would be to start putting debugging printfs in
DBD::Sybase's dbdimp.c, just to see where the code's actully going, but
you may not be happy doing that. Something else you could try, if MSSQL
will let you, is to cast the bigint to varchar or something equivalent
before returning it. CAST(column AS varchar) would be the SQL92 syntax;
I don't know if MSSQL implements that or if there's some equivalent.
Ben
------------------------------
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 3648
***************************************