[17587] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5007 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Dec 1 11:05:34 2000

Date: Fri, 1 Dec 2000 08:05:13 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <975686713-v9-i5007@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 1 Dec 2000     Volume: 9 Number: 5007

Today's topics:
    Re: Alias STDIN to a variable (Anno Siegel)
    Re: Alias STDIN to a variable <jboes@eoexchange.com>
    Re: Anybody know what the carriage control characters a <gjchap99@my-deja.com>
    Re: calling perl script in html? (Monte Phillips)
    Re: calling perl script in html? <geoff-at-farmline-dot-com@127.0.0.1>
        Calling up web page in browser <kathomas@fairmark.com>
    Re: Calling up web page in browser <tony_curtis32@yahoo.com>
    Re: Calling up web page in browser <brosson@my-deja.com>
    Re: checking if mail address is valid <jboes@eoexchange.com>
    Re: Date::Manip unable to determine TIMEZONE??? <jboes@eoexchange.com>
        FAQ 4.3:   Does Perl have a round() function?  What abo <faq@denver.pm.org>
    Re: good format for frequently-updated database? <jboes@eoexchange.com>
    Re: HELP BEFORE ME HEAD EXPLODES <ubl@schaffhausen.de>
    Re: Help! (Tad McClellan)
    Re: how do i escape from perldoc <jboes@eoexchange.com>
    Re: how do i escape from perldoc (Tad McClellan)
        how to redirect output (to text-file) <l.hagen@HumanInference.com>
    Re: how to redirect output (to text-file) <foo@bar.va>
        Linux setuid and Perl 5.6.0 <john@hennessy.net.au>
        LWP post and get mmm3000@my-deja.com
        Most efficient way of getting a random row from db quer <mcameron@mirusweb.com>
    Re: Need a web-based real-time option quote provider... <davesisk@ipass.net>
    Re: Need a web-based real-time option quote provider... (Bernard El-Hagin)
        next if length < 80;  # why can't Perl be made to recog <cwfuchs@sfu.ca>
    Re: next if length < 80;  # why can't Perl be made to r <carvdawg@patriot.net>
    Re: next if length < 80;  # why can't Perl be made to r (Bernard El-Hagin)
    Re: next if length < 80;  # why can't Perl be made to r <foo@bar.va>
    Re: next if length < 80;  # why can't Perl be made to r (Tad McClellan)
    Re: OT Cargo Cult? (Was: Re: reformatting a perl script (Tad McClellan)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 1 Dec 2000 13:39:28 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Alias STDIN to a variable
Message-Id: <9089mg$q62$1@lublin.zrz.tu-berlin.de>

[jeopardious posting rearranged]

John Boy Walton <johngros@Spam.bigpond.net.au> wrote in comp.lang.perl.misc:
><bdesany@my-deja.com> wrote in message news:906nap$uea$1@nnrp1.deja.com...
>> I have a subroutine in a package that I want to be able provide data to
>> in a number of ways, but I don't want to have custom routines for each
>> way. So I have it set up to read from <STDIN>, but if a filename is
>> provided to the subroutine (by the calling script) then I open a
>> filehandle (INPUT) and say *STDIN = *INPUT and all the parts of the
>> script that say things like "while <STDIN>" still work, but pull data
>> from the file instead of STDIN.
>>
>> What I would like to do is get this effect from string data in a
>> variable as well. This is because I have a cgi that wants to pass the
>> data using a variable rather than a file. How can I make STDIN read
>> from a scalar variable containing a string value?
>>
>open(PIPE, "| STDIN")    || die "cannot fork: $!";

Have you tried to run this code?

>print PIPE $a_scalar_variable_containing_a_string_value";
>close(PIPE);
>It may need <> around STDIN I have not used this myself.

How do you think <> around STDIN would help?

What you posted is nothing but a wild guess.  Please make sure your
code works before you give advice.

Anno


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

Date: Fri, 01 Dec 2000 10:15:18 -0500
From: "Jeff Boes" <jboes@eoexchange.com>
Subject: Re: Alias STDIN to a variable
Message-Id: <3a27c1a2$0$30011$44a10c7e@news.net-link.net>

Unless my newsreader has been taken over by the Illuminati, I think
bdesany@my-deja.com babbled:

> 
> Hey I figured it out! Woo hoo! Well, actually I got the solution from
> Programming Perl. But it was me who actively decided it would be a good
> idea to look in that chapter... ;)
> 

