[13708] in Perl-Users-Digest
Perl-Users Digest, Issue: 1118 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 19 13:11:27 1999
Date: Tue, 19 Oct 1999 10:10:17 -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: <940353017-v9-i1118@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 19 Oct 1999 Volume: 9 Number: 1118
Today's topics:
Mastering Algorithms With Perl-- Reviews (Sergej Zoubok)
MOMspider problems <kenneth@guiden.no>
Re: newbie <madebeer@igc.apc.org>
Re: perl and encrypted cookies rwentwor@advent.com
Re: Pseudo Hashes <jtolley@bellatlantic.net>
Re: shifting a hash <rhomberg@ife.ee.ethz.ch>
Re: sorting arrays (Kragen Sitaker)
Re: THANKS FOR ALL THE HELP (Craig Berry)
Re: Unix command ´tree´ in Perl? <jseigh@bbnplanet.com>
Using SQL stored procedure in Perl gqc2017@my-deja.com
Re: Using SQL stored procedure in Perl (Brett W. McCoy)
Re: Using SQL stored procedure in Perl (Michel Dalle)
Using SQL stored procedure gqc2017@my-deja.com
Why does this compile? (James Moody)
Re: Why does this compile? (M.J.T. Guy)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 19 Oct 1999 16:47:33 GMT
From: sqz1909@is2.nyu.edu (Sergej Zoubok)
Subject: Mastering Algorithms With Perl-- Reviews
Message-Id: <Fg1P3.22$zJ1.1327@typhoon.nyu.edu>
Has anyone read "Mastering Algorithms With Perl" by Jon Orwant, et al.? It
seems like an ideal addition to my Perl reference shelf but I've been
unable to find a copy to browse. I'd be interested, as I hope others
would be, in hearing more about it.
Regards,
Sergej
------------------------------
Date: Tue, 19 Oct 1999 17:38:39 +0200
From: Keneth Gulliksen <kenneth@guiden.no>
Subject: MOMspider problems
Message-Id: <380C907F.58B07FA5@guiden.no>
Anybody having any experience running MOMspider 1.00 ? Have problems
with the following file : sys_socket_ph.c
It seems not possible to compile it in c and make it running. Good
suggestion could be mailed me kenneth@guiden.no
Thanks
------------------------------
Date: Tue, 19 Oct 1999 09:30:13 -0700 (PDT)
From: Michael de Beer <madebeer@igc.apc.org>
Subject: Re: newbie
Message-Id: <APC&1'0'50775dd3'78d@igc.apc.org>
Ran wrote:
>Hi there, I'm a Perl newbie.
Keep reading those docs! Especially the O'Reilly book 'Learning Perl';
>The file consists of lines of the following format:
><someword>: <number_of_files> <filename1.txt> <filename1.txt> ....
OK
>I want to do something like the following:
>
>while ($line = <FILE>) {
> ($word, $number, $array_of_files) = split(" ", $line);
If you want $array_of_files to be a list/array, it should be
@array_of_files, not $array_of_files.
>but how would I get the array_of_files to work?
depends what you mean by 'work'
>I can't figure that out.
This code does something with @array_of_files. Maybe it'll show you
what you're looking for. If you're on unix, read what 'chop' and 'join' do
by typing 'perldoc -f chop' or 'perldoc -f join'
#!/usr/local/bin/perl5 -w
use strict;
# for clmp rshoham@cs5.acs.ucalgary.ca
while (<DATA>) {
last if /^__END__/;
my ($word, $number, @array_of_files) = split(" ", $_);
chop ($word);
print "the number is $number for the word $word\n";
print join "~", @array_of_files;
print "\n--\n";
}
__DATA__
<someword>: <number_of_files> <filename1.txt> <filename1.txt>
__END__
------------------------------
Date: Tue, 19 Oct 1999 16:21:08 GMT
From: rwentwor@advent.com
Subject: Re: perl and encrypted cookies
Message-Id: <7ui5p5$hco$1@nnrp1.deja.com>
> That was my first reaction, too, and then I realized there might be a
> legitimate reason to do this. For example, he might want to create an
> unforgeable cryptographic token.
Perhaps you are right. Maybe I did overreact. But, considering how
much cookies have been abused, it was a "reasonable" overreaction.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 19 Oct 1999 16:44:56 GMT
From: James Tolley <jtolley@bellatlantic.net>
Subject: Re: Pseudo Hashes
Message-Id: <380C9F9F.A39B169C@bellatlantic.net>
Scott Pritchett wrote:
> Can anyone show me an example of a pseudo hash, I heard about them on the
> Topaz talk on Perl.com but seem unable to get them to work. It seems that an
> element of the array should be accessable by accessing it thru the reference
> to the hash of field name/indices, but how?
>
> My test code is :-
>
> $hx={'beer' => 1, 'snack' => 2, 'logs' => 3, 'last' => 4};
> @ar=(\%hx, qw( crisps nuts balls beer crap ));
> print $ar something or other;
>
You're creaing $hx, then trying to use %hx...
also, you need a recent version of perl (>5.005?) to use this.
There is ample good coverage of pseudo hashes in Object Oriented Perl -
a good read! - or perldoc has info on this, if your version
supports this datatype.
hth
James
>
> Scott
------------------------------
Date: Tue, 19 Oct 1999 17:31:47 +0200
From: Alex Rhomberg <rhomberg@ife.ee.ethz.ch>
Subject: Re: shifting a hash
Message-Id: <380C8EE3.4C00584@ife.ee.ethz.ch>
Ala Qumsieh wrote:
>
> But, my benchmarks (on 5.005_03) proved that indeed a
>
> sort { $b cmp $a} @a
>
> is faster than
>
> reverse sort @a;
This definition of proof is a bit strange.
> The benchmark is attached below. I am sure I am doing something wrong
> with it. Please correct me if you figure it out.
To benchmark sort routines, use large(r) arrays:
size of array: 100000
Benchmark: timing 5 iterations of by_flipping_ab, by_reverse,
reverse_only, sort_only...
by_flipping_ab: 21 secs (20.99 usr 0.04 sys = 21.03 cpu)
by_reverse: 9 secs ( 8.93 usr 0.01 sys = 8.94 cpu)
reverse_only: 2 secs ( 1.30 usr 0.00 sys = 1.30 cpu)
sort_only: 9 secs ( 8.95 usr 0.00 sys = 8.95 cpu)
- Alex
code:
#!/usr/bin/perl -w
#use 5.005;
use Benchmark;
use strict;
use vars qw/@array_to_sort/;
@array_to_sort = map {rand()} (1..100_000);
print "size of array: @{[scalar @array_to_sort]}\n";
my @sorted;
timethese(5, {
by_flipping_ab => 'my @sort1 = sort {$b cmp $a} @array_to_sort',
by_reverse => 'my @sort2 = reverse sort @array_to_sort',
sort_only => 'my @sort3 = sort @array_to_sort',
reverse_only => 'my @sort4 = reverse @array_to_sort',
});
------------------------------
Date: Tue, 19 Oct 1999 16:49:27 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: sorting arrays
Message-Id: <ri1P3.18344$E_1.1030600@typ11.nn.bcandid.com>
In article <slrn80oj39.1vv.mgjv@wobbie.heliotrope.home>,
Martien Verbruggen <mgjv@comdyn.com.au> wrote:
>On Mon, 18 Oct 1999 18:59:36 GMT,
> secnarf@my-deja.com <secnarf@my-deja.com> wrote:
>> I have the contents of a table in an array. I only want to sort the by
>> the contents of the first line of the table row, which looks like -
>
>This doesn't really parse very well. Arrays and tables have nothing in
>common. But I'll just assume that you know what you're talking about,
>even in we don't.
"nothing in common"? HTML tables are two-dimensional arrays. He
probably needs to know how to read the HTML table into Perl arrays.
This is a non-trivial task. Perhaps HTML::Parser would be a place to start.
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Tue Oct 19 1999
21 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Tue, 19 Oct 1999 16:41:38 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: THANKS FOR ALL THE HELP
Message-Id: <s0p7q2hcr0166@corp.supernews.com>
Wyzelli (wyzelli@yahoo.com) wrote:
: Craig Berry <cberry@cinenet.net> wrote in message
: news:s0l5n6snr0186@corp.supernews.com...
: > kstephan (kstephan@my-deja.com) wrote:
: > : Reading through the threads, I noticed the line
: > : $thisyear = $year + 1900;
: > : What happens on 1 January 2000???
: >
: > I don't know!!! My gosh, what *does* happen when you add 100 to 1900???
: > Or when you rtfm, for that matter???
:
: Just musing...
:
: localtime et al returns the number of years since the epoch, to which we
: add 1900 to ensure y2k accuracy.
Not true. On Unix-ish systems, the epoch is midnight Jan 1 1970 UTC.
localtime returns years since 1900. Big difference.
: Are there many occasions are there where the number of years since the
: epoch is actually used? Particularly outside the current century?
Taking 'epoch' here to mean "the localtime year offset" -- yes. This
pattern has been in constant use since the early years of Unix, back in
the late 70s. Various applications have from that time forward dealt with
dates beyond 1999.
: Would it be terribly difficult for localtime to return the number of years
: since the epoch + 1900?
No, and if I had a time machine I'd take a gun back to 1975 and force
Kernighan et al to do it that way. :) It was, in retrospect, an
astonishingly bad decision to return year-1900. However, so much existing
practice has built up around the C (and C-derived Perl) behavior of
localtime that any attempt to fix it now would cause far more harm than
good.
: Assuming localtime returned 'years since epoch plus 1900' would not those
: cases of 'years since epoch' then be adequately served by 'localtime - 1900'
Yes, of course (assuming you mean 'the localtime year value' where you
write 'localtime' above). Or 'year%100' to reliably get just the
non-century portion of the year -- which also works with the current
behavior, of course.
--
| Craig Berry - cberry@cinenet.net
--*-- http://www.cinenet.net/users/cberry/home.html
| "They do not preach that their God will rouse them
a little before the nuts work loose." - Kipling
------------------------------
Date: Tue, 19 Oct 1999 16:59:15 GMT
From: Joe Seigh <jseigh@bbnplanet.com>
Subject: Re: Unix command ´tree´ in Perl?
Message-Id: <380CA2E0.6B8760EA@bbnplanet.com>
From the "No thanks, we already have one." department.
Yes, it just so happens...I suppose I could post it
later after the assignment is due.
Joe Seigh
------------------------------
Date: Tue, 19 Oct 1999 16:03:37 GMT
From: gqc2017@my-deja.com
Subject: Using SQL stored procedure in Perl
Message-Id: <7ui4of$ggf$1@nnrp1.deja.com>
Hi, I have SQL stored procedure called "getinfo" with a SQL statement
"select id, name from customer". Now how do I write the perl script to
use this stored procedure and display the result to the browser by using
DBConnect(), DBDoSQL() and other functions?
Thank you!!!!!
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 19 Oct 1999 16:14:35 GMT
From: bmccoy@foiservices.com (Brett W. McCoy)
Subject: Re: Using SQL stored procedure in Perl
Message-Id: <slrn80p6fp.cp1.bmccoy@moebius.foiservices.com>
Also Sprach gqc2017@my-deja.com <gqc2017@my-deja.com>:
>Hi, I have SQL stored procedure called "getinfo" with a SQL statement
>"select id, name from customer". Now how do I write the perl script to
>use this stored procedure and display the result to the browser by using
>DBConnect(), DBDoSQL() and other functions?
The procedure isn't directly accessed via Perl, but via an SQL query
passed back to the server with the appropriate function call.
--
Brett W. McCoy bmccoy@foiservices.com
Computer Operations Manager (Alpha Geek) http://www.foiservices.com
FOI Services, Inc./DIOGENES 301-975-0110
---------------------------------------------------------------------------
------------------------------
Date: Tue, 19 Oct 1999 16:55:21 GMT
From: michel.dalle@usa.net (Michel Dalle)
Subject: Re: Using SQL stored procedure in Perl
Message-Id: <7ui821$a8g$1@news.mch.sbs.de>
In article <7ui4of$ggf$1@nnrp1.deja.com>, gqc2017@my-deja.com wrote:
>Hi, I have SQL stored procedure called "getinfo" with a SQL statement
>"select id, name from customer". Now how do I write the perl script to
>use this stored procedure and display the result to the browser by using
>DBConnect(), DBDoSQL() and other functions?
Presumably by having a look at the DBI FAQ (located on your harddisk).
Some interesting entries for v.0.37 are :
5.3 How can I invoke stored procedures with DBI?
and
5.4 How can I get return values from stored procedures with DBI?
And <http://www.symbolstone.org/technology/perl/DBI/index.html>
is also a nice place to visit, for modules, FAQs, tutorials etc.
You might also have a look at the DBIx modules (like DBIx::CGI and
DBIx::HTMLView) on CPAN, but I don't know their quality or contents.
Have fun,
Michel.
------------------------------
Date: Tue, 19 Oct 1999 15:46:21 GMT
From: gqc2017@my-deja.com
Subject: Using SQL stored procedure
Message-Id: <7ui3o9$fm8$1@nnrp1.deja.com>
Hi, I have SQL stored procedure called "getinfo" with a SQL statement
"select id, name from customer". Now how do I write the perl script to
use this stored procedure and display the result to the browser by using
DBConnect(), DBDoSQL() and other functions?
Thank you.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 19 Oct 1999 16:08:21 GMT
From: moody+@pie.ius.cs.cmu.edu (James Moody)
Subject: Why does this compile?
Message-Id: <7ui51l$i4c$1@goldenapple.srv.cs.cmu.edu>
A friend asked for help debugging a script he modified. Basically, he added a
couple of routines to someone else's script.
I tracked down the problem to a missing semicolon. The resulting statement
compiled and ran, but I don't know why or what it means syntactically.
Here's a really stripped down version wich illustrates the problem:
sub jumbo {
print "$foo \n";
1;
}
$foo = "Hello!"; #<-- Note this semicolon!
&jumbo;
In this example $foo is created on assignment. Obviously, if you ran this,
the result would be the string 'hello!' printed out on a line by itself.
Now, if the indicated semicolon was missing, the main part of the script would
be:
$foo = "Hello!" &jumbo;
This compiles! The execution result is a blank line.
My question is why does it compile?!?! I this in fact correct syntax?
What is going on on the right side of that statement? How can a scalar and a
return value be assigned to a variable without an error message being triggered?
I mean, this does not compile:
$foo = "Hello!" 1;
so why should
$foo = "Hello!" <something that returns '1'>;
Just curious.
-------------------+---------------------------------+-----------------
James E. Moody Jr. | Center for Orthopaedic Research |
Project Engineer | Suite 309, 5200 Centre Avenue | 412.623.2943
moody@cor.ssh.edu | Pittsburgh, PA 15232 | FAX 412.623.1108
-------------------+---------------------------------+-----------------
------------------------------
Date: 19 Oct 1999 16:28:35 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Why does this compile?
Message-Id: <7ui67j$bl9$1@pegasus.csx.cam.ac.uk>
James Moody <James_Moody@cmu.edu> wrote:
>
>Now, if the indicated semicolon was missing, the main part of the script would
>be:
>
> $foo = "Hello!" &jumbo;
>
>This compiles! The execution result is a blank line.
>
>My question is why does it compile?!?! I this in fact correct syntax?
Always use -w, particularly when you don't understand what's happening:
$ perl -we '$foo = "Hello!" &jumbo;'
Unquoted string "jumbo" may clash with future reserved word at -e line 1.
Operator or semicolon missing before &jumbo at -e line 1.
Ambiguous use of & resolved as operator & at -e line 1.
Name "main::foo" used only once: possible typo at -e line 1.
$
That should offer some clues.
Mike Guy
------------------------------
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 1118
**************************************