[29594] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 838 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Sep 10 16:14:22 2007

Date: Mon, 10 Sep 2007 13:14:09 -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           Mon, 10 Sep 2007     Volume: 11 Number: 838

Today's topics:
        INDEX Function <amerar@iwc.net>
    Re: INDEX Function <glex_no-spam@qwest-spam-no.invalid>
    Re: INDEX Function <amerar@iwc.net>
    Re: INDEX Function <glex_no-spam@qwest-spam-no.invalid>
    Re: INDEX Function <amerar@iwc.net>
    Re: INDEX Function xhoster@gmail.com
    Re: INDEX Function <amerar@iwc.net>
        select number <webmaster@valleywebnet.com>
    Re: select number <mritty@gmail.com>
    Re: select number  usenet@DavidFilmer.com
    Re: trying to export some utility methods, and struggli <anno4000@radom.zrz.tu-berlin.de>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 10 Sep 2007 10:34:44 -0700
From:  "amerar@iwc.net" <amerar@iwc.net>
Subject: INDEX Function
Message-Id: <1189445684.195882.122500@y42g2000hsy.googlegroups.com>


Ok, I should be able to figure this out, but guess not.

I have a long string here, and I'm using the INDEX function to find a
string within that.  Why then, is it always returning the wrong
position???   Here are some examples.  I'm looking for the string "
AND ", notice the capital letters.

Here is my INDEX statement:

for $i (0 .. $#info) {
    $customer_id =  $info[$i][0];
    $screen_name =  $info[$i][1];
    $screen_query = substr($info[$i][2],4);

    $and = index($screen_query, 'AND');
    print "AND POSITION IS HERE: $and\n";
}

POSITION IS HERE: 8
HERE: 20,1115,1082,1083,1086,1088,1089,1090|select
master_table.ticker,master_table.comp_name,DIV_YIELD,NET_MARGIN,DEBT_TO_EQUITY,PRICE_TO_BOOK,PRICE_TO_CASH,PRICE_TO_SALES
from master_table,prices,stock_data,daily_zacks_rank where
master_table.m_ticker=stock_data.m_ticker and
master_table.m_ticker=prices.m_ticker and
master_table.m_ticker=daily_zacks_rank.m_ticker AND
upper(PRICE_TO_BOOK) <= 1.2 AND upper(PRICE_TO_CASH) >= 1.5 AND
upper(PRICE_TO_SALES) <= 1.2

POSITION IS HERE: 38
HERE: 20,1115|select master_table.ticker,master_table.comp_name from
master_table,prices,stock_data,daily_zacks_rank where
master_table.m_ticker=stock_data.m_ticker and
master_table.m_ticker=prices.m_ticker and
master_table.m_ticker=daily_zacks_rank.m_ticker AND upper(DIV_YIELD)
>= 4 AND upper(DEBT_TO_EQUITY) <= .2

POSITION IS HERE: 381
HERE:
16\1020,1021,1024,1028,1115,1030,1032,1033,1040,1042,1055,1056,1057,1065,1073,1078|
select
master_table.ticker,stock_data.EXCHANGE,stock_data.SECTOR_NAME,stock_data.MKT_VALUE,master_table.comp_name,prices.CLOSING,stock_data.HIGH_52W,stock_data.LOW_52W,daily_zacks_rank.z_rank_d,AVG_RATING,Q_EST_SURP,SURP_PREV,SURP_AVG_4Q,NET_PERC_INS,TREND_EPGR,PE_12M
from master_table,prices,stock_data,daily_zacks_rank where
master_table.m_ticker=stock_data.m_ticker and
master_table.m_ticker=prices.m_ticker and
master_table.m_ticker=daily_zacks_rank.m_ticker(+)  AND
upper(daily_zacks_rank.z_rank_d) <= 2 AND upper(AVG_RATING) <= 2 AND
upper(Q_EST_SURP) >= 0 AND upper(SURP_PREV) >= 0 AND
upper(SURP_AVG_4Q) >= 0 AND upper(stock_data.MKT_VALUE) >= 500 AND
upper(stock_data.PERC_CHG_12W) >= 10 AND upper(PRICE_TO_SALES) <= .5

Go figure???



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

Date: Mon, 10 Sep 2007 12:47:55 -0500
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: INDEX Function
Message-Id: <46e5834b$0$10304$815e3792@news.qwest.net>

