[17207] in Perl-Users-Digest
Perl-Users Digest, Issue: 4619 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Oct 14 21:05:21 2000
Date: Sat, 14 Oct 2000 18:05:07 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <971571906-v9-i4619@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sat, 14 Oct 2000 Volume: 9 Number: 4619
Today's topics:
Re: [Q] "pass along" in AUTOLOAD ? <kj0@mailcity.com>
Re: A Simpler perlish way (Logan Shaw)
Re: A variable menage-a-trois? Too Strict! (Martien Verbruggen)
Re: Converting to thumbnails (Martien Verbruggen)
Re: cookies blocked by "location"? (Scott Roberts)
Re: cookies blocked by "location"? <jeff@vpservices.com>
Help needed with form-modification in perl <mjaccoud@webshuttle.ch>
Re: Help needed with form-modification in perl <anders@wall.alweb.dk>
Help with FOREACH <jtjohnston@courrier.usherb.ca>
Re: Help with FOREACH <anders@wall.alweb.dk>
Re: Help with FOREACH <anders@wall.alweb.dk>
Re: Help with FOREACH (Mark-Jason Dominus)
Re: I need a DB solution <john@netoz.au.com>
Re: I need a DB solution <jeff@vpservices.com>
Re: I need a DB solution <zaphod@psnw.com>
Re: I need a DB solution <john@netoz.au.com>
Re: Perl Output <jaysonb@mbox.com.au>
Re: tips on installing Image::Magick ? (Martien Verbruggen)
Re: user-defined operators? (Martien Verbruggen)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 14 Oct 2000 18:43:04 -0400
From: kj0 <kj0@mailcity.com>
Subject: Re: [Q] "pass along" in AUTOLOAD ?
Message-Id: <8sanho$20i$1@panix3.panix.com>
Keywords: carpenter, contemporary, phenol, tell
>"Passing" the method call does not make sense, because there is
>nowhere to pass it to. If there were a DESTROY method to inherit
>from, that method would have been called in the first place, instead
>of AUTOLOAD. AUTOLOAD is the handler of *last* resort.
OK, got it. Thanks a lot.
KJ
------------------------------
Date: 14 Oct 2000 18:01:06 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: A Simpler perlish way
Message-Id: <8saoji$emv$1@provolone.cs.utexas.edu>
In article <sT3G5.16859$6O5.1502220@news1.rdc1.mb.home.com>,
Andrew Johnson <andrew-johnson@home.com> wrote:
>In article <103G5.48026$td5.7224524@news1.rdc2.pa.home.com>,
> Ben Kennedy <bkennedy@hmsonline.com> wrote:
>Indeed, not only is it unfair, it is simply incorrect.
>
>Using a module is not cargo-cult programming -- to think so is a
>misunderstanding of both the term 'cargo-cult' and programming.
>
>Using a well tested module is not at all like emulating an airstrip
>in an attempt to entice cargo planes to land -- rather, it is like
>going to an actual air freight shipping company who know all the
>protocols and ins and outs of shipping cargo by plane and arranging
>through them to send or receive your shipments of goods.
>
>Using a module in such a way stands in opposition to building your
>own real airstrips, manufacturing your own real planes, training your
>own pilots and cargo handlers, etc, etc,... ie, reinventing or
>reimplementing the wheel.
Indeed, modern society is simply too specialized for anything *else* to
happen, at least at some level.
I am what a friend of mine once described as a "depth-first person",
which in the context of Perl means that I would probably rather
understand how a module works than to actually use it to get something
accomplished. This is probably partly because I enjoy knowing about
the way things work, especially if there's something clever involved,
and partially because I only truly feel comfortable using a module once
I'm familiar enough with its workings to trust it.
After doing this kind of thing enough, I eventually realized that you
just can't do that forever. If I really want to know how a Perl module
works, I will read the module's source code, and that will probably
turn me on to some Perl feature I had heard about but hadn't used, and
that will, perhaps, make me think about some new programming languages
concept, like maybe closures. And then I might start wondering both
how closures can be used to alter how I think about programming and
about how closures are implemented and whether they're efficient. From
there I might find myself examining Perl's internals and/or learning
about other programming languages that use closures in order to better
understand them.
This might all be very interesting, but at some point I've simply got
to stop. Eventually, I'll find myself going to lower and lower levels,
and I'll want to know about computer architecture, then about digital
systems design, and then about chip making technologies, and then about
quantum physics (so I can understand transistors), and so on. At each
level, I can gain enough understanding so I can say I generally know
what's going on, but I could still be accused of being a cargo cultist
if I couldn't build the thing I'm using myself. The problem is, more
than 100 man-years have gone into creating this stuff, and I'll
eventually die before I do anything useful.
The point? Abstraction / black boxes, whether you like them or not,
are absolutely essential to doing the complex tasks we do today.
Everyone who participates in modern society uses them. Heck, even
people who lived 1000 years ago did the same thing. Society is
specialize and interwoven, and the important thing with Perl modules,
just like anything else, is not so much that you understand them but
that you know that someone understands them properly and has done the
right thing.
- Logan
------------------------------
Date: Sun, 15 Oct 2000 10:16:43 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: A variable menage-a-trois? Too Strict!
Message-Id: <slrn8uhqar.294.mgjv@martien.heliotrope.home>
On Sat, 14 Oct 2000 07:53:38 -0700,
Michael Sattler <michael@GeekTimes.com> wrote:
> I would like to share a bunch of variables declarations between three
> CGIs. For example,
goto http://www.deja.com/home_ps.shtml, and find the thread with the
subject "included files: missing one important concept...", which was
running here on 10 and 11 October.
The various articles in that thread answer your question, and answer why
your attempt failed.
Did you read the group at all before posting?
Martien
--
Martien Verbruggen |
Interactive Media Division | Useful Statistic: 75% of the people
Commercial Dynamics Pty. Ltd. | make up 3/4 of the population.
NSW, Australia |
------------------------------
Date: Sun, 15 Oct 2000 10:05:35 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Converting to thumbnails
Message-Id: <slrn8uhplv.294.mgjv@martien.heliotrope.home>
[In the future, please post your reply _after_ the suitably trimmed text
that you reply to]
On Sat, 14 Oct 2000 20:36:10 GMT,
dtbaker_dejanews@my-deja.com <dtbaker_dejanews@my-deja.com> wrote:
[reordered post]
> In article <slrn8tkrci.b9n.mgjv@verbruggen.comdyn.com.au>,
> mgjv@tradingpost.com.au wrote:
> >
> > use Image::Magick;
> > # http://www.imagemagick.org/
>
> good information... I need to do some similar work. I have used
> Image::Size to get the size, but was needing to actually resample the
> images as well.
>
> I went and looked at the docs for this Image::ImageMagick , and I got a
> little overwhelmed by the install requirements. It looks like you might
> need both the perl lib and also a C++ development environment to
> install? I would like to install both on my PC running win98 and install
> to my UNIX domain online to use in some cgi. Is this going to be
> possible without root privs on the remote server?
You don't need the Magick++ libraries, but you might as well install
them. What you need to do, is install ImageMagick proper first. Then you
install the perl module that interfacres with it. The installation
process of ImageMagick is fairly straightforward, and I believe you can
even get binary distributions.
Unpack the distribution, and in the top directory:
# ./configure
# make
# make test
# make install
Some versions had problems in compiling up the Perl module without having
IM installed et, so you might have to do:
# ./configure --without-perl
# make
# make install
# cd PerlMagick
# perl Makefile.PL
# make
# make install
To disable Magick++ installation (but again, there's no real reason for
that) use --without-magick-plus-plus as an option to configure
# ./configre --help
Martien
--
Martien Verbruggen |
Interactive Media Division | Can't say that it is, 'cause it
Commercial Dynamics Pty. Ltd. | ain't.
NSW, Australia |
------------------------------
Date: Sat, 14 Oct 2000 22:21:28 GMT
From: scott@heelspurs.castrate.this.part.com (Scott Roberts)
Subject: Re: cookies blocked by "location"?
Message-Id: <39e8d91e.121245512@news.knology.net>
I can't find an explanation of "location" in any of my 6 Perl books,
but its used frequently in Perl code. There's only one small section
in the online docs, which don't explain what it's doing. I guess it's
a TCP/IP or Unix or Web browser thing.
On Sat, 14 Oct 2000 17:32:09 GMT, David Steuber
<nospam@david-steuber.com> wrote:
>I'm not sure what the Perl question is here.
>
>Cookies are only sent back to the server that sets them. They do not
>follow a redirect.
>
>The other system should be setting a cookie based on the URL you
>redirected too. Otherwise, only the click through will be recorded,
>not any subsequent activity.
>
>--
>David Steuber | Perl apprentice, Apache/mod_perl user,
>NRA Member | and general Internet web wannabe.
>ICQ# 91465842
>*** http://www.david-steuber.com/ ***
------------------------------
Date: Sat, 14 Oct 2000 15:42:04 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: cookies blocked by "location"?
Message-Id: <39E8E13C.7BFE7859@vpservices.com>
Scott Roberts wrote:
>
> I can't find an explanation of "location" in any of my 6 Perl books,
Right, it is a term used in the CGI and HTTP specifications, and has
nothing to do with Perl.
> but its used frequently in Perl code.
The term "cash transaction" is used frequently in Perl code for
accounting systems, that doesn't mean that cash transactions have
anything to do with Perl or that Perl books would deal with them.
I suggest you read up on and/or inquire in newsgroups related to CGI,
HTML, and HTTP to find out more about how redirects and cookies work.
Once you have determined the proper flow of information betweent the
various CGI scripts and cookie files involved you may have questions
about how you would implement that flow in Perl. Please do come back
and ask those questions here when you reach that point.
It is possible that rather than having Perl simply redirect to a
different page, you will want it to send information to a form on
another page through something like the LWP module (WWW library for
Perl) or it may be that your changes will be unrelated to Perl and will
have to do with what information is in the redirect URL and with the
processing capabilities of the page or script that redirect ends up at.
--
Jeff
------------------------------
Date: 14 Oct 2000 23:08:06 GMT
From: "Michael Jaccoud" <mjaccoud@webshuttle.ch>
Subject: Help needed with form-modification in perl
Message-Id: <l4.b4.FA2p0Ce6btiSEZh.NR@webshuttle.ch>
Hi all
I come to this group as a newbe.... I never tried perl up to yesterday, because
a friend needs assistance because he has no flair for programming languages.
I've tested dozens of ways to get a working script but without any success :(
OK, now the problem: I have a form on a website to fill in. There are about 20
or 25 fields and if i send the form whithout a perl script between the mail get all
informations of this form in the right order but then it's "one piece of
code"...
When i do it with the following script:
----------------------------
# sort fields
my ($key,$value,@sorted);
my $sort = $query{'sort'} || '';
if ($sort eq 'order') {
foreach $key (sort keys %query) {
next if grep {$_ eq $key} @hidden;
next if (!$query{$key} && $query{'hide_blanks'});
print S "$key: $query{$key}\n";
}
}
elsif {
while (($key,$value) = each %query) {
print S "$key: $value\n"
unless ((grep {$_ eq $key} @hidden)||(!$value && $query{'hide_blanks'}));
}
}
print S "\n\n";
----------------------------
and when I set somewhere in the html-code an
<INPUT TYPE="hidden" NAME="sort" VALUE="alphabetic">
i get alphabetic sorted answers. But what can I do that I get the form the same
order like I insert in the form??? If I work with @sorted ('1','2') and so on it
seems I get a overflow or something like that, because the numbers are to much
strings. But this can't be the solution to sort them the right way, because the
form itself HAS the right order. How can I parse the Form in the right order
with Perl? ATTENTION: The script you see here should not be modificated, there
should be a new "elsif" to catch an
<INPUT TYPE="hidden" NAME="sort" VALUE="order">
Any help???
Thank you all in advance!
--
Gruss, Michael Jaccoud
--------------------------------------------------------
Best regards Return mail address:
Michael Jaccoud topgun@pop.ch
--------------------------------------------------------
------------------------------
Date: Sun, 15 Oct 2000 02:03:21 +0200
From: Anders Lund <anders@wall.alweb.dk>
Subject: Re: Help needed with form-modification in perl
Message-Id: <0w6G5.944$Uy5.75095@news000.worldonline.dk>
Michael Jaccoud wrote:
> Hi all
>
> I come to this group as a newbe.... I never tried perl up to yesterday,
> because a friend needs assistance because he has no flair for programming
> languages.
>
> I've tested dozens of ways to get a working script but without any success
> :(
>
> OK, now the problem: I have a form on a website to fill in. There are
> about 20 or 25 fields and if i send the form whithout a perl script
> between the mail get all informations of this form in the right order but
> then it's "one piece of code"...
>
> When i do it with the following script:
> ----------------------------
> # sort fields
> my ($key,$value,@sorted);
> my $sort = $query{'sort'} || '';
> if ($sort eq 'order') {
> foreach $key (sort keys %query) {
> next if grep {$_ eq $key} @hidden;
> next if (!$query{$key} && $query{'hide_blanks'});
> print S "$key: $query{$key}\n";
> }
> }
>
>
> elsif {
> while (($key,$value) = each %query) {
> print S "$key: $value\n"
> unless ((grep {$_ eq $key} @hidden)||(!$value &&
> $query{'hide_blanks'}));
> }
> }
> print S "\n\n";
> ----------------------------
> and when I set somewhere in the html-code an
> <INPUT TYPE="hidden" NAME="sort" VALUE="alphabetic">
> i get alphabetic sorted answers. But what can I do that I get the form the
> same order like I insert in the form??? If I work with @sorted ('1','2')
> and so on it seems I get a overflow or something like that, because the
> numbers are to much strings. But this can't be the solution to sort them
> the right way, because the form itself HAS the right order. How can I
> parse the Form in the right order with Perl? ATTENTION: The script you see
> here should not be modificated, there should be a new "elsif" to catch an
> <INPUT TYPE="hidden" NAME="sort" VALUE="order">
>
>
> Any help???
>
> Thank you all in advance!
First, you have to realize that the browser may or may not send the data in
an order corresponding to your form.
It seems you have your data in a hash %query, but where does that come
from? The block or sub that provides that, is the place to place code to
save the order. If you wrote your own parsing function, usually using split
in two levels, you should do like below:
@pairs = split/&/, $data;
for (@pairs) {
($key, $value) = split /=/;
...
# HERE
push @order, $key;
}
However, if you use the CGI module, you should read the documentation which
states:
FETCHING THE NAMES OF ALL THE PARAMETERS PASSED TO YOUR
SCRIPT:
@names = $query->param
If the script was invoked with a parameter list (e.g.
"name1=value1&name2=value2&name3=value3"), the param()
method will return the parameter names as a list. If the
script was invoked as an <ISINDEX> script, there will be a
single parameter named 'keywords'.
NOTE: As of version 1.5, the array of parameter names
returned will be in the same order as they were submitted
by the browser. Usually this order is the same as the
order in which the parameters are defined in the form
(however, this isn't part of the spec, and so isn't
guaranteed).
Now you can add your block, assuming that you have the order in an array
named @order:
elsif ($sort eq 'order') {
for (@order) {
# next statements
print "$_: $query{$_}\n"
}
}
A comment:
> next if grep {$_ eq $key} @hidden;
Use a hash!! assuming that you have a list in the form stating which fields
are of type hidden, you can just
$hidden{$_}++ for (@hidden);
Then you do
next if $hidden{$key};
-anders
--
[ the word wall - and the trailing dot - in my email address
is my _fire_wall - protecting me from the criminals abusing usenet]
------------------------------
Date: Fri, 13 Oct 2000 17:37:26 -0400
From: jtjohnston <jtjohnston@courrier.usherb.ca>
Subject: Help with FOREACH
Message-Id: <39E78096.4A1C@courrier.usherb.ca>
Basically, I have a webring and I want to print the next five sites in
the ring.
Let's say $IDkey = 5.
I want to print out the next five lines in the database after $IDkey.
$key doesn't always exist. For example key = 11 does not exist. So when
I call
http://....com/webring/test.cgi?action=next5&link=7
I only get four print outs.
If link=20, which is only two lines away from the end of the database, I
only get one line. Therefore, I would like to wrap around to the
beginning of the database and grab the first 4 lines too.
Can anyone help me with this bit of script?
Thanks,
John
####################################################################################
if ($in{'action'} eq 'next5')
{
$IDkey = $in{'link'};
$output.= "<CENTER><TABLE border=0 CELLPADDING=2 CELLSPACING=0>\n";
dbmopen(%DB, "$data_path/data", 0777) || die &error(" Unable to open
$data_path/data. Reason:$!");
foreach $key (sort {$a<=>$b} keys %DB)
{
($db_contact_name, $db_email, $db_title, $db_url, $db_desc,
$db_keywords, $db_hits,
$db_flag, $db_date, $db_time) = split (/\t/, $DB{$key});
if (($key eq $IDkey+1) || ($key eq $IDkey+2) || ($key eq
$IDkey+3) || ($key eq $IDkey+4) ||($key eq $IDkey+5))
{
$output.= "<TR>\n";
$output.= "<TD BGCOLOR=#FF9FFF
NOWRAP><B><$font>$key.</FONT></B></TD>";
$output.= "<TD BGCOLOR=#FF9FFF NOWRAP><B><$font> <A
HREF=\"$cgi_url/jump.cgi?action=go&link=$key\"
Target=\"_top\">$db_title</A></FONT></B></TD>";
$output.= "</TR><TR>\n";
}
}
dbmclose(%DB);
$output.= "</TABLE></CENTER></UL>\n";
print "$output\n";
}
}
------------------------------
Date: Sun, 15 Oct 2000 02:32:11 +0200
From: Anders Lund <anders@wall.alweb.dk>
Subject: Re: Help with FOREACH
Message-Id: <2X6G5.948$Uy5.75454@news000.worldonline.dk>
jtjohnston wrote:
> Basically, I have a webring and I want to print the next five sites in
> the ring.
>
> Let's say $IDkey = 5.
> I want to print out the next five lines in the database after $IDkey.
>
> $key doesn't always exist. For example key = 11 does not exist. So when
> I call
>
> http://....com/webring/test.cgi?action=next5&link=7
>
> I only get four print outs.
>
> If link=20, which is only two lines away from the end of the database, I
> only get one line. Therefore, I would like to wrap around to the
> beginning of the database and grab the first 4 lines too.
>
> Can anyone help me with this bit of script?
>
> Thanks,
>
> John
>
I put a few comments with oyur code, but see below.
###########################################################################
#########
> if ($in{'action'} eq 'next5')
> {
> $IDkey = $in{'link'};
>
> $output.= "<CENTER><TABLE border=0 CELLPADDING=2 CELLSPACING=0>\n";
>
> dbmopen(%DB, "$data_path/data", 0777) || die &error(" Unable to open
> $data_path/data. Reason:$!");
>
> foreach $key (sort {$a<=>$b} keys %DB)
> {
You are not sure that you will use theese data. Only do the split if you
actually want to use them...
> ($db_contact_name, $db_email, $db_title, $db_url, $db_desc,
> $db_keywords, $db_hits,
> $db_flag, $db_date, $db_time) = split (/\t/, $DB{$key});
This is REALLY BAD!!
You should use a counter, instead of this one!!!
>
> if (($key eq $IDkey+1) || ($key eq $IDkey+2) || ($key eq
> $IDkey+3) || ($key eq $IDkey+4) ||($key eq $IDkey+5))
> {
> $output.= "<TR>\n";
> $output.= "<TD BGCOLOR=#FF9FFF
> NOWRAP><B><$font>$key.</FONT></B></TD>";
> $output.= "<TD BGCOLOR=#FF9FFF NOWRAP><B><$font> <A
> HREF=\"$cgi_url/jump.cgi?action=go&link=$key\"
> Target=\"_top\">$db_title</A></FONT></B></TD>";
> $output.= "</TR><TR>\n";
> }
> }
> dbmclose(%DB);
>
> $output.= "</TABLE></CENTER></UL>\n";
> print "$output\n";
>
> }
> }
if ($in{'action'} eq 'next5')
{
$IDkey = $in{'link'};
$output.= "<CENTER><TABLE border=0 CELLPADDING=2 CELLSPACING=0>\n";
dbmopen(%DB, "$data_path/data", 0777) || die &error(" Unable to open
$data_path/data. Reason:$!");
foreach $key (sort {$a<=>$b} keys %DB)
{
my @sortedkeys = sort keys %BD;
# See perldoc -f splice for informaiton..
my @keys = splice @sortedkeyx, $IDkey + 1, 5;
# If we didn't get 5, take some from the top.
push @keys splice (@sortedkeys, 0, 5 - scalar @keys) if (scalar @keys < 5);
for (@keys) # Oops, no foreach no more.
{
# Now we know that we want this record, parse it.
($db_contact_name, $db_email, $db_title, $db_url, $db_desc,
$db_keywords, $db_hits,
$db_flag, $db_date, $db_time) = split (\t, $DB{$_});
# Here document, nifty eh...
$output.= << "COOL HERE DOCUMENT"
<TR>
<TD BGCOLOR=#FF9FFF NOWRAP><B><$font>$_</FONT></B></TD>
<TD BGCOLOR=#FF9FFF NOWRAP><B><$font>
<A HREF=\"$cgi_url/jump.cgi?action=go&link=$_\"
Target=\"_top\">$db_title</A></FONT></B></TD>
</TR>
<TR>
COOL HERE DOCUMENT
;
}
}
dbmclose(%DB);
$output.= "</TABLE></CENTER></UL>\n";
print "$output\n";
}
}
--
[ the word wall - and the trailing dot - in my email address
is my _fire_wall - protecting me from the criminals abusing usenet]
------------------------------
Date: Sun, 15 Oct 2000 02:34:14 +0200
From: Anders Lund <anders@wall.alweb.dk>
Subject: Re: Help with FOREACH
Message-Id: <ZY6G5.950$Uy5.75504@news000.worldonline.dk>
Anders Lund wrote:
Bad mistake, I forgot to remove some lines.
>
> if ($in{'action'} eq 'next5')
> {
> $IDkey = $in{'link'};
>
> $output.= "<CENTER><TABLE border=0 CELLPADDING=2 CELLSPACING=0>\n";
>
> dbmopen(%DB, "$data_path/data", 0777) || die &error(" Unable to open
> $data_path/data. Reason:$!");
>
######## foreach $key (sort {$a<=>$b} keys %DB)
######## { THEESE ARE REPLACED BELOW---------
>
> my @sortedkeys = sort keys %BD;
> # See perldoc -f splice for informaiton..
> my @keys = splice @sortedkeyx, $IDkey + 1, 5;
> # If we didn't get 5, take some from the top.
> push @keys splice (@sortedkeys, 0, 5 - scalar @keys) if (scalar @keys <
> 5);
>
> for (@keys) # Oops, no foreach no more.
> {
> # Now we know that we want this record, parse it.
> ($db_contact_name, $db_email, $db_title, $db_url, $db_desc,
> $db_keywords, $db_hits,
> $db_flag, $db_date, $db_time) = split (\t, $DB{$_});
> # Here document, nifty eh...
> $output.= << "COOL HERE DOCUMENT"
> <TR>
> <TD BGCOLOR=#FF9FFF NOWRAP><B><$font>$_</FONT></B></TD>
> <TD BGCOLOR=#FF9FFF NOWRAP><B><$font>
> <A HREF=\"$cgi_url/jump.cgi?action=go&link=$_\"
> Target=\"_top\">$db_title</A></FONT></B></TD>
> </TR>
> <TR>
> COOL HERE DOCUMENT
> ;
> }
> }
> dbmclose(%DB);
>
> $output.= "</TABLE></CENTER></UL>\n";
> print "$output\n";
>
> }
> }
>
>
--
[ the word wall - and the trailing dot - in my email address
is my _fire_wall - protecting me from the criminals abusing usenet]
------------------------------
Date: Sun, 15 Oct 2000 01:02:55 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: Help with FOREACH
Message-Id: <39e9023f.1223$3d0@news.op.net>
In article <39E78096.4A1C@courrier.usherb.ca>,
jtjohnston <jtjohnston@courrier.usherb.ca> wrote:
> foreach $key (sort {$a<=>$b} keys %DB)
I think 'while' is a better fit here. Perhaps yry something like this:
$num_shown = 0;
$next_site = $ID_key + 1;
while ($num_shown < 5) {
if (exists $DB{$next_site}) { # This is a real site
# We will display this one.
($db_contact_name, $db_email, etc....)
= split /\t/, $DB{$next_site};
$output .= "<TR>\n";
etc....;
$num_shown++;
}
$next_site++;
}
This runs the while loop over and over, until you have accumulated
information for five sites total. If you try an ID number and
discover that it doesn't correspond to a real site, you don't increase
$num_shown, so the loop tries the next site number instead.
($num_shown++ means to increase $num_shown by 1.)
Now look carefully at the code until you understand what it is doing
and what all the variables are for. Otherwise the rest of the
article will not make sense.
There's a bug here: Suppose there are 57 sites, and someone is at site
#55 and asks for the next 5. This code will look for site #56 and add
its information to the output, then do the same for site #57. Then it
will look for site #58, but there isn't one, so it will try #59
instead, but there is no #59 either, so it will look for #60.... it is
in an infinite loop, because there are no more sites.
Somehow the code needs to know that there are only 57 sites, and
instead of looking for #58 it needs to go back to #1. That is because
you are running a web ring and not a web line.
To fix this, you need to have the database remember the maximum ID
number that has been used in your ring. You must have this recorded
somewhere already, or else when someone added a new site to the ring
you would not know what number to give them. Let's suppose that this
information is recorded in $DB{MAX}. Say, if there are 57 sites in
all, then $DB{MAX} will be 57. Then, instead of just
$next_site++;
you use:
$next_site++;
if ($next_site > $DB{MAX}) { $next_site = 1 }
so that if $next_site ever becomes too large, you wrap it around and
make it 1 instead.
This still has a bug: If there are fewer than five sites total, it
will output some of them more than once, because $next_site will go
clear around the ring and come back to where it started. There are
several ways to deal with this. One way is to ignore it; then if
there are only three sites in the ring, some of them will be listed
twice in the 'next 5' display. That may be acceptable, at least for
the first implementation.
Another approach is to add yet another item to the database:
$DB{NUM_SITES}, which will record the total number of sites. (This is
different from $DB{MAX}, because if sites #1, #2, and #5 exist but #3
and #4 don't, then $DB{MAX} will be 5, while $DB{NUM_SITES} will only
be 3.) Then replace this:
while ($num_shown < 5) {
...
with this:
$num_to_show = 5;
if ($num_to_show > $DB{NUM_SITES}) { $num_to_show = $DB{NUM_SITES} }
while ($num_shown < $num_to_show) {
...
This says that normally you're going to show 5 sites, but if that is
larger than the number of sites in the database, you are going to show
exactly the number in the database instead.
Hope this helps. Good luck.
------------------------------
Date: Sun, 15 Oct 2000 08:13:43 +1000
From: "JohnB" <john@netoz.au.com>
Subject: Re: I need a DB solution
Message-Id: <39e8db13$0$11608$7f31c96c@news01.syd.optusnet.com.au>
Hi Neb
A database solution I have used successfully can be found at www.flatext.com
I have used it with data records up to 12,000 and it is still very quick. It
is also easy to use, inexpensive and configurable
New MySQL version coming soon I believe
Hope this helps
Regards
John
------------------------------
Date: Sat, 14 Oct 2000 15:24:01 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: I need a DB solution
Message-Id: <39E8DD01.E1FFB0E0@vpservices.com>
JohnB wrote:
>
> A database solution I have used successfully can be found at www.flatext.com
Sorry, my DNS can't find that address, is the URL correct?
--
Jeff
------------------------------
Date: Sat, 14 Oct 2000 15:20:33 -0700
From: Zaphod <zaphod@psnw.com>
Subject: Re: I need a DB solution
Message-Id: <39E8DC31.11035C0D@psnw.com>
Jeff Zucker wrote:
>
> JohnB wrote:
> >
> > A database solution I have used successfully can be found at www.flatext.com
>
> Sorry, my DNS can't find that address, is the URL correct?
>
> --
> Jeff
add an extra "t" make it www.flattext.com
--
Zaphod
Technical Director
------------------------------------------------------------------------
TruckLoad2000.com A Service of Acquisitions Services, LLC.
------------------------------------------------------------------------
Support: (559) 304-0882 2680 N. Marks suit 106
Direct: (559) 275-0493 Fresno, CA 93722
Toll Free: (866) 275-0493 http://www.TruckLoad2000.com
Fax: (559) 275-0529 email: zaphod@TruckLoad2000.com
========================================================================
========================================================================
------------------------------
Date: Sun, 15 Oct 2000 08:52:18 +1000
From: "JohnB" <john@netoz.au.com>
Subject: Re: I need a DB solution
Message-Id: <39e8e41f$0$11632$7f31c96c@news01.syd.optusnet.com.au>
sorry, typing to quick for my own good
www.flattext.com
john
------------------------------
Date: Sat, 14 Oct 2000 22:46:27 GMT
From: Jayson Barber <jaysonb@mbox.com.au>
Subject: Re: Perl Output
Message-Id: <39E8EE43.812D4910@mbox.com.au>
Ge! Im sorry, but perl isn't my speciallity, im trying to capture the output
and place it in to my Visual Basic Program.
Once again, I am deeply sorry
Jayson Barber
(jaysonb@mbox.com.au)
Gwyn Judd wrote:
> I was shocked! How could Jayson Barber <user1@study.vic.bigpond.net.au>
> say such a terrible thing:
> >
> >--------------B25ACC5AE9D6F6534917176B
> >Content-Type: text/plain; charset=us-ascii
> >Content-Transfer-Encoding: 7bit
> >
> >Hey!
> >
> >Is there a way to dump all of the output of a perl script to a file,
> >without too much coding changes, eg one line at the top of the program,
> >etc
>
> perl my_perl_script.pl > my_output.txt
>
> --
> Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
> "Maybe we... we all need to wake up. Become special, before it's too late."
> -- Duncan (to Marcus), "Exogenesis"
------------------------------
Date: Sun, 15 Oct 2000 10:22:14 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: tips on installing Image::Magick ?
Message-Id: <slrn8uhql6.294.mgjv@martien.heliotrope.home>
On Sat, 14 Oct 2000 21:27:36 GMT,
dtbaker_dejanews@my-deja.com <dtbaker_dejanews@my-deja.com> wrote:
> I need to do some image re-sampling and manipulation... and it looks
> like the module Image::Magick will fill the bill. However, I am not very
> familar with installing the optional modules. The instructions seem to
> be mostly designed for UNIX, and assume you have root privs.
>
> I would like to know if there is a tutorial that might walk thru the
> installs on both a local windows98 PC, and a remote UNIX domain host
> where I do NOT have root privs and would have to install to my
> mydomain/cgi-bin/ImageMagick dir or something like that.
For win98, get the binaries from
ftp://ftp.cdrom.com/pub/ImageMagick/win2k (you can find that link from
the ImageMagick home page at http://www.imagemagick.org/).
For a unix system, unpack the sources, and in the top level dir:
# ./configure --prefix=/home/me/imagemagick
for more info
# cat README
# ./configure --help
Alrternatively, you can see whether there are some binaries availabel
that can be installed without root
privileges: ftp://ftp.cdrom.com/pub/ImageMagick/binaries, but I doubt
that.
Martien
--
Martien Verbruggen | My friend has a baby. I'm writing
Interactive Media Division | down all the noises the baby makes
Commercial Dynamics Pty. Ltd. | so later I can ask him what he meant
NSW, Australia | - Steven Wright
------------------------------
Date: Sun, 15 Oct 2000 10:10:17 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: user-defined operators?
Message-Id: <slrn8uhpup.294.mgjv@martien.heliotrope.home>
On Sat, 14 Oct 2000 16:39:14 +0200,
Ole Christian Eidheim <eidheim@hivolda.no> wrote:
> Is it possible to create user-defined operators in Perl?
What exactly are you asking? Is
# perldoc overload
What you mean, or are you really looking for new operators?
Martien
--
Martien Verbruggen |
Interactive Media Division | If it isn't broken, it doesn't have
Commercial Dynamics Pty. Ltd. | enough features yet.
NSW, Australia |
------------------------------
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 4619
**************************************