[10324] in Perl-Users-Digest
Perl-Users Digest, Issue: 3917 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Oct 7 13:07:12 1998
Date: Wed, 7 Oct 98 10:00:18 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 7 Oct 1998 Volume: 8 Number: 3917
Today's topics:
Re: *quick q:* how to escape a query string? <mblase@ncsa.uiuc.edu>
Re: Are there any "perl.newbie" group or forum? <mp@mkt2mkt.com>
Re: Are there any "perl.newbie" group or forum? <merlyn@stonehenge.com>
Re: Bug in open(FH,"| script") ? (Ilya Zakharevich)
Re: Can't send mail via telnet programmatically <nick@malloc.org>
Re: Can't send mail via telnet programmatically <aperrin@mcmahon.qal.berkeley.edu>
Capturing command output in Perl <wkchiu@yahoo.com>
Re: Capturing command output in Perl <aperrin@mcmahon.qal.berkeley.edu>
Re: Capturing command output in Perl (Pentti Vanska)
Expecting <ayoung@sigg.com>
Extracting muliple values from a hash elund@compuserve.com
Re: Extracting n-grams and words that contain them <garethr@cre.canon.co.uk>
How do I combine scripts <brettr@centuryinter.net>
How do I replicate tail/head? baillie@my-dejanews.com
Re: Keeping a running list of the top n values retrieve (Abigail)
Re: mSQL2 Perl5 Insert Status Checking (brian d foy)
Re: NEEDED: A good perl programer to... (brian d foy)
Re: perl html tag parser (Bart Lateur)
Perl Robots jrrl@lycos.com
Re: RFC: "Build'n'Play" installation tool <ctbates@tva.gov>
Re: scope of my using () <due@whitecrow.net>
Re: send geroge reese (was Re: Call for Participation: <zenin@bawdycaste.org>
Text Submission in Data Capture boxes <pplnet1@connectnet.com>
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 07 Oct 1998 11:01:28 -0500
From: Marty Blase <mblase@ncsa.uiuc.edu>
Subject: Re: *quick q:* how to escape a query string?
Message-Id: <361B9058.3DC5DE44@ncsa.uiuc.edu>
"Doran L. Barton" wrote:
>
> *sighs* RTFM, Marty.
I had to find it. :-P I based the above on another newspost I saw first.
Please don't ask why I didn't just type "perldoc" like any sensible user
would. :-)
I'm puzzled, though. It looks like JavaScript will parse a colon (:) into
%3A when the escape() function is called, but uri_escape() won't do the same
thing in Perl. It does parse ? and % correctly, though. The errant colon
isn't breaking my CGI scripts (yet), but I'm still wondering why there's a
difference.
- Marty
------------------------------
Date: Wed, 07 Oct 1998 09:15:53 -0800
From: madame philosophe <mp@mkt2mkt.com>
Subject: Re: Are there any "perl.newbie" group or forum?
Message-Id: <361BA1C7.13BB0701@mkt2mkt.com>
Well it seems that
1. I shouldn't start a newsgroup
2. You guys aren't as mean as once thought.
3. Though snide, can be reasonable.
4. Have given me a better understanding what on earth the problem is.
What I don't understand is this:
If someone is posting a "dumb" question (If there is such a thing),
why not just ignore it? Treat it like spam?
Instead of the subject line: How to Find The Perl FAQ
Say something more for newbies, like: Need Help With Perl? Here's What To
Do...
or even better: Newbies: How To Use This Newsgroup
As far as the "user inyourface" it could diminish some of the more earnest
learners from having to humiliate themselves.
Comments?
mp
------------------------------
Date: Wed, 07 Oct 1998 16:20:12 GMT
From: Randal Schwartz <merlyn@stonehenge.com>
Subject: Re: Are there any "perl.newbie" group or forum?
Message-Id: <8cu31gwdhh.fsf@gadget.cscaper.com>
>>>>> "Shambo" == Shambo Pfaff <shambop@bacon-and-spam.timeoutny.com> writes:
Shambo> May the Schwartz be with you.
"looks like your schwartz is bigger than mine". :)
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: 7 Oct 1998 16:52:44 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Bug in open(FH,"| script") ?
Message-Id: <6vg68s$i47$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Mattias Petersson EHS/SKA 62067
<ehsmatt@ehpt.com>],
who wrote in article <361B5FA1.1FF82708@ehpt.com>:
> I think I have found a bug in the perl funciton open(FH,"| script").
> My perl prg looks like this, where the script prgX is listening
> on its STDIN.
>
> #!/usr/bin/perl
>
> open( FH1,"| prgX") or die("prgX not found\n");
> select FH1; $|=1;
> (print FH1 "OK\n") or die("filehandle not ready\n");
>
>
> The fact is that if the script prgX doesn't exist, perl anyway
> continues the execution.
> When it comes to the last line, it tries to print to a nonexisting
> filehandle resulting in that the perl prg dies before the dying message.
>
> This must be a bug in Perl, right?
No, it is a bug in Unix - you have no way to start a child on Unix,
you can only transmogrify into a child. On an OS (or half of that ;-)
with a reasonable process-start API you get
F:\home\.cpan.tmp\Tk800.011>perl
#!/usr/bin/perl
open( FH1,"| prgX") or die("prgX not found\n");
select FH1; $|=1;
(print FH1 "OK\n") or die("filehandle not ready\n");
^Z
prgX not found
Ilya
------------------------------
Date: Wed, 07 Oct 1998 19:51:34 +0100
From: Nick Moraitakis <nick@malloc.org>
Subject: Re: Can't send mail via telnet programmatically
Message-Id: <361BB836.4F10518B@malloc.org>
John W. Fierke wrote:
> I'm putting together some error-checking Unix scripts on a DEC-Alpha
> machine for our EDI group. Now that we have moved to MS Exchange/
> Outlook, they aren't having any luck sending mail from the Unix box.
>
> I'd like to use 'telnet [mailserver] 25', along with the proper mail
> syntax, to notify the EDI team with email messages and/or paging them via
>
> email....but it looks like I've got a problem when it comes to trying to
> send the mail commands once I've initiated the telnet!!
>
> Anybody know how to get this done? I'm writing the script in perl and
> it's fairly straight-forward :
>
> $sender="Fred.Flinstone@stone.com";
> $recipient="George.Jetson@space.com";
> open(MAIL, "| telnet dev.mail.com 25")
> || die "\nERROR - Unable to open Mail process, stopped";
> # sleep 60; # had been sleeping long enough for the server to
> # # respond
> print MAIL "mail from: $sender\n";
> print MAIL "rcpt to: $sender\n";
> print MAIL "data\n";
> print MAIL "from: $sender\n";
> print MAIL "to: $recipient\n";
> print MAIL "subject: $subject\n";
> print MAIL "$message\n";
> print MAIL ".\n";
> close(MAIL);
>
> also, all that exists is the perl binary which is 5.004_01. How much
> trouble would it be to replace that with a FULLY EQUIPPED version of perl
> (compiled with all its features)? Currently it's size is 942,080...how
> much space would I need to have? I'm just thinking that I won't be able
> to copy the Net::SMTP module and its constituants onto the box and 'use'
> them, without recompiling. OK...I just DON'T KNOW! This isn't really my
> machine to 'experiment' with.
I think this will not work because telnet tries to read input from your
terminal, so a pipe to it will not help. There is a module on CPAN, though
that lets you manipulate telnet sessions. Also, why don't you try using
sendmail instead of telnetting to the mailserver directly?
------------------------------
Date: Wed, 07 Oct 1998 09:28:34 -0700
From: Andrew Perrin <aperrin@mcmahon.qal.berkeley.edu>
To: "John W. Fierke" <John.Fierke@Avnet.com>
Subject: Re: Can't send mail via telnet programmatically
Message-Id: <361B96B2.95734EF6@mcmahon.qal.berkeley.edu>
[posted and sent via email]
this seems like a very complicated, odd way to solve the problem. I would
suggest either:
1. Pipe MAIL to /usr/ucb/sendmail or wherever your sendmail is; or
2. Use the Mail::Internet module, available from CPAN.
Both of these should also allow you to get some feedback back from the mail
process, which may provide a clue as to why your system stopped working.
Good luck,
Andy
John W. Fierke wrote:
> I'm putting together some error-checking Unix scripts on a DEC-Alpha
> machine for our EDI group. Now that we have moved to MS Exchange/
> Outlook, they aren't having any luck sending mail from the Unix box.
>
> I'd like to use 'telnet [mailserver] 25', along with the proper mail
> syntax, to notify the EDI team with email messages and/or paging them via
>
> email....but it looks like I've got a problem when it comes to trying to
> send the mail commands once I've initiated the telnet!!
>
> Anybody know how to get this done? I'm writing the script in perl and
> it's fairly straight-forward :
>
> $sender="Fred.Flinstone@stone.com";
> $recipient="George.Jetson@space.com";
> open(MAIL, "| telnet dev.mail.com 25")
> || die "\nERROR - Unable to open Mail process, stopped";
> # sleep 60; # had been sleeping long enough for the server to
> # # respond
> print MAIL "mail from: $sender\n";
> print MAIL "rcpt to: $sender\n";
> print MAIL "data\n";
> print MAIL "from: $sender\n";
> print MAIL "to: $recipient\n";
> print MAIL "subject: $subject\n";
> print MAIL "$message\n";
> print MAIL ".\n";
> close(MAIL);
>
> also, all that exists is the perl binary which is 5.004_01. How much
> trouble would it be to replace that with a FULLY EQUIPPED version of perl
> (compiled with all its features)? Currently it's size is 942,080...how
> much space would I need to have? I'm just thinking that I won't be able
> to copy the Net::SMTP module and its constituants onto the box and 'use'
> them, without recompiling. OK...I just DON'T KNOW! This isn't really my
> machine to 'experiment' with.
>
> thx,
> John Fierke
>
> Anyone Without a Sense of Humor
> is at the Mercy of the Rest of Us!
> ================================================================
> | John Fierke 11333 Pagemill Road |
> | Programmer Analyst Dallas, TX 75243 |
> | Open Systems Development (V)214.553.4086 |
> | (P)214.581.1564 |
> | John.Fierke@Avnet.com (F)214.553.4004 |
> ================================================================
--
-------------------------------------------------------------
Andrew J. Perrin - NT/Unix/Access Consulting - (650)938-4740
aperrin@mcmahon.qal.berkeley.edu (Remove the Junk Mail King)
http://www.geocities.com/SiliconValley/Grid/7544/
-------------------------------------------------------------
------------------------------
Date: Thu, 8 Oct 1998 00:00:26 +0800
From: "wkchiu" <wkchiu@yahoo.com>
Subject: Capturing command output in Perl
Message-Id: <6vg2u7$uu1$1@imsp009a.netvigator.com>
I am writing a perl script in NT which runs the PING.EXE command to check a
node (using system() or win32::create() ??) and examine the reply of
PING.EXE to see whether the node is alive or dead. My question is how can I
capture the output of PING.EXE in perl script to carry out the processing ?
wkchiu.
------------------------------
Date: Wed, 07 Oct 1998 09:32:03 -0700
From: Andrew Perrin <aperrin@mcmahon.qal.berkeley.edu>
To: wkchiu <wkchiu@yahoo.com>
Subject: Re: Capturing command output in Perl
Message-Id: <361B9783.A6E562CD@mcmahon.qal.berkeley.edu>
[posted and sent via email]
Use backticks instead.
$response = `ping $host`;
will store the response of ping in the variable $response.
wkchiu wrote:
> I am writing a perl script in NT which runs the PING.EXE command to check a
> node (using system() or win32::create() ??) and examine the reply of
> PING.EXE to see whether the node is alive or dead. My question is how can I
> capture the output of PING.EXE in perl script to carry out the processing ?
>
> wkchiu.
--
-------------------------------------------------------------
Andrew J. Perrin - NT/Unix/Access Consulting - (650)938-4740
aperrin@mcmahon.qal.berkeley.edu (Remove the Junk Mail King)
http://www.geocities.com/SiliconValley/Grid/7544/
-------------------------------------------------------------
------------------------------
Date: 7 Oct 1998 16:31:26 GMT
From: vanska@adpser1.gsf.fi (Pentti Vanska)
Subject: Re: Capturing command output in Perl
Message-Id: <6vg50u$ukp$1@news.gsf.fi>
wkchiu (wkchiu@yahoo.com) wrote:
: I am writing a perl script in NT which runs the PING.EXE command to check a
: node (using system() or win32::create() ??) and examine the reply of
: PING.EXE to see whether the node is alive or dead. My question is how can I
: capture the output of PING.EXE in perl script to carry out the processing ?
: wkchiu.
Just run ping.exe in pipe.
Something like this ...
open(PIPE,"ping.exe host|") or die("\n Can't open pipe !\n");
while(<PIPE>) {
print("$_"); # This is output do what ever you want
}
close(PIPE);
t.pena
------------------------------
Date: Wed, 07 Oct 1998 11:23:02 -0500
From: Aaron Young <ayoung@sigg.com>
Subject: Expecting
Message-Id: <361B9565.8C92DCE2@sigg.com>
Hi all
I am trying to use the Expect module and could use a little
clarification
I have the Pod documentation in front of me but I am having a little bit
of trouble understanding how one of the methods is supposed to work
I am calling the $obj->clear_accum() and for some reason I'm not
understanding the behavior of the object after that call
My understanding is that it should clear everything out....but it
doesn't seem to.
My code (below) takes an pgp5 encrypted file hello.pl.asc and decrypts
it
but when I do my &print_match sub I don't get what I expect....what I
get is the first match printed again when it should be printing out the
second.....in other words, I get the Enter pass phrase: bit everytime I
print out what was matched.
the odd thing is that everything seems to work, if I can't get the
match, then I can't change the behavior based on the output.......
TIA
Aaron
I have something like this
#Set up objects
$process = Expect->spawn("/usr/local/security/bin/pgpv",
"hello.pl.asc");
$process->expect(1, "Enter pass phrase:");
&print_match;
$process->clear_accum();
$process->send_slow(1, "my key phrase\n");
$process->clear_accum();
$process->expect(1, ["type binary.","Overwrite? [y/N]"]);
&print_match;
$process->send_slow(1, "y\n");
&print_match;
exit;
#Print out Expect match info
sub print_match {
print "\n----------------------------------\n";
print "Object->exp_match(): ";
print $process->exp_match();
print "\n";
print "Object->exp_match_number(): ";
print $process->exp_match_number();
print "\n----------------------------------\n";
}
------------------------------
Date: Wed, 07 Oct 1998 16:39:44 GMT
From: elund@compuserve.com
Subject: Extracting muliple values from a hash
Message-Id: <6vg5gg$n7a$1@nnrp1.dejanews.com>
Is there a simple way to extract multiple named values from a hash? For
example (and this doesn't work):
@array = @hash{key0,key3}; # This could be interpolated in a string
instead of
@array = ($hash{key0}, $hash{key3}); # Not interpolatable
or
@array = map {$hash{$_}} (key0, key3); # Interpolation be damned
It seems like Perl should allow this as a corollary to array slices (and this
works):
@array = @otherArray[0,3]; # Friendly to string interpolation
I'm just lazy and like to do things in one line if it's an alternative. My
question is probably more of a why: Is there a reason this isn't in Perl, and
if not, who would I beg and plead to get this added?
-- Eric Lund
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Wed, 7 Oct 1998 16:33:48 GMT
From: Gareth Rees <garethr@cre.canon.co.uk>
Subject: Re: Extracting n-grams and words that contain them
Message-Id: <si90ismivn.fsf@cre.canon.co.uk>
William P Shaw <wpsst2+@pitt.edu> wrote:
> The problem I would like to solve is as follows:
>
> INPUT : A string of words, separated by spaces.
>
> OUTPUT: A hash of <n-gram> => frequency in string, AND a list of the
> words that contained each n-gram.
>
> The string is contained in $result. I am extracting the n-grams of
> size $n as follows:
>
> for ($i = 0; $i < length $result; $i++) {
> $gram = substr $result, $i, $n;
> $n_grams{$gram}++;
> }
>
> is there a more efficient, "Perl-like" way of extracting the n-grams?
That looks like a good method to me. I would have used length $result -
$n + 1 for the upper bound on the loop, though.
> Suppose I extract the 5-gram "he qu" from "The quick". How can I
> retain the information that this 5-gram came from the words "The
> quick"?
>
> I'm relatively new at Perl; [...] how could I retain the word
> information?
You don't explain clearly what is causing you the trouble. It sounds
like you are stuck on one or both of these problems:
1. You don't know how to work out which words contain the n-gram.
2. You don't know how to store the information that the n-gram came
from a particular set of words.
I'll give you my thoughts on both problems, anyway.
problem 1
------------------------------------------------------------------------
You can use Perl's regular expression engine to solve this one. Here's
a program to solve the problem:
#!perl -w
sub ngrams {
my $s = shift; # String to generate n-grams from
my $n = shift; # Length of n-grams
my $i = 0; # Characters before n-gram
my $j = (length $s) - $n; # Characters after n-gram
for (; $j >= 0; ++$i, --$j) {
my $gram = substr $s, $i, $n;
$s =~ /^.{0,$i}\b(.{$n,}?)\b.{0,$j}$/;
print "'$gram' found in '$1'\n";
}
}
ngrams("the quick brown fox", 4);
and here's its output:
'the ' found in 'the '
'he q' found in 'the quick'
'e qu' found in 'the quick'
' qui' found in ' quick'
'quic' found in 'quick'
'uick' found in 'quick'
'ick ' found in 'quick '
'ck b' found in 'quick brown'
'k br' found in 'quick brown'
' bro' found in ' brown'
'brow' found in 'brown'
'rown' found in 'brown'
'own ' found in 'brown '
'wn f' found in 'brown fox'
'n fo' found in 'brown fox'
' fox' found in ' fox'
(You didn't define what you mean by "the words an n-gram is found in"
for the case when the n-gram starts or ends with a space or other
non-word character, so I've included the non-word character(s) in the
words.)
How does this work? The magic is in the regular expression
/^.{0,$i}\b(.{$n,}?)\b.{0,$j}$/
Note that I have arranged that $i + $n + $j is the length of the string.
Perl's regexp engine matches the first \b against the last word boundary
before the n-gram (which starts after $i characters) since .{0,$i} is
greedy. It then matches as few characters as necessary - since .{$n,}?
is non-greedy - to bring it up to another word boundary such that the
remainder is $j or fewer characters. This forces the .{$n,}? to match a
string including the n-gram (which has $j characters after it).
I hope that's a clear explanation (if in doubt, try some examples and
work out how Perl's regexp engine will proceed).
problem 2
------------------------------------------------------------------------
This is much easier. You need a data structure which maps each n-gram
to a structure containing (1) the count of the times the n-gram was
found; and (2) a list of the contexts in which the n-gram was found.
So how about a hash of hashes structure where
$result{$ngram}{COUNT} is the count of occurrences; and
$result{$ngram}{CONTENTS} is a reference to a list of occurrences
I'm sure you can fill in the rest.
--
Gareth Rees
------------------------------
Date: Wed, 7 Oct 1998 11:41:16 -0500
From: "brettr" <brettr@centuryinter.net>
Subject: How do I combine scripts
Message-Id: <6vg5qr$5f6$1@newsread1-mx.centuryinter.net>
How would I combine 2 scripts into one? How would the form know which script
it was calling in the file? I think some use of hidden variables. I'm just
not exactly sure of where to start.
brettr
------------------------------
Date: Wed, 07 Oct 1998 15:51:08 GMT
From: baillie@my-dejanews.com
Subject: How do I replicate tail/head?
Message-Id: <6vg2lb$eqv$1@nnrp1.dejanews.com>
I was wondering if anyone could tell me how to create a kind of tail and head
function to use in a script (as in the unix tail and head commands).
Basically I've got a long output file that (among other things) lists the
amount of a backup that's completed (in KB) and I want to be able to just
grab the last reference to that. Actually, this is my first Perl program
and, if anyone's got the time and patience to tell me what's screwed up,
here's my script:
I really can't get this to work much at all, but any input would be
appreciated. Basically this just takes the output of a C program and gives a
visual progress meter.
i.e.
amount to store = whatever MB
amount stored = whatever MB
==============================================>
Opcard is 52% complete.
#!/usr/local/bin/perl -w
if($ARGV[0] ne "") {
$host=$ARGV[0];
system "rsh $host alex-sched -LP 0 > /tmp/opck.cache";
} else {
$host='localhost';
system "alex-sched -LP 0 > /tmp/opck.cache";
}
open(FILE, "</tmp/opck.cache") or die "Can't access file: $!";
$i=0; while(<FILE>) { if($line =~ /^"Total Bytes to Backup"/) {
$to_store=$line; # Here's where I need head(maybe), or will this do?
$to_store =~ /[0-9]*/; chomp($to_store); $to_store/=1024; last; }
while(defined($line =~ /^"Current KBytes Stored"/)) { chomp($line); #
Here's where I need tail. $store_array[$i]=$line; $store_array[$i] =~
/[0-9]*/; $i++; } }
close(FILE) or die "Couldn't close cache file: $!";
$amount_stored=$store_array[$#store_array];
$screen_width=`tput cols`;
$equal_signs=($amount_stored/$to_store)*$screen_width;
$total=($amount_stored/$to_store)*100;
$cntr=2;
$avcntr=0;
undef(@store_array);
print "\n\t\t$host amount to store\t=\t$to_store/1024 MB\n";
print "\t\tamount stored\t\t=\t$amount_stored/1024 MB\n\n";
while($cntr<=$equal_signs) {
print "=";
$cntr++;
}
print ">\n";
print "Opcard store is $total% complete";
unlink(FILE);
If you've come this far, thanks very much =).
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: 7 Oct 1998 16:11:20 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Keeping a running list of the top n values retrieved
Message-Id: <6vg3r8$fd$1@client3.news.psi.net>
Sam Holden (sholden@pgrad.cs.usyd.edu.au) wrote on MDCCCLXIII September
MCMXCIII in <URL:news:slrn71lel6.mjt.sholden@pgrad.cs.usyd.edu.au>:
++ On 6 Oct 1998 16:42:20 GMT, Abigail <abigail@fnx.com> wrote:
++ >
++ >If we have n values, and want to get the top m, sorting takes O (n log n).
++
++ And looses on space in a big way for n >> m.
How's that? All methods use O (n) memory.
++
++ >Using a sorted array of size m, and splice each new element in, takes O (n m).
++
++ Which is basically what the above does the sort is O(n log (m+1)) the
++ assignment is O(n m) so we have O(n m) all up.
You've lost me here. What do you mean?
++ >Using a heap gives a running time of O (n log m).
++ >
++ >If m is small compared to n, the heap clearly wins.
++
++ The smaller m gets the closer O(n m) gets to being as good as O(n log m)...
++ Since a smaller m has a bigger impact on (n m) than (n log m)
++
++ If n is 1000000 and m is 16 then we have
++ n*m = 16000000
++ n*log m = 4000000
++ So it's only 4 times slower. With m = 1024 n*m is over 100 times slower.
Rubbish. You can't ignore the constant.
++ Though log m is better than m especially since a heap has little overhead.
++
++
++ I agree the heap is probably the best solution, though displaying the
++ top m elements in decreasing order takes O(m) with the sorted array and
++ O(m log m) with the heap (though once sorted it can stay sorted until the
++ next insertion). Unless someone knows a way of getting at the elements in a h
++ in sored order in less than O(m log m)?
You can't do that. If you can, you can sort in time less than O (n log n),
as building a heap can be done in linear time.
++ So a skip list would actually give O(n log m) insertions and O(m) displays, b
++ would be a lot more work to implement than a heap.
Since m <= n, O (m log m) = O (n log m). The insertions in the heap will
dominate reporting the result anyway.
Abigail
--
sub f{sprintf'%c%s',$_[0],$_[1]}print f(74,f(117,f(115,f(116,f(32,f(97,
f(110,f(111,f(116,f(104,f(0x65,f(114,f(32,f(80,f(101,f(114,f(0x6c,f(32,
f(0x48,f(97,f(99,f(107,f(101,f(114,f(10,q ff)))))))))))))))))))))))))
------------------------------
Date: Wed, 07 Oct 1998 12:46:08 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: mSQL2 Perl5 Insert Status Checking
Message-Id: <comdog-ya02408000R0710981246080001@news.panix.com>
Keywords: from just another new york perl hacker
In article <361ACDF2.B6505FF2@cybie.com>, Chi Yu <chi@cybie.com> posted:
>Can anyone please give me the proper code for checking the status of an
>INSERT statement?
> $sql_statement = "...some valid SQL statement";
> $sth = $dbh->query($sql_statement);
is this Msql.pm? you can check the special $Msql::errmsg variable. IIRC,
that is also available as $dbh->errmsg. for the DBI module, you would
check $dbh->errstr.
>When checking the status of a SELECT, I use the following code but it
>does not work for the INSERT:
[snip]
>Using SQLMonitor I can see the INSERT statement worked, but the script
>fails (error 500) on any subsequent query to the $sth variable.
what shows up in the server error logs? that's your first, best
source of information on errors :)
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers needs volunteers! <URL:http://www.pm.org/to-do.html>
------------------------------
Date: Wed, 07 Oct 1998 12:41:59 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: NEEDED: A good perl programer to...
Message-Id: <comdog-ya02408000R0710981241590001@news.panix.com>
Keywords: from just another new york perl hacker
In article <6vehf8$99j$1@lark.jmu.edu>, schutzmd@jmu.edu (Mike) posted:
>> >> You forgot to mention a price which you are willing to pay. Therefore
>> >> dont expect any serious offer.
>> >
>> >I'll bet you don't play poker very well. ;)
>
>> Poker's very different... if an agent/client isn't able to start talking
>> money in a matter of seconds the conversation has a pretty short lifespan.
>
>Wow, I didn't realize that our society is so twisted... I've donated
>literally hundreds of hours of perl programming to a couple worthy
>recipients.
the problem is that everyone thinks that they are a worthy recipient.
there's only so much pro bono stuff one can do before becoming homeless,
after all.
"think freedom, not free beer" as rms says.
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers needs volunteers! <URL:http://www.pm.org/to-do.html>
------------------------------
Date: Wed, 07 Oct 1998 17:10:02 GMT
From: bart.mediamind@ping.be (Bart Lateur)
Subject: Re: perl html tag parser
Message-Id: <3623a03d.9855467@news.ping.be>
ekaull@my-dejanews.com wrote:
> if ($listing[$index]=~/href+\s*\=+\"+(.*)\s*\"+/i)
> {
># $html =~ s/(href=")([^"]*)/$1\L$2/gi; # yours
> $listing[$index]=~s/(href+\s*\=+\"+)([^"]*)/$1\L$2/gi; # mine works
As Jonathan Feinberg already wrote: what are those plusses doing there?
Drop'm. It allows you to include more than one of whatever precedes it.
For example: /href="+/ will match href=""""" too. That's not what you
want.
Also: there's no need to do a match test first, and a substitution
later. You may TRY a substitution, and if there's no match, no harm is
done. So: drop the "if" part.
You've limited the amount of how much text you can match between the
quotes, using ([^"]*). Good. That'll only have effect if there are still
more quotes on the same line, but it *is* important.
In short:
$listing[$index] =~ s/(href\s*=")([^"]*)"/$1\L$2/gi;
is all you need.
Bart.
------------------------------
Date: Wed, 07 Oct 1998 16:24:39 GMT
From: jrrl@lycos.com
Subject: Perl Robots
Message-Id: <6vg4k7$kv1$1@nnrp1.dejanews.com>
I am working up a Perl branch of the {C,C++}Robots family. For those of you
unfamiliar with these, they are games in which robots attempt to destroy each
other. As a player, you write programs to run robots. Available to your
program are functions to move, fire, look around, and check your status.
Anyway, I figured before I wasted too much of my time on it, I'd check to see
if there is any interest in such a beast. Ideally, I want to have a web
interface so you can submit your robots via a form and watch animations of
the battle. I'd like to look at different tournament structures and different
arenas as well (let's add obstacles and mazes!).
So... are you interested? If so, please let me know. Thanks.
-John.
----
John R. R. Leavitt | Senior Technology Strategist | Lycos, Inc
412 208 1033 | jrrl@lycos.com | http://steam.letters.com/jrrl/
It's supposed to be hard. If it wasn't hard, everyone would do it.
The hard is what makes it great.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Wed, 07 Oct 1998 10:54:39 -0400
From: Tom Bates <ctbates@tva.gov>
To: Steffen Beyer <sb@engelschall.com>
Subject: Re: RFC: "Build'n'Play" installation tool
Message-Id: <361B80AF.DFD66490@tva.gov>
Steffen Beyer wrote:
> Michael Gerth <mic@oreilly.de> from O'Reilly and myself (Steffen Beyer
> <sb@engelschall.com>) would be very glad if some volunteers could take
> a look at this tool ("peer review") before actual publication and if
> they would share with us a) their opinions about and b) their experiences
> with this tool!
Looks like something we need very much. We'd like to try it, but the INSTALL.en file
on your site is in German. Didn't know if you were aware of that.Regards,
Tom
------------------------------
Date: 7 Oct 1998 16:11:44 GMT
From: "AmD" <due@whitecrow.net>
Subject: Re: scope of my using ()
Message-Id: <6vg3s0$l3n$0@206.165.146.112>
Mark,
Thanks for the reply. What I am trying to discover is whether my
subroutine successfully creates a hash. In my script the hash is returned
as undefined if it was not possible to create the hash. I built in error
checking when my first approach did not work by including an additional
variable signaling success. As a general strategy, should I just always use
an additional return variable to indicate whether or not the subroutine was
successful, or are the other ways to do this?
Do you happen to know why there is the difference in outcomes when one
does, or does not, surround the hash with parentheses? I am still curious
about that. Thanks again.
Allan
Mark-Jason Dominus wrote in message <6vg057$hfv$1@monet.op.net>...
>In article <6vfq31$4i8$0@206.165.167.139>, AmD <Allan@due.net> wrote:
>>If you run the following it will print "Hash is defined"
>
>At present, `defined' is not meaningful for hashes or arrays; only for
>scalars. Using it returns a bizarre result.
------------------------------
Date: 7 Oct 98 16:44:03 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: send geroge reese (was Re: Call for Participation: Python Conference)
Message-Id: <907778800.622378@thrush.omix.com>
Abigail <abigail@fnx.com> wrote:
: Zenin (zenin@bawdycaste.org) wrote on MDCCCLXII September MCMXCIII in
>snip<
: ++ Encapsulation, data abstraction, lower name collisions, etc.
:
: You don't need OO for that. In fact, when using procedures and packages
: I already have 'my' variables and namespaces. Have had those for many,
: many years.
$thing = Some::Really::Deep::Package::Name::Foo::makeMeAThing();
Some::Really::Deep::Package::Name::Foo::doSomethingWithIt($thing);
Some::Really::Deep::Package::Name::Foo::doSomethingElse($thing);
$bar = Some::Really::Deep::Package::Name::Bar::makeMeAThing();
foreach ($thing, $bar) {
Some::Really::Deep::Package::Name::???::someFunction ($_);
}
It's both a simple typing issue, as well as a practical issue.
Should Foo and Bar subclass Name? Maybe, maybe not. If they
gain nothing more then a function blueprint (Java's "interface")
I'd say it's really iffy, and we still wouldn't be talking
inheritance, only typo checking.
: It still amazes me that perl5 introduced both 'my', 'use strict' and
: its silly way of creating objects.
It may be silly, but it's quite a bit more flexible and more
powerful then most others. The fact that your own closure based
object can even be done is a testament to that.
--
-Zenin (zenin@archive.rhps.org) From The Blue Camel we learn:
BSD: A psychoactive drug, popular in the 80s, probably developed at UC
Berkeley or thereabouts. Similar in many ways to the prescription-only
medication called "System V", but infinitely more useful. (Or, at least,
more fun.) The full chemical name is "Berkeley Standard Distribution".
------------------------------
Date: Wed, 07 Oct 1998 16:59:13 GMT
From: Jeffery DeMarco <pplnet1@connectnet.com>
Subject: Text Submission in Data Capture boxes
Message-Id: <361BA2AA.DC30A28F@connectnet.com>
We have just finished an html form for our site visitors
(attached)
http://www.internetnewsnetwork.com/1stmerchantscreditcardprocessingdepot/info/mail-form.html
The site visitor can now fill in the form on their screen
and hit the 'print' button and print BOTH the form AND the
text that they insert into the data capture fields as ONE FORM.
However, when the site visitor hits the 'submit' button, the document
sends a 'string' of data, which is what we do NOT want.
We would like the site visitor to hit 'submit' and we receive
the document, looking exactly like the document fully on the screen,
WITH the text entered BY the site visitor STILL IN the data boxes.
THEN, all we have to do is hit 'print' and BOTH the document
AND the text info IN the data boxes PREVIOUSLY filled in by
the site visitor prints as ONE document.
Could you point me in the right direction ?
Thanks, Jeffery
------------------------------
Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
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.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 V8 Issue 3917
**************************************