Another approach: IO::Scalar.

-- 
Jeff Boes <jboes@eoexchange.com>          Tel:  (616) 381-9889 x.18
Sr. Software Engineer, EoExchange, Inc.   http://www.eoexchange.com/
Search, Monitor, Notify.                  http://www.eomonitor.com/


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

Date: Fri, 01 Dec 2000 12:47:57 GMT
From: Jack Altradmon <gjchap99@my-deja.com>
Subject: Re: Anybody know what the carriage control characters are ?
Message-Id: <9086ls$24a$1@nnrp1.deja.com>

Yes, thanks Michael. I know that all the 'standard' escape characters
are in the Camel book but it doesn't show me a '\ch' escape which does
a backspace on my win32 platform. So I  was wondering if this was an un-
documented one and if so, are there anymore available.

In article <3A2671EE.F2FF5D64@home.com>,
  Michael Carman <mjcarman@home.com> wrote:
> Jack Altradmon wrote:
> >
> > I have a 'real-time' counter which shows number of files being
> > processed.
> >
> > Before I print out the updated counter I print out a number of '\ch'
> > characters which backspaces the cursor. What are the special
> > characters for moving the cursor to beginning of line,
> > end of line, forward spacing..?
>
> I don't know all of those, (and I don't think that a "move to end of
> line" char even exists) but backspace is "\b" in Perl, and you can
use
> "\f" (formfeed) to return to the beginning of the current line.
>
> -mjc
>


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Fri, 01 Dec 2000 10:54:19 GMT
From: montep@hal-pc.org (Monte Phillips)
Subject: Re: calling perl script in html?
Message-Id: <3a2782c9.3418906@news.hal-pc.org>

On Thu, 30 Nov 2000 01:53:50 GMT, joshbaxley <joshb@isomedia.com>
wrote:

>I have a perl script that simply takes a list of files in a directory
>and lists them in html with links to them.
>
>Now if I did this in ASP and not perl and I wanted to call it in an HTML
>page, I would simply type:
>
><!-- #LOCATION File:page.asp -->
>
>now how do I do this with perl?
>


If you want the perl script to run automatically without user
clicking, AND your ISP does not allow server side includes <-! Exec
etc. then the easiest method is to place your perl script as an image
src with 0 width and 0 heigth   

g'Luk


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

Date: Fri, 1 Dec 2000 12:22:00 -0000
From: "Geoff Winkless" <geoff-at-farmline-dot-com@127.0.0.1>
Subject: Re: calling perl script in html?
Message-Id: <90854g$4p$1@soap.pipex.net>


"Monte Phillips" <montep@hal-pc.org> wrote in message
news:3a2782c9.3418906@news.hal-pc.org...
: On Thu, 30 Nov 2000 01:53:50 GMT, joshbaxley <joshb@isomedia.com>
: wrote:
:
: >I have a perl script that simply takes a list of files in a directory
: >and lists them in html with links to them.
: >
: >Now if I did this in ASP and not perl and I wanted to call it in an HTML
: >page, I would simply type:
: >
: ><!-- #LOCATION File:page.asp -->
: >
: >now how do I do this with perl?
: >
:
:
: If you want the perl script to run automatically without user
: clicking, AND your ISP does not allow server side includes <-! Exec
: etc. then the easiest method is to place your perl script as an image
: src with 0 width and 0 heigth

Yuck.

Also this doesn't work in all browsers.

Find a better way.

Geoff




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