amerar@iwc.net wrote:
> Ok, I should be able to figure this out, but guess not.
> 
> I have a long string here, and I'm using the INDEX function to find a
> string within that.  Why then, is it always returning the wrong
> position???   Here are some examples.  I'm looking for the string "
> AND ", notice the capital letters.

No it's looking for 'AND'.

> 
> Here is my INDEX statement:
> 
> for $i (0 .. $#info) {
>     $customer_id =  $info[$i][0];
>     $screen_name =  $info[$i][1];
>     $screen_query = substr($info[$i][2],4);
> 
>     $and = index($screen_query, 'AND');
>     print "AND POSITION IS HERE: $and\n";
> }
> 
> POSITION IS HERE: 8
> HERE: 20,1115,1082,1083,1086,1088,1089,1090|select

Since you don't show us what's in $screen_query, how
can we help? Your output never contains
'AND POSITION IS HERE: ' either. Post actual
code that others can run which shows your issue.

e.g.

my $screen_query='blah..';
my $pos = index($screen_query, 'AND');
print "AND POSITION IS HERE: $pos\n" if $pos >= 0;





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

Date: Mon, 10 Sep 2007 11:06:33 -0700
From:  "amerar@iwc.net" <amerar@iwc.net>
Subject: Re: INDEX Function
Message-Id: <1189447593.090996.237360@w3g2000hsg.googlegroups.com>

On Sep 10, 12:47 pm, "J. Gleixner" <glex_no-s...@qwest-spam-
no.invalid> wrote:
> ame...@iwc.net wrote:
> > Ok, I should be able to figure this out, but guess not.
>
> > I have a long string here, and I'm using the INDEX function to find a
> > string within that.  Why then, is it always returning the wrong
> > position???   Here are some examples.  I'm looking for the string "
> > AND ", notice the capital letters.
>
> No it's looking for 'AND'.
>
>
>
> > Here is my INDEX statement:
>
> > for $i (0 .. $#info) {
> >     $customer_id =  $info[$i][0];
> >     $screen_name =  $info[$i][1];
> >     $screen_query = substr($info[$i][2],4);
>
> >     $and = index($screen_query, 'AND');
> >     print "AND POSITION IS HERE: $and\n";
> > }
>
> > POSITION IS HERE: 8
> > HERE: 20,1115,1082,1083,1086,1088,1089,1090|select
>
> Since you don't show us what's in $screen_query, how
> can we help? Your output never contains
> 'AND POSITION IS HERE: ' either. Post actual
> code that others can run which shows your issue.
>
> e.g.
>
> my $screen_query='blah..';
> my $pos = index($screen_query, 'AND');
> print "AND POSITION IS HERE: $pos\n" if $pos >= 0;

$screen_query is the SQL query you see.  The extremely long string.
Here is the code:

for $i (0 .. $#info) {
    $customer_id = $info[$i][0];
    $screen_name = $info[$i][1];
    $screen_query = $info[$i][2];
    print "HERE: $screen_query\n\n";

    $string = 'select';
    $d = index($screen_query, $string);
    print "POSITION IS HERE: $d\n";
}



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

Date: Mon, 10 Sep 2007 13:17:07 -0500
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: INDEX Function
Message-Id: <46e58a24$0$505$815e3792@news.qwest.net>

amerar@iwc.net wrote:
> On Sep 10, 12:47 pm, "J. Gleixner" <glex_no-s...@qwest-spam-
> no.invalid> wrote:
>> ame...@iwc.net wrote:
>>> Ok, I should be able to figure this out, but guess not.
>>> I have a long string here, and I'm using the INDEX function to find a
>>> string within that.  Why then, is it always returning the wrong
>>> position???   Here are some examples.  I'm looking for the string "
>>> AND ", notice the capital letters.
>> No it's looking for 'AND'.
>>
>>
>>
>>> Here is my INDEX statement:
>>> for $i (0 .. $#info) {
>>>     $customer_id =  $info[$i][0];
>>>     $screen_name =  $info[$i][1];
>>>     $screen_query = substr($info[$i][2],4);
>>>     $and = index($screen_query, 'AND');
>>>     print "AND POSITION IS HERE: $and\n";
>>> }
>>> POSITION IS HERE: 8
>>> HERE: 20,1115,1082,1083,1086,1088,1089,1090|select
>> Since you don't show us what's in $screen_query, how
>> can we help? Your output never contains
>> 'AND POSITION IS HERE: ' either. Post actual
>> code that others can run which shows your issue.
>>
>> e.g.
>>
>> my $screen_query='blah..';
>> my $pos = index($screen_query, 'AND');
>> print "AND POSITION IS HERE: $pos\n" if $pos >= 0;
> 
> $screen_query is the SQL query you see.  The extremely long string.
> Here is the code:
> 
> for $i (0 .. $#info) {
>     $customer_id = $info[$i][0];
>     $screen_name = $info[$i][1];
>     $screen_query = $info[$i][2];
>     print "HERE: $screen_query\n\n";
> 
>     $string = 'select';
>     $d = index($screen_query, $string);
>     print "POSITION IS HERE: $d\n";
> }
> 