Date: Fri, 1 Dec 2000 08:28:21 -0800
From: "Kaye Thomas" <kathomas@fairmark.com>
Subject: Calling up web page in browser
Message-Id: <t2fd7ujejkch29@corp.supernews.com>

I assume this is a FAQ but my searches didn't turn up an answer. I want to
be able to use form input to send the user to a page on a different server.
I know how to send output to their browser that could include a link to the
page on the other server, but I want to send them there directly as a result
of processing the form. For example, the form input includes the word "book"
and when the form is processed the next thing they see is the home page of
Amazon.com.

My hosting service has a list as long as my arm of Perl modules that are on
their system but I don't know what's in them, so if there's something there
that will do this, I don't know what it is.

TIA




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

Date: 01 Dec 2000 08:45:25 -0600
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Calling up web page in browser
Message-Id: <87elzsci9m.fsf@limey.hpcc.uh.edu>

>> On Fri, 1 Dec 2000 08:28:21 -0800,
>> "Kaye Thomas" <kathomas@fairmark.com> said:

> I assume this is a FAQ but my searches didn't turn up an
> answer. I want to be able to use form input to send the
> user to a page on a different server.  I know how to

    use CGI qw(:whatever options);

    print redirect('http://www.new.site/new/path');

hth
t
-- 
Eih bennek, eih blavek.


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

Date: Fri, 01 Dec 2000 14:52:51 GMT
From: Brian <brosson@my-deja.com>
Subject: Re: Calling up web page in browser
Message-Id: <908dvv$804$1@nnrp1.deja.com>

One simple solution would be to have Perl process the form, then return
a simple web page with a message like "Processing request..." with a
<body> tag as follows:

<body onload="location.replace('http://www.amazon.com')">

As soon as this page loads, their web browser will be redirected to
Amazon.

Hope this helps,
Brian

In article <t2fd7ujejkch29@corp.supernews.com>,
  "Kaye Thomas" <kathomas@fairmark.com> wrote:
> I assume this is a FAQ but my searches didn't turn up an answer. I
want to
> be able to use form input to send the user to a page on a different
server.
> I know how to send output to their browser that could include a link
to the
> page on the other server, but I want to send them there directly as a
result
> of processing the form. For example, the form input includes the
word "book"
> and when the form is processed the next thing they see is the home
page of
> Amazon.com.
>
> My hosting service has a list as long as my arm of Perl modules that
are on
> their system but I don't know what's in them, so if there's something
there
> that will do this, I don't know what it is.
>
> TIA
>
>

--
Brian R.


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Fri, 01 Dec 2000 10:23:20 -0500
From: "Jeff Boes" <jboes@eoexchange.com>
Subject: Re: checking if mail address is valid
Message-Id: <3a27c3f9$0$35013$44a10c7e@news.net-link.net>

Unless my newsreader has been taken over by the Illuminati, I think
"Sander van Gennip" <sander@veenhoven.com> babbled:

> i am trying to check if a mail address is valid from perl. I do this by
> checking if www.<server> or smtp.<server> exists (resolve ip). This
> seems to work in 99% of all cases, but not all. Anybody know a more
> reliable way?
> 
> greetings, Sander



-- Found in /usr/lib/perl5/5.6.0/pod/perlfaq9.pod
       How do I check a valid mail address?  

Jeff Boes <jboes@eoexchange.com>          Tel:  (616) 381-9889 x.18
Sr. Software Engineer, EoExchange, Inc.   http://www.eoexchange.com/
Search, Monitor, Notify.                  http://www.eomonitor.com/


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

Date: Fri, 01 Dec 2000 10:44:57 -0500
From: "Jeff Boes" <jboes@eoexchange.com>
Subject: Re: Date::Manip unable to determine TIMEZONE???
Message-Id: <3a27c8a9$0$30007$44a10c7e@news.net-link.net>

Unless my newsreader has been taken over by the Illuminati, I think "Alan
Mailer" <clarityassoc@earthlink.net> babbled:


> Is there a way of working around this?  For example, is there a way to
> *supply* the appropriate TimeZone indication in my code?

Well, sure. You answered your own question up there ...

>    $ENV{TZ}
>    $main::TZ

Just set either $ENV{TX} or $main::TZ to the appropriate value, e.g.,

$ENV{TZ} = 'EST';

If you don't want this in your code, you could always SET the environment
variable externally, say in your autoexec.

> 
> ... but, I'm assuming none of these places exist in my Windows
> development
> environment; hence the error.
> 

Well, that's were you went wrong ... ;)


-- 
Jeff Boes <jboes@eoexchange.com>          Tel:  (616) 381-9889 x.18
Sr. Software Engineer, EoExchange, Inc.   http://www.eoexchange.com/
Search, Monitor, Notify.                  http://www.eomonitor.com/


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

Date: Fri, 01 Dec 2000 13:17:03 GMT
From: PerlFAQ Server <faq@denver.pm.org>
Subject: FAQ 4.3:   Does Perl have a round() function?  What about ceil() and floor()?  Trig functions?
Message-Id: <jxNV5.46$_g6.170830336@news.frii.net>

This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with every Standard Distribution of
Perl.

+
  Does Perl have a round() function?  What about ceil() and floor()?  Trig functions?

    Remember that int() merely truncates toward 0. For rounding to a certain
    number of digits, sprintf() or printf() is usually the easiest route.

        printf("%.3f", 3.1415926535);       # prints 3.142

    The POSIX module (part of the standard Perl distribution) implements
    ceil(), floor(), and a number of other mathematical and trigonometric
    functions.

        use POSIX;
        $ceil   = ceil(3.5);                        # 4
        $floor  = floor(3.5);                       # 3

    In 5.000 to 5.003 Perls, trigonometry was done in the Math::Complex
    module. With 5.004, the Math::Trig module (part of the standard Perl
    distribution) implements the trigonometric functions. Internally it uses
    the Math::Complex module and some functions can break out from the real
    axis into the complex plane, for example the inverse sine of 2.

    Rounding in financial applications can have serious implications, and
    the rounding method used should be specified precisely. In these cases,
    it probably pays not to trust whichever system rounding is being used by
    Perl, but to instead implement the rounding function you need yourself.

    To see why, notice how you'll still have an issue on half-way-point
    alternation:

        for ($i = 0; $i < 1.01; $i += 0.05) { printf "%.1f ",$i}

        0.0 0.1 0.1 0.2 0.2 0.2 0.3 0.3 0.4 0.4 0.5 0.5 0.6 0.7 0.7 
        0.8 0.8 0.9 0.9 1.0 1.0

    Don't blame Perl. It's the same as in C. IEEE says we have to do this.
    Perl numbers whose absolute values are integers under 2**31 (on 32 bit
    machines) will work pretty much like mathematical integers. Other
    numbers are not guaranteed.

- 

Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short.  They represent an important
part of the Usenet tradition.  They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep comming up.  If you are some how irritated by
seeing these postings you are free to ignore them or add the sender
to your killfile.  If you find errors or other problems with these
postings please send corrections or comments to the posting email
address.

If you are not able to find this or other Perl documentation from
your installation you may access it via the web by following the
appropriate links from one of the addresses listed below.

    http://theoryx5.uwinnipeg.ca/mod_perl/cpan-search
    http://www.perldoc.com
    http://www.cpan.org
    http://www.perl.com

Answers to questions about LOTS of other stuff, mostly not related to
Perl, can be found at

    news:news.answers

and in the many thousands of other useful Usenet news groups.

The perlfaq manual pages contain the following copyright notice.

  AUTHOR AND COPYRIGHT

    Copyright (c) 1997-1999 Tom Christiansen and Nathan
    Torkington.  All rights reserved.

    When included as an integrated part of the Standard
    Distribution of Perl or of its documentation (printed or
    otherwise), this work is covered under Perl's Artistic
    License.  For separate distributions of all or part of
    this FAQ outside of that, see the perlfaq manpage.

    Irrespective of its distribution, all code examples here
    are public domain.  You are permitted and encouraged to
    use this code and any derivatives thereof in your own
    programs for fun or for profit as you see fit.  A simple
    comment in the code giving credit to the FAQ would be
    courteous but is not required.

-- 
    This space intentionally left blank


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

Date: Fri, 01 Dec 2000 10:26:01 -0500
From: "Jeff Boes" <jboes@eoexchange.com>
Subject: Re: good format for frequently-updated database?
Message-Id: <3a27c3fc$0$35013$44a10c7e@news.net-link.net>

Unless my newsreader has been taken over by the Illuminati, I think "Eric
Undersander" <eundersander@austin.rr.com> babbled:

> 
> Any suggestions on how to do this?

Um, your Perl question is what, precisely?

Really, you need to approach this as a programming language-independent
problem. Database design, if it's good, doesn't really impact choice of
language for processing the results. Raise this question in
comp.databases.

-- 
Jeff Boes <jboes@eoexchange.com>          Tel:  (616) 381-9889 x.18
Sr. Software Engineer, EoExchange, Inc.   http://www.eoexchange.com/
Search, Monitor, Notify.                  http://www.eomonitor.com/


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

Date: Fri, 01 Dec 2000 16:49:29 +0100
From: Malte Ubl <ubl@schaffhausen.de>
Subject: Re: HELP BEFORE ME HEAD EXPLODES
Message-Id: <3A27C88A.24C2137E@schaffhausen.de>

neurofase@my-deja.com schrieb:
> 
> I am a complete novice with perl, even though i first starting using it
> a year ago.
> 
> All I do is use edit pad to cut and paste and alter perl forms that I
> already have. I am trying to make up a new bit of perl but i keep
> hitting brick walls.
> 
> Is there any good programs which most people use, like using
> Dreamweaver for HTML.

Yes, its called _VisualPerl++_. You can find it at microsoft.com.
It gives you direct access to the Component Object Model and it
optimizes your scripts to run even better on Windows with the little
downside that they wont run on any other system anymore.

Uhmm, just kidding,

malte


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

Date: Fri, 1 Dec 2000 07:16:19 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Help!
Message-Id: <slrn92f5kj.8ne.tadmc@magna.metronet.com>

[ Excuse the piggybacking, but the foolish Subject caused the
  original article to be auto-deleted from my news spool
  immediately upon receipt.
]

John W. Krahn <krahnj@acm.org> wrote:
>Diana Richardson wrote:
>> 
>> I am totally at my wits end and I know you don't really like helping with
>> homework but I'm stuck. I've tried every combination I know 


Try a combination that includes "check the Perl docs".


>> This is my error message:
              ^^^^^^^^^^^^^
>> Unquoted string "a" may clash with future reserved word at abba line 7.
>> syntax error at abba line 7, near "a
>> 
>> print"
>> Execution of abba aborted due to compilation errors.
>
>perldoc perldiag
>And search for "Unquoted string".


And then note that you do not have an error messages at all!

You have a warning message.

"warnings" are not the same as "errors".

warnings never change the execution of your program. All they
do is make some output on STDERR.

errors either prevent execution altogether (compile-time errors),
or stop the execution of your program early (run-time errors).


-- 
    Tad McClellan                          SGML consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Fri, 01 Dec 2000 10:09:01 -0500
From: "Jeff Boes" <jboes@eoexchange.com>
Subject: Re: how do i escape from perldoc
Message-Id: <3a27bf4a$0$30012$44a10c7e@news.net-link.net>

Unless my newsreader has been taken over by the Illuminati, I think
lightfoote@my-deja.com babbled:

> hi perl family....
> 
> ah still trying to figure out how how to escape from perldoc... every
> key i hit still gets me 'more'     even perldoc perldoc wasn't much
> help...


$ perldoc perldoc

will tell you (under ENVIRONMENT) that it attempts to display the dox
with 'PERLDOC_PAGER', 'MANPAGER', or 'PAGER' (and if none of these
environmental variables results in a usable program or script, it starts
searching other likely locations).

Odds are, if you are on a UNIX-like system, that perldoc is routing
output through 'less'. Thus, you need to know something about 'less' (as
opposed to knowing less about 'something') to operate perldoc. Try 'man
less'.

-- 
Jeff Boes <jboes@eoexchange.com>          Tel:  (616) 381-9889 x.18
Sr. Software Engineer, EoExchange, Inc.   http://www.eoexchange.com/
Search, Monitor, Notify.                  http://www.eomonitor.com/


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

Date: Fri, 1 Dec 2000 09:02:08 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: how do i escape from perldoc
Message-Id: <slrn92fbr0.8ne.tadmc@magna.metronet.com>

lightfoote@my-deja.com <lightfoote@my-deja.com> wrote:

>ah still trying to figure out how how to escape from perldoc...


You do not have a problem with "escaping" from perldoc, you
have a problem escaping from the pager that perldoc sends
it output to.


>every key i hit still gets me 'more'     


How to escape from the pager depends, of course, on what pager
you are using.

Looks like you are using "more", so

   man more

should tell you how to exit from the program.


>even perldoc perldoc
>wasn't much help...


Actually it does, but you may not have recognized it:

   "`perldoc' will use, in order of preference,
    the pager defined in `PERLDOC_PAGER', `MANPAGER', or
    `PAGER' before trying to find a pager on its own."

From that you find out what program you are using, then you
read the docs for that program.


-- 
    Tad McClellan                          SGML consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Fri, 1 Dec 2000 13:53:55 +0100 
From: Lex Hagen <l.hagen@HumanInference.com>
Subject: how to redirect output (to text-file)
Message-Id: <04932F2B7E20D211856C00A0C9A060952B43EF@mail.humaninference.com>

Hi,

Is there a way to redirect output (into a text-file) that is produced
while running a perlprogram on the interpreter?

Thanks,

Lex



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

Date: Fri, 01 Dec 2000 14:09:12 +0100
From: Marco Natoni <foo@bar.va>
Subject: Re: how to redirect output (to text-file)
Message-Id: <3A27A2F8.14A3A0F2@bar.va>

Lex,

Lex Hagen wrote:
> Is there a way to redirect output (into a text-file) that is 
> produced while running a perlprogram on the interpreter?

	$ perldoc -f select


	Best regards,
		Marco


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

Date: Fri, 01 Dec 2000 21:07:06 +0800
From: John Hennessy <john@hennessy.net.au>
Subject: Linux setuid and Perl 5.6.0
Message-Id: <3A27A27A.9AB8B2C2@hennessy.net.au>

I have just installed Perl 5.6.0 on Redhat 6.2 kernel 2.2.17.
I was promptly informed by the Perl installation that Linux did not
support secure setuid operation. Further documentation read seemed to
support the idea that setuid was not even implemented in Linux.

Question: Should I use the setuid emulation offered by the Perl
installation process or is there a better method ?

Thanks

John.



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

Date: Fri, 01 Dec 2000 11:13:17 GMT
From: mmm3000@my-deja.com
Subject: LWP post and get
Message-Id: <90814b$u5e$1@nnrp1.deja.com>

Hello,

 I am working on some sort of autosubmit for CGI scripts
In the program i am creating some submissions are successfull
either with the POST or GET method, using the LWP Agent

However,
 At some scripts I get "All Fields Are Required" as response,
Even when I fill in all the fields ! Even the hidden ones.
I am sure that all variables are spelled right.

Are there some (standard?) variables posted with the script, that are
 not in any way on the HTML page, which holds the FORM ?


Anyone any experience with this ?

Thank you.

ps
The program is meant to autosubmit to the so-called TGP sites


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Fri, 01 Dec 2000 16:00:01 GMT
From: Mike Cameron <mcameron@mirusweb.com>
Subject: Most efficient way of getting a random row from db query?
Message-Id: <3A27D90F.CDC8C076@mirusweb.com>

This code works, but I would like to retreive the row as a hashref not
an arrayref.

# Select a random sale item from this category

  my $query = "SELECT * FROM products WHERE  sale_start <= '2000-11-15'
and sale_end >= '2000-11-15'";
  my $sth = $dbh->prepare($query) || die $sth->errstr;
       $sth->execute() || die $sth->errstr;
  my $saleItems=$sth->fetchall_arrayref();
  my $rand = int(rand (@$saleItems));
  my $randomSaleItem = $saleItems->[$rand];

Should I loop through the records like so?

# Query code omitted ...

  my $randomSaleItem = "";
  my $rand = int(rand ($sth->rows()));
  my $index =0;
while ($randomSaleItem=$sth->fetchrow_hashref()){
     last if $rand == $index++;
}
# Should now have a random hashref in $randomSaleItem

Any comments on efficiency would be appreciated



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

Date: Fri, 01 Dec 2000 13:48:47 GMT
From: "David Sisk" <davesisk@ipass.net>
Subject: Re: Need a web-based real-time option quote provider...
Message-Id: <3%NV5.41567$L26.13177050@typhoon.southeast.rr.com>

OK, perhaps I didn't word this succintly enough for folks who can only
perform literal interpretation, so let me re-phrase the question:

Does anyone know of a real-time option quote provider that is Perl-friendly,
ie. quotes can be easily accessed from a Perl CGI script.

Thanks and regards,
Dave

David Sisk <davesisk@ipass.net> wrote in message
news:A0CV5.8706$88.1413743@typhoon.southeast.rr.com...
> ...similar to Yahoo or CBOE (where an http call from Perl can grab a
simple
> CSV file that is returned), EXCEPT I need real-time stock and option
quotes
> that don't have any redistribution limitations.  For instance, CBOE offers
> paid web-based real-time snapshot quotes similar to their free delayed
> quotes, but they have a use limitation (cannot be redistributed).  I need
a
> real-time provider that charges a monthly fee and doesn't impose any
> limitations.  If anyone knows of any possibilities, please post or email!
>
> Best regards,
> Dave
>
>
>




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

Date: Fri, 1 Dec 2000 14:01:54 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: Need a web-based real-time option quote provider...
Message-Id: <slrn92fbip.cag.bernard.el-hagin@gdndev25.lido-tech>

On Fri, 01 Dec 2000 13:48:47 GMT, David Sisk <davesisk@ipass.net> wrote:
>OK, perhaps I didn't word this succintly enough for folks who can only
>perform literal interpretation, so let me re-phrase the question:

You'll be getting a plethora of replies now, I bet.

Cheers,
Bernard
--
perl -le '$#="Just Another Perl Hacker"; print \Bernard'


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

Date: Fri, 1 Dec 2000 04:35:54 -0800
From: "jnpool" <cwfuchs@sfu.ca>
Subject: next if length < 80;  # why can't Perl be made to recognize this?
Message-Id: <9085qs$deo$1@morgoth.sfu.ca>

Hello Perl savants,

I noticed this statement in the 3rd edition of Programming Perl (page 97)
and
it wasn't obvious to me as to why the language couldn't easily be made to
accomodate this statement.

Is there more insight on this to help out my intuition?

Chris




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

Date: Fri, 01 Dec 2000 07:50:35 -0500
From: H C <carvdawg@patriot.net>
Subject: Re: next if length < 80;  # why can't Perl be made to recognize this?
Message-Id: <3A279E9B.97BC8483@patriot.net>

Maybe it needs to look like this...

next if $length < 80;
         ^^

jnpool wrote:

> Hello Perl savants,
>
> I noticed this statement in the 3rd edition of Programming Perl (page 97)
> and
> it wasn't obvious to me as to why the language couldn't easily be made to
> accomodate this statement.
>
> Is there more insight on this to help out my intuition?
>
> Chris

--
Q: Why is Batman better than Bill Gates?
A: Batman was able to beat the Penguin.




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

Date: Fri, 1 Dec 2000 12:45:55 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: next if length < 80;  # why can't Perl be made to recognize this?
Message-Id: <slrn92f74b.cag.bernard.el-hagin@gdndev25.lido-tech>


[Re-reversed the flow of time]

On Fri, 01 Dec 2000 07:50:35 -0500, H C <carvdawg@patriot.net> wrote:
>jnpool wrote:
>
>> Hello Perl savants,
>>
>> I noticed this statement in the 3rd edition of Programming Perl (page 97)
>> and
>> it wasn't obvious to me as to why the language couldn't easily be made to
>> accomodate this statement.
>>
>> Is there more insight on this to help out my intuition?
>>
>> Chris
>
>Maybe it needs to look like this...
>
>next if $length < 80;
>         ^^

Ummm, I think Chris was talking about the function length, not a variable
$length.

Cheers,
Bernard
--
perl -le '$#="Just Another Perl Hacker"; print \Bernard'


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

Date: Fri, 01 Dec 2000 13:50:03 +0100
From: Marco Natoni <foo@bar.va>
Subject: Re: next if length < 80;  # why can't Perl be made to recognize this?
Message-Id: <3A279E7B.7CC670E2@bar.va>

Chris,

jnpool wrote:
> I noticed this statement in the 3rd edition of Programming Perl 
> (page 97) and it wasn't obvious to me as to why the language 
> couldn't easily be made to accomodate this statement. Is there 
> more insight on this to help out my intuition?

  /lenght/ is a sub that calculates the... lenght of a given string.  If
no scalars are passed as parameter, the /$_/ variable is evaluated.  The
obvious conclusion in this case is that a previous statement has
produced a significant result in /$_/.


	Best regards,
		Marco


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

Date: Fri, 1 Dec 2000 09:20:23 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: next if length < 80;  # why can't Perl be made to recognize this?
Message-Id: <slrn92fct7.8ne.tadmc@magna.metronet.com>

jnpool <cwfuchs@sfu.ca> wrote:

>I noticed this statement in the 3rd edition of Programming Perl (page 97)
>and
>it wasn't obvious to me as to why the language couldn't easily be made to
>accomodate this statement.


Hmmm. Since the authors have tried to explain it in the book,
there must be some part of what they said that you 
"aren't getting". I wonder what part...


use PSI::ESP;

The "pathologically eclectic" part requires a bit of interpretation,
maybe that's where your problem is?

Perl's syntax is loaded with ambiguities. When perl finds an
ambiguity it _must_ disambiguate it so that it can decide
what to do and continue with the rest of the program.

perl "guesses" what you meant. Sometimes it guesses wrong.
Sometimes it knows that it cannot make a reliable guess, so
it gives up (won't compile). You have hit the second case :-)


>Is there more insight on this to help out my intuition?


Errr, yes.

You write a program that tries it, and you see what it says:

---------------
#!/usr/bin/perl -w
use strict;

while (<DATA>) {
   next if length < 80;
}

print "all done\n";
---------------

Warning: Use of "length" without parens is ambiguous at ./temp line 5.
Unterminated <> operator at ./temp line 5.



perl can't decide if you are doing a numerical "less than"
operation or if you are starting to do input (or filename
globbing).

So Perl would not be the easy to use, "divine what I mean"
magician that we all know and love if the ambiguities were
removed from the language.

i.e. "fixing" the above would make Perl unPerlish.


-- 
    Tad McClellan                          SGML consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Fri, 1 Dec 2000 07:31:56 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: OT Cargo Cult? (Was: Re: reformatting a perl script)
Message-Id: <slrn92f6hs.8ne.tadmc@magna.metronet.com>

Tim Schmelter <schmelter_tim@hotmail.com> wrote:

>I've seen the phrase in this newsgroup a couple of times, but it's
>significance eludes me. What exactly is meant by "cargo-cult"?


http://www.tuxedo.org/~esr/jargon/html/entry/cargo-cult-programming.html


-- 
    Tad McClellan                          SGML consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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 V9 Issue 5007
**************************************


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