One last time...
*Post actual code that others can run which shows your issue.*


my $screen_query = ' some long string with select in it';
my $string = 'select';
my $d = index($screen_query, $string);
print "POSITION IS HERE: $d\n";

POSITION IS HERE: 23


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

Date: Mon, 10 Sep 2007 11:20:45 -0700
From:  "amerar@iwc.net" <amerar@iwc.net>
Subject: Re: INDEX Function
Message-Id: <1189448445.716523.255310@d55g2000hsg.googlegroups.com>

On Sep 10, 1:17 pm, "J. Gleixner" <glex_no-s...@qwest-spam-no.invalid>
wrote:
> ame...@iwc.net wrote:
> > On Sep 10, 12:47 pm, "J. Gleixner" <glex_no-s...@qwest-spam-
> > no.invalid> wrote:
> >> ame...@iwc.net wrote:
> >>> Ok, I should be able to figure this out, but guess not.
> >>> I have a long string here, and I'm using the INDEX function to find a
> >>> string within that.  Why then, is it always returning the wrong
> >>> position???   Here are some examples.  I'm looking for the string "
> >>> AND ", notice the capital letters.
> >> No it's looking for 'AND'.
>
> >>> Here is my INDEX statement:
> >>> for $i (0 .. $#info) {
> >>>     $customer_id =  $info[$i][0];
> >>>     $screen_name =  $info[$i][1];
> >>>     $screen_query = substr($info[$i][2],4);
> >>>     $and = index($screen_query, 'AND');
> >>>     print "AND POSITION IS HERE: $and\n";
> >>> }
> >>> POSITION IS HERE: 8
> >>> HERE: 20,1115,1082,1083,1086,1088,1089,1090|select
> >> Since you don't show us what's in $screen_query, how
> >> can we help? Your output never contains
> >> 'AND POSITION IS HERE: ' either. Post actual
> >> code that others can run which shows your issue.
>
> >> e.g.
>
> >> my $screen_query='blah..';
> >> my $pos = index($screen_query, 'AND');
> >> print "AND POSITION IS HERE: $pos\n" if $pos >= 0;
>
> > $screen_query is the SQL query you see.  The extremely long string.
> > Here is the code:
>
> > for $i (0 .. $#info) {
> >     $customer_id = $info[$i][0];
> >     $screen_name = $info[$i][1];
> >     $screen_query = $info[$i][2];
> >     print "HERE: $screen_query\n\n";
>
> >     $string = 'select';
> >     $d = index($screen_query, $string);
> >     print "POSITION IS HERE: $d\n";
> > }
>
> One last time...
> *Post actual code that others can run which shows your issue.*
>
> my $screen_query = ' some long string with select in it';
> my $string = 'select';
> my $d = index($screen_query, $string);
> print "POSITION IS HERE: $d\n";
>
> POSITION IS HERE: 23

Ok, I am writing this script myself, no one else will run it.  I
simply query an Oracle database and return what is in $screen_query.
You saw those values in my first post.  Those were the long values.

Then, I am looking for the first occurrence of the work ' AND '.  The
perl code to loop through the array is below.  Thee is nothing more to
it..........

for $i (0 .. $#info) {
    $customer_id = $info[$i][0];
    $screen_name = $info[$i][1];
    $screen_query = $info[$i][2];
    print "HERE: $screen_query\n\n";

    $string = ' AND ';
    $d = index($screen_query, $string);
    print "POSITION IS HERE: $d\n";

If you need to see the values of $query_string, there they are again:

POSITION IS HERE: 8
HERE: 20,1115,1082,1083,1086,1088,1089,1090|select
master_table.ticker,master_table.comp_name,DIV_YIELD,NET_MARGIN,DEBT_TO_EQUITY,PRICE_TO_BOOK,PRICE_TO_CASH,PRICE_TO_SALES
from master_table,prices,stock_data,daily_zacks_rank where
master_table.m_ticker=stock_data.m_ticker and
master_table.m_ticker=prices.m_ticker and
master_table.m_ticker=daily_zacks_rank.m_ticker AND
upper(PRICE_TO_BOOK) <= 1.2 AND upper(PRICE_TO_CASH) >= 1.5 AND
upper(PRICE_TO_SALES) <= 1.2

POSITION IS HERE: 38
HERE: 20,1115|select master_table.ticker,master_table.comp_name from
master_table,prices,stock_data,daily_zacks_rank where
master_table.m_ticker=stock_data.m_ticker and
master_table.m_ticker=prices.m_ticker and
master_table.m_ticker=daily_zacks_rank.m_ticker AND upper(DIV_YIELD)

>= 4 AND upper(DEBT_TO_EQUITY) <= .2

POSITION IS HERE: 381
HERE:
16\1020,1021,1024,1028,1115,1030,1032,1033,1040,1042,1055,1056,1057,1065,1073,1078|
select
master_table.ticker,stock_data.EXCHANGE,stock_data.SECTOR_NAME,stock_data.MKT_VALUE,master_table.comp_name,prices.CLOSING,stock_data.HIGH_52W,stock_data.LOW_52W,daily_zacks_rank.z_rank_d,AVG_RATING,Q_EST_SURP,SURP_PREV,SURP_AVG_4Q,NET_PERC_INS,TREND_EPGR,PE_12M
from master_table,prices,stock_data,daily_zacks_rank where
master_table.m_ticker=stock_data.m_ticker and
master_table.m_ticker=prices.m_ticker and
master_table.m_ticker=daily_zacks_rank.m_ticker(+)  AND
upper(daily_zacks_rank.z_rank_d) <= 2 AND upper(AVG_RATING) <= 2 AND
upper(Q_EST_SURP) >= 0 AND upper(SURP_PREV) >= 0 AND
upper(SURP_AVG_4Q) >= 0 AND upper(stock_data.MKT_VALUE) >= 500 AND
upper(stock_data.PERC_CHG_12W) >= 10 AND upper(PRICE_TO_SALES) <= .5



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

Date: 10 Sep 2007 18:33:09 GMT
From: xhoster@gmail.com
Subject: Re: INDEX Function
Message-Id: <20070910143311.410$7t@newsreader.com>

"amerar@iwc.net" <amerar@iwc.net> wrote:
>
> $screen_query is the SQL query you see.  The extremely long string.
> Here is the code:
>
> for $i (0 .. $#info) {
>     $customer_id = $info[$i][0];
>     $screen_name = $info[$i][1];
>     $screen_query = $info[$i][2];
>     print "HERE: $screen_query\n\n";
>
>     $string = 'select';

You are not searching for "AND" (notice case or not), you are searching
for "select".


>     $d = index($screen_query, $string);
>     print "POSITION IS HERE: $d\n";

You are printing the sql string before you are printing the position, while
in your example you started the "example" output out with the position
(apparently from an incomplete prior iteration), not the sql string.  Once
one realizes that you are out of register, and searching for something
different than you claim you are searching for, and apparently posted the
wrong code in the first place, then your example output seems to be what
one would expect it to be.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.


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

Date: Mon, 10 Sep 2007 11:45:50 -0700
From:  "amerar@iwc.net" <amerar@iwc.net>
Subject: Re: INDEX Function
Message-Id: <1189449950.634714.138260@19g2000hsx.googlegroups.com>

On Sep 10, 1:33 pm, xhos...@gmail.com wrote:
> "ame...@iwc.net" <ame...@iwc.net> wrote:
>
> > $screen_query is the SQL query you see.  The extremely long string.
> > Here is the code:
>
> > for $i (0 .. $#info) {
> >     $customer_id = $info[$i][0];
> >     $screen_name = $info[$i][1];
> >     $screen_query = $info[$i][2];
> >     print "HERE: $screen_query\n\n";
>
> >     $string = 'select';
>
> You are not searching for "AND" (notice case or not), you are searching
> for "select".
>
> >     $d = index($screen_query, $string);
> >     print "POSITION IS HERE: $d\n";
>
> You are printing the sql string before you are printing the position, while
> in your example you started the "example" output out with the position
> (apparently from an incomplete prior iteration), not the sql string.  Once
> one realizes that you are out of register, and searching for something
> different than you claim you are searching for, and apparently posted the
> wrong code in the first place, then your example output seems to be what
> one would expect it to be.
>
> Xho
>
> --
> --------------------http://NewsReader.Com/--------------------
> The costs of publication of this article were defrayed in part by the
> payment of page charges. This article must therefore be hereby marked
> advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
> this fact.

That was my fault.  I was trying different strings to see what kind of
results I'd get and in my copying and pasting, I probably messed
things up.

But in any case, I even printed out the length, and it is wrong, with
no patterns.  Maybe there is a character in the string messing things
up???




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

Date: Mon, 10 Sep 2007 08:49:11 -0700
From:  JimJx <webmaster@valleywebnet.com>
Subject: select number
Message-Id: <1189439351.496553.78110@22g2000hsm.googlegroups.com>

This is probably a very easy question but I couldn't find it in the
docs.

I have a select
SELECT * FROM valley WHERE category = ?

But I need to be able to find any number, 1, 2, 89, 153... etc.

How do I do that???

Thanks!
Jim



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

Date: Mon, 10 Sep 2007 09:12:02 -0700
From:  Paul Lalli <mritty@gmail.com>
Subject: Re: select number
Message-Id: <1189440722.707637.5880@k79g2000hse.googlegroups.com>

On Sep 10, 11:49 am, JimJx <webmas...@valleywebnet.com> wrote:
> This is probably a very easy question but I couldn't find it in the
> docs.
>
> I have a select
> SELECT * FROM valley WHERE category = ?
>
> But I need to be able to find any number, 1, 2, 89, 153... etc.
>
> How do I do that???

How do you do what???  Your question is nonsensical.  What do the
numbers 1, 2, 89, 153 have to do with the SQL statement you pasted?
What does "any number" have to do with that statement?

Your question is very poorly phrased.  At a minimum, you should be
posting sample input and desired output of whatever problem it is
you're having.

Paul Lalli



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

Date: Mon, 10 Sep 2007 16:56:49 -0000
From:  usenet@DavidFilmer.com
Subject: Re: select number
Message-Id: <1189443409.180857.253400@19g2000hsx.googlegroups.com>

On Sep 10, 8:49 am, JimJx <webmas...@valleywebnet.com> wrote:
> I have a select
> SELECT * FROM valley WHERE category = ?
>
> But I need to be able to find any number, 1, 2, 89, 153... etc.

Huh??? Do you mean you want to select all rows where the value of the
category column is numeric?  Or are you trying to select all rows
where the category column matches some particular number or group of
numbers???

FWIW, that's not a Perl question...


--
The best way to get a good answer is to ask a good question.
David Filmer (http://DavidFilmer.com)



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

Date: Mon, 10 Sep 2007 17:44:02 +0200
From: Anno Siegel <anno4000@radom.zrz.tu-berlin.de>
Subject: Re: trying to export some utility methods, and struggling
Message-Id: <5kl722F4dtnsU1@mid.dfncis.de>

On 2007-09-10 10:52:21 +0200, bugbear <bugbear@trim_papermule.co.uk_trim> said:

> Sherm Pendley wrote:
>> bugbear <bugbear@trim_papermule.co.uk_trim> writes:
>> 
>>> (reponse at bottom)
>> 
>> That's where we expect it to be - no need to point it out.
>> 
>>> Mumia W. wrote:
>>> 
>>>> # Let's say we're back in the main program now.
>>>> 
>>>> WidgetBasher->utility_function();
>>>> WidgetManip->utility_function();
>>>> WidgetDoer->utility_function();
>>> Yep, that works, but that's almost exactly what I'm trying to avoid.
>>> I don't want to be forced to have an instance of a class
>>> just to call a utility;
>> 
>> Good thing that calling a class method doesn't force that.
>> 
>>> I am aware of the various uses of OO code (I've spent 15 years
>>> on large projects in both Java and C++)
>> 
>> And in all that time you've never heard of class methods?
>> 
>> Astonishing.
> 
> It would be if true, but I *have* heard of class methods.
> 
> I am aware of the possibility of doing
> BasherUtility::utility_function();

That's not calling utility_function as a class method, just
a fully qualified sub call.  It doesn't follow inheritance,
and it doesn't deliver the class name as an argument.

The class method call is

    BasherUtility->utility_function();

which does these things.

[...]

Anno



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

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:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#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 838
**************************************


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