[13167] in Perl-Users-Digest
Perl-Users Digest, Issue: 577 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Aug 18 17:07:14 1999
Date: Wed, 18 Aug 1999 14:05:12 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 18 Aug 1999 Volume: 9 Number: 577
Today's topics:
Re: $$var[xxx] vs ${var}[xxx] <aqumsieh@matrox.com>
Re: A prime numbers program. <aqumsieh@matrox.com>
Re: A prime numbers program. jm_the_great@my-deja.com
Re: A prime numbers program. (Larry Rosler)
Re: A prime numbers program. (John Stanley)
Re: A prime numbers program. (Larry Rosler)
arghh! can't figure out s/// ! <pnkflyd51@hotmail.com>
Re: arghh! can't figure out s/// ! <Allan@due.net>
Re: arghh! can't figure out s/// ! <pnkflyd51@hotmail.com>
Re: arghh! can't figure out s/// ! (Alan Curry)
Re: CGI and param <makkulka@cisco.com>
Re: cgi POST in Perl script? <makkulka@cisco.com>
Re: djgpp, Win98, Perl, and serial port <dchristensen@california.com>
Re: HARASSMENT -- Monthly Autoemail (1)
Re: Help Translating Apple IIe file vwcorrado@my-deja.com
Is it possible to send oneway message to perl cgi? yangsu@ustc.edu
Re: Matt's cookielib and Unicode <newsgroups@mail.ru>
Passing undef to a subroutine <clint@drtech.co.uk>
Re: Passing undef to a subroutine (Greg Bacon)
Re: Passing undef to a subroutine <Mark_Reibert-SC2762@email.mot.com>
Re: Pattern Matching <mark@leaf.ee.ufl.edu>
Perl function that searches $PATH for a filename <abonet@rincon.com>
Re: Perl function that searches $PATH for a filename <uri@sysarch.com>
Perl on Linux and MS SQL 7.0 <jriera@retemail.es>
Perl/ HTML form mail attachments <news@news.com>
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 18 Aug 1999 14:26:02 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: $$var[xxx] vs ${var}[xxx]
Message-Id: <x3yr9l1kksn.fsf@tigre.matrox.com>
"Irwin M. Feuerstein" <ebct@hotmail.com> writes:
[I am applying jeopardy style quoting here.
But only because I had to]
There are two simple rules to follow in this case:
1) Key or index lookups are done at the end.
2) The prefix closest to a variable name binds most closely.
Let's use the above two rules to see what happens:
> $$var[xxx]
This becomes:
{$$var}[xxx]
So $var is a ref to an array.
This is equivalent to $var->[xxx];
> ${$var}[xxx]
This is the same thing.
> $${var}[xxx]
Again. The same thing.
> ${${var}}[xxx]
And the same.
> Why aren't they the same thing?
huh?
% perl -wl
use constant 'xxx' => 2;
$var = ['a'..'z'];
for (qw(
$$var[xxx]
${$var}[xxx]
$${var}[xxx]
${${var}}[xxx]
)) {
print "$_ : ", eval;
}
__END__
Name "main::var" used only once: possible typo at - line 2.
$$var[xxx] : c
${$var}[xxx] : c
$${var}[xxx] : c
${${var}}[xxx] : c
They are all the same.
But, you have a different one in your subject line:
${var}[xxx]
This becomes:
$var[xxx]
which is a regular array indexing.
HTH,
Ala
------------------------------
Date: Wed, 18 Aug 1999 14:51:53 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: A prime numbers program.
Message-Id: <x3ypv0kly5z.fsf@tigre.matrox.com>
jm_the_great@my-deja.com writes:
> #!/usr/bin/perl
You should be using '-w' to help you debug your program faster.
'use strict;' will also be a good idea, but your program will fail
miserably if you insert it now.
> # By Justin Mitchell
> # If you have any comments/suggestions e-mail
> # them to me at jm_777_homeboy@yahoo.com
>
> $n = 1;
> $primes[1] = 2;
Why not $primes[0] ?
But push() would be a better choice still.
> $c = 0;
What is $c? You don't use it anywhere else!
> @digits = ($ARGV[1]..$ARGV[2]);
Adding comments to the roles of the above variables might help.
> foreach $number (@digits){
> $pr = 0;
> if (($number / 2)==(int($number / 2))){
> next;
> }
Why do it the brute force way? Use '%':
next unless $number % 2;
> for ($digi = 2; ($digi**2) <= $number; $digi++){
> $digi++ if (($digi / 2)==(int($digi / 2)));
Again, use '%':
$digi++ unless $digi % 2;
But, the above two lines are effectively looping through all odd
numbers between 2 and $number. Then why not simply do:
for ($digi = 3; $digi**2 <= $number; $digi += 2) {
This should be faster.
> if (($number / $digi)==(int($number / $digi))){
unless ($number % digi) {
> $pr = 1;
> last;
> }
> }
Here you are taking the brute force approach of testing if $number
(which is odd) is divisible by any odd number greater than 2 and
smaller than the square root of $number. Which is WRONG.
Your numbers should go all the way up to $number/2:
for ($digi = 3; $digi*2 < $number; $digi += 2) {
Maybe it was a typo and you actually wanted to have one '*' instead of
two. Also note that you only need to check if $digi*2 is strictly less
than $number, since $number is odd.
> if ($pr == 0){
> $n++;
> $primes[$n] = $number;
Why use $n? just use push().
push @primes, $number;
Another comment. You seem to use $pr to indicate NOT prime:
if $pr == 1, then number is NOT prime
else number is prime
which is counter-intuitive. Your variable names should be
meaningful. Reversing the polarity of the above variable would make it
more meaningful.
> print "$number\n" if ($ARGV[3])
> }
> }
> open (OUTFILE, ">$ARGV[0]");
test the result of your open()s.
open OUTFILE, ">$ARGV[0]" or die "Couldn't create $ARGV[0]: $!\n";
> select (OUTFILE);
> print "Found $n primes";
> foreach $prime (@primes){
> print "$prime\n";
> }
> close (OUTFILE);
close OUTFILE or warn "Couldn't close $ARGV[0]: $!\n";
This is a brute force approach. There are several methods already
developed that are much faster than this. Some of these methods date
back to thousand of years ago. I adivse you to look at any book on
numerical algorithms for a better solution to your problem.
Also, check out comp.lang.perl.moderated. A recent thread discussed
prime numbers.
HTH,
Ala
------------------------------
Date: Wed, 18 Aug 1999 19:36:12 GMT
From: jm_the_great@my-deja.com
Subject: Re: A prime numbers program.
Message-Id: <7pf1vb$em8$1@nnrp1.deja.com>
How would I divisibility by the modulo thing?
Can you give me an example?
In article <7pemfr$6cj$1@lublin.zrz.tu-berlin.de>,
anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote:
> <jm_the_great@my-deja.com> wrote in comp.lang.perl.misc:
> > This is a little program that will figure out all the prime
> >numbers from $ARGV[1] to $ARGV[2]. $ARGV[0] is the filename for the
> >output and $ARGV[3] is if you want to see the numbers as they go by
> >(note: just put anything down for $ARGV[3]).
> > I just want to see if anybody can help me make this thing faster
> >(Although, it does run about 20% faster on my Linux box then my
Windows
> >box :-). The code is here (also, if somebody wants to put some
> >comments in it, that would be great):
> >
> >#!/usr/bin/perl
>
> Use -w. Use strict.
>
> ># By Justin Mitchell
> ># If you have any comments/suggestions e-mail
> ># them to me at jm_777_homeboy@yahoo.com
> >
> >$n = 1;
> >$primes[1] = 2;
> >$c = 0;
> >@digits = ($ARGV[1]..$ARGV[2]);
> >foreach $number (@digits){
> > $pr = 0;
> > if (($number / 2)==(int($number / 2))){
>
> Test for divisibility using the % (modulus) operator.
>
> > next;
> > }
> > for ($digi = 2; ($digi**2) <= $number; $digi++){
>
> You have tested for 2 separately. Why test again? Start at 3
> and step through the test divisors in steps of 2.
>
> > $digi++ if (($digi / 2)==(int($digi / 2)));
> > if (($number / $digi)==(int($number / $digi))){
> > $pr = 1;
> > last;
> > }
> > }
> > if ($pr == 0){
> > $n++;
> > $primes[$n] = $number;
> > print "$number\n" if ($ARGV[3])
> > }
> > }
> >open (OUTFILE, ">$ARGV[0]");
> >select (OUTFILE);
> >print "Found $n primes";
> >foreach $prime (@primes){
> > print "$prime\n";
> > }
> >close (OUTFILE);
>
> Since you collect primes anyway, it may pay to reorganize things so
that
> you know all primes < $number when you test for $number. You can then
> use the known primes as test divisors.
>
> Anno
>
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Wed, 18 Aug 1999 13:14:13 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: A prime numbers program.
Message-Id: <MPG.1224b3ed68608014989e6f@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <7pejj6$2sk$1@nnrp1.deja.com> on Wed, 18 Aug 1999 15:30:45
GMT, jm_the_great@my-deja.com <jm_the_great@my-deja.com> says...
> This is a little program that will figure out all the prime
> numbers from $ARGV[1] to $ARGV[2]. $ARGV[0] is the filename for the
> output and $ARGV[3] is if you want to see the numbers as they go by
> (note: just put anything down for $ARGV[3]).
> I just want to see if anybody can help me make this thing faster
> (Although, it does run about 20% faster on my Linux box then my Windows
> box :-). The code is here (also, if somebody wants to put some
> comments in it, that would be great):
<CODE snipped; reproduced below in benchmark, after being "use
strict;"ed and too many output tests removed.>
The variation 'lr' uses '%' to decide divisiblity, push to store values,
and more rational filtering. The third program 'sieve' is a
straightforward implementation of the famous Sieve of Eritosthanes,
which uses a large array to hold the results. A very recent thread in
comp.lang.perl.moderated
<URL:http://x42.deja.com/viewthread.xp?AN=513821702&search=thread>
points out that this space use can be reduced by using bit vectors
instead of arrays, though it might slow it down some. The 'seive1'
variation uses half as much memory.
Benchmark: timing 1 iterations of jm, lr, sieve, sieve1...
jm: 24 wallclock secs (24.56 usr + 0.01 sys = 24.58 CPU)
lr: 7 wallclock secs ( 6.47 usr + 0.00 sys = 6.47 CPU)
sieve: 2 wallclock secs ( 2.17 usr + 0.00 sys = 2.17 CPU)
sieve1: 1 wallclock secs ( 1.20 usr + 0.00 sys = 1.20 CPU)
Iteration warnings removed.
So I guess one can do it faster. :-)
*********** Benchmark program follows (83 lines) ***********
#!/usr/local/bin/perl -w
use strict;
use Benchmark;
my @argv = (0, 2, 100000, 0);
sub jm_the_great {
my $n = 1;
my @primes;
$primes[1] = 2;
my @digits = ($argv[1]..$argv[2]);
foreach my $number (@digits){
my $pr = 0;
if (($number / 2)==(int($number / 2))){
next;
}
for (my $digi = 2; ($digi**2) <= $number; $digi++){
$digi++ if (($digi / 2)==(int($digi / 2)));
if (($number / $digi)==(int($number / $digi))){
$pr = 1;
last;
}
}
if ($pr == 0){
$n++;
$primes[$n] = $number;
}
}
shift @primes, print map "$_\n" => @primes if ($argv[3]);
}
sub lr_the_greater {
use integer;
my @primes;
$primes[0] = 2;
my $number = $argv[1] & 1 ? $argv[1] : $argv[1] + 1;
NUMBER:
for ( ; $number < $argv[2]; $number += 2) {
for (my $digi = 3; $digi * $digi <= $number; $digi += 2) {
next NUMBER unless $number % $digi;
}
push @primes, $number;
}
print map "$_\n" => @primes if $argv[3];
}
sub sieve {
use integer;
my @primes;
$#primes = $argv[2] - 1; # Preallocate for best speed.
for (my $digi = 4; $digi <= @primes; $digi += 2) {
$primes[$digi] = 1;
}
for (my $dig = 3; $dig <= @primes; $dig += 2) {
next if $primes[$dig];
for (my $digi = 2 * $dig; $digi < @primes; $digi += $dig) {
$primes[$digi] = 1;
}
}
print map { $primes[$_] ? "" : "$_\n" } 2 .. $#primes if $argv[3];
}
sub sieve1 {
use integer;
my @primes;
$#primes = ($argv[2] - 3)/2; # Preallocate for best speed.
for (my $dig = 3; $dig <= $argv[2]; $dig += 2) {
next if $primes[$dig/2 - 1];
for (my $digi = 3 * $dig; $digi <= $argv[2]; $digi += 2 * $dig) {
$primes[$digi/2 - 1] = 1;
}
}
print "2\n",
map { $primes[$_] ? () : ($_ + $_ + 3, "\n") } 0 .. $#primes
if $argv[3];
}
timethese(1 << (shift || 0), {
jm => \&jm_the_great,
lr => \&lr_the_greater,
sieve => \&sieve,
sieve1 => \&sieve1,
});
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 18 Aug 1999 20:34:04 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: A prime numbers program.
Message-Id: <7pf5bs$i0t$1@news.NERO.NET>
In article <x3ypv0kly5z.fsf@tigre.matrox.com>,
Ala Qumsieh <aqumsieh@matrox.com> wrote:
>Here you are taking the brute force approach of testing if $number
>(which is odd) is divisible by any odd number greater than 2 and
>smaller than the square root of $number. Which is WRONG.
>Your numbers should go all the way up to $number/2:
No. That is wrong. If $number has a divisor greater than sqrt($number),
then the result will be less than sqrt($number). Remember:
N / A = B means N / B = A
and if A > sqrt(N), B must be less than sqrt(N) or else A*B will be
greater than N.
------------------------------
Date: Wed, 18 Aug 1999 13:54:22 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: A prime numbers program.
Message-Id: <MPG.1224bd56466666b3989e70@nntp.hpl.hp.com>
In article <x3ypv0kly5z.fsf@tigre.matrox.com> on Wed, 18 Aug 1999
14:51:53 -0400, Ala Qumsieh <aqumsieh@matrox.com> says...
> jm_the_great@my-deja.com writes:
...
> for ($digi = 3; $digi**2 <= $number; $digi += 2) {
...
> Here you are taking the brute force approach of testing if $number
> (which is odd) is divisible by any odd number greater than 2 and
> smaller than the square root of $number. Which is WRONG.
> Your numbers should go all the way up to $number/2:
>
> for ($digi = 3; $digi*2 < $number; $digi += 2) {
>
> Maybe it was a typo and you actually wanted to have one '*' instead of
> two.
No. I don't think you thought this one through. You do not need to
test for possible factors greater than the square root of the number,
because in that case there would also be a factor smaller than the
square root, which would already have been tested.
...
> This is a brute force approach. There are several methods already
> developed that are much faster than this. Some of these methods date
> back to thousand of years ago. I adivse you to look at any book on
> numerical algorithms for a better solution to your problem.
>
> Also, check out comp.lang.perl.moderated. A recent thread discussed
> prime numbers.
I gave the URL in my response.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 18 Aug 1999 15:14:10 -0400
From: "AL" <pnkflyd51@hotmail.com>
Subject: arghh! can't figure out s/// !
Message-Id: <7pf0od$d7q$1@autumn.news.rcn.net>
Hello-
I must have some sort of misconception about how s/// works. Here's what I
want, and it should be simple!
The string is initially something like "509 Green Avenue". I want to end up
with "509\+Green\+Avenue" (yes, WITH both the \'s _and_ the +'s, not just
the +'s.)
Here's my code that doesn't work:
$string =~ s/' '/'\+'/;
When I print the string, I simply get what I began with: "509 Green Avenue",
with spaces.
What am I doing wrong?!?! What would the correct code be? Thanks a ton.
Al
------------------------------
Date: Wed, 18 Aug 1999 15:25:25 -0400
From: "Allan M. Due" <Allan@due.net>
Subject: Re: arghh! can't figure out s/// !
Message-Id: <7pf1i6$s93$1@nntp3.atl.mindspring.net>
AL wrote in message <7pf0od$d7q$1@autumn.news.rcn.net>...
:Hello-
:
:I must have some sort of misconception about how s/// works. Here's
what I
:want, and it should be simple!
:
:The string is initially something like "509 Green Avenue". I want to
end up
:with "509\+Green\+Avenue" (yes, WITH both the \'s _and_ the +'s, not
just
:the +'s.)
:Here's my code that doesn't work:
:
:$string =~ s/' '/'\+'/;
Those single quotes aren't doing what you think they are. You are
literally searching for ' ' which does not exist in your string. You
need a g in there too.
$string =~ s! !\\+!g;
but I bet what you really want is something like:
$string =~ s! +!\\+!g; #one or more space
or possibly:
$string =~ s!\s+!\\+!g; #one or more white space
HTH
AmD
--
$email{'Allan M. Due'} = ' All@n.Due.net ';
--random quote --
As far as the laws of mathematics refer to reality, they are not
certain; as far as they are certain, they do not refer to reality.
- Albert Einstein
------------------------------
Date: Wed, 18 Aug 1999 15:42:07 -0400
From: "AL" <pnkflyd51@hotmail.com>
Subject: Re: arghh! can't figure out s/// !
Message-Id: <7pf2c7$o2q$1@autumn.news.rcn.net>
Thanks very much! That worked wonderfully!
Al
Allan M. Due <Allan@due.net> wrote in message
news:7pf1i6$s93$1@nntp3.atl.mindspring.net...
>
> AL wrote in message <7pf0od$d7q$1@autumn.news.rcn.net>...
> :Hello-
> :
> :I must have some sort of misconception about how s/// works. Here's
> what I
> :want, and it should be simple!
> :
> :The string is initially something like "509 Green Avenue". I want to
> end up
> :with "509\+Green\+Avenue" (yes, WITH both the \'s _and_ the +'s, not
> just
> :the +'s.)
>
> :Here's my code that doesn't work:
> :
> :$string =~ s/' '/'\+'/;
>
> Those single quotes aren't doing what you think they are. You are
> literally searching for ' ' which does not exist in your string. You
> need a g in there too.
>
> $string =~ s! !\\+!g;
>
> but I bet what you really want is something like:
> $string =~ s! +!\\+!g; #one or more space
>
> or possibly:
> $string =~ s!\s+!\\+!g; #one or more white space
>
> HTH
>
> AmD
> --
> $email{'Allan M. Due'} = ' All@n.Due.net ';
> --random quote --
> As far as the laws of mathematics refer to reality, they are not
> certain; as far as they are certain, they do not refer to reality.
> - Albert Einstein
>
>
>
------------------------------
Date: Wed, 18 Aug 1999 19:38:02 GMT
From: pacman@defiant.cqc.com (Alan Curry)
Subject: Re: arghh! can't figure out s/// !
Message-Id: <uYDu3.9907$x04.538720@typ11.nn.bcandid.com>
In article <7pf0od$d7q$1@autumn.news.rcn.net>,
AL <pnkflyd51@hotmail.com> wrote:
>Hello-
>
>The string is initially something like "509 Green Avenue". I want to end up
>with "509\+Green\+Avenue" (yes, WITH both the \'s _and_ the +'s, not just
>the +'s.)
>
>Here's my code that doesn't work:
>
>$string =~ s/' '/'\+'/;
You're searching for an apostrophe followed by a space followed by an
apostrophe. Then replacing it with an apostrophe followed by a plus followed
by an apostrophe. And since you forgot the g flag, you're only replacing the
first instance.
Try this instead
$string =~ s/ /\\+/g;
--
Alan Curry |Declaration of | _../\. ./\.._ ____. ____.
pacman@cqc.com|bigotries (should| [ | | ] / _> / _>
--------------+save some time): | \__/ \__/ \___: \___:
Linux,vim,trn,GPL,zsh,qmail,^H | "Screw you guys, I'm going home" -- Cartman
------------------------------
Date: Wed, 18 Aug 1999 13:17:49 -0700
From: Makarand Kulkarni <makkulka@cisco.com>
Subject: Re: CGI and param
Message-Id: <37BB14ED.AC8D4381@cisco.com>
[ Derek wrote:
> I would like to check if a parameter exists on the command line and if so use
> it, otherwise use a default set in the script itself
{ Code snipped...}
> but unfortunately when I run my script with no command line parameters it waits
> for me to enter some name value pairs before it will continue.
Whether or not CGI.pm will wait for you to enter name/value pairs
followed by a CTRL+D depends on the following line inside
the source for CGI.pm.
$query_string = read_from_cmdline() unless $NO_DEBUG;
Set $NO_DEBUG to 1 to make sure that you do not want the script
to scan the command line or wait for you to enter the name value pairs.
The read_from_cmdline() does the following --
if (@ARGV){
Ok use the command line..
}else {
wait for name value pairs to be entered on STDIN
}
So, the script will expect params either on the command line or
be entered as name/value pairs.
--From your question..
>I would like to check if a parameter exists on the command line and if so use
>it, or else use a default inside the script...
What you are aiming at is to run the script without any command line and want the
script NOT to wait for you to enter anything. For this you may
have to change the read_from_cmdline() itself inside CGI.pm.
--Makarand
------------------------------
Date: Wed, 18 Aug 1999 12:44:19 -0700
From: Makarand Kulkarni <makkulka@cisco.com>
Subject: Re: cgi POST in Perl script?
Message-Id: <37BB0D13.96C36C18@cisco.com>
[djnaab@students.wisc.edu wrote:
> I'm writing a script which needs to be able to POST a few variables to
> a script on an external server. I assume that there is a function for
> this in cgi-lib (or the like), but I can't find it anywhere.
Yes. You can do this. Suppose you want to make a POSTing to
a form.url script with CGI param name q and value 'x'.
use HTTP::Request::Common ;
use LWP::UserAgent;
$ua = LWP::UserAgent->new;
$res = $ua-> request ( POST 'http://whatever/.../temp/form.pl',
['q'=>'x'] );
# Notice the array being used to pass key/value pairs.
if ($res->is_success) {
print $res->as_string () ;
}
else {
print "ERROR grabbing URL...\n ";
}
---
------------------------------
Date: Wed, 18 Aug 1999 13:18:22 -0700
From: "David Christensen" <dchristensen@california.com>
Subject: Re: djgpp, Win98, Perl, and serial port
Message-Id: <37bb1289@news5.newsfeeds.com>
-----Original Message-----
From: Bbirthisel@aol.com <Bbirthisel@aol.com>
To: dchristensen@california.com <dchristensen@california.com>
Date: Tuesday, August 17, 1999 9:01 AM
Subject: Re: djgpp, Win98, Perl, and serial port
Hi David:
> I have been posting all our e-mail conversations on
comp.os.msdos.djgpp and comp.lang.perl.misc. I hope that's OK with
you...
Ok with me. But this one, which includes data and email address for
the gentleman in Japan, may not be appropriate. I would edit those
out if you re-post. <removed -- David>
> This thread is getting pretty heavy into DJGPP only, so I'm going
to stop cross-posting to comp.lang.perl.misc starting with this
message.
Mostly off topic there, although it was on when it started.
> Eli Zaretskii is one of the authors of "GNU Software for
MS-Windows and MS-DOS and Compatible Systems"
(http://www.fsf.org/order/windows.html). He hangs around on
comp.os.msdos.djgpp, and is a good sport about us all pestering him
;-). I highly recommend his book/ CD to anyone who develops on MS
boxes.
He might be one to ask about porting the Win32::API module. He
would at least have a clue as to who we should REALLY ask.
>> There are at least three sets of "serial libraries" for DJGPP...
> - if you need a serial communications package, check out the
SVAsync library.
Used that one.
> - another package for serial communications, called BCSERIO, was
written by Bill Currie. BCSERIO is available from Bill's home page.
Experimented with it. I don't recall building a complete
application.
> - if you need serial communications from programs that use the
Allegro library, try DZComm, which is available from the
v2tk/allegro directory on the usual DJGPP sites.
New to me.
> I just went to my local CPAN mirror to see what ports were
available and both
ftp://theory.uwinnipeg.ca/pub/CPAN/ports/win32/ActiveState/ and
ftp://theory.uwinnipeg.ca/pub/CPAN/ports/win32/Standard/ were
empty! I'm confused %-(
Hmm... they were both ok on my CPAN mirror this morning.
> Have you heard of Cygnus (http://sourceware.cygnus.com/cygwin/)?
Yes. I use their tools all the time and the compiler periodically.
> As I understand it, they wrote a DLL that provides a Un*x
(Posix?)
Un*x. I don't have the most recent compiler, but the older ones had
some difficulties linking with Win32 libraries - so the choice was
"all-or-nothing" rather than a blend of options. I've heard they
have made progress in this area.
> >The other alternative is an XS implementation...
> What's XS?
The glue language for writing Perl<->C extensions. If you have to
ask, it's not an available option ;-)
-bill
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Sun, 15 Aug 1999 13:51:31 -0700
From: "REBUS" <rebus@access(1).com>
Subject: Re: HARASSMENT -- Monthly Autoemail
Message-Id: <rrm70kriboh86@corp.supernews.com>
I R A Darth Aggie wrote in message ...
>No. You lose. Thank's for playing, tho. I'll draw you picture, it
>will take you less time...
>
>You post a question to misc.for-sale.widgets, 'cause you want to know
>what the going rate for a Model 31 widget is. You get several in-group
>postings, but you also get several in email. Some tell you what you want
>to know, some others inquire if you're in the market to buy, and some
>else asks if you're selling.
>
>Common link: your original posting about a Model 31 widget.
>
>Someone else sees your posting, and sends email that they've plenty of
>Model 41's, 51's and 61's at LOW LOW PRICES. *That* is unsolicited,
>because you *never* asked about those models.
>
>Does that make sense?
Oh, it makes sense all right, but you are defining rules where rules do not
exist. If, hypothetically, I post a message asking a group for the price of
tea in China, and get 20 emails offering to sell me tea at x/ton, they are
all SPAM if I *Believe* them to SPAM, then they are SPAM. However, my ISP
(and the poster's) may think differently, and act accordingly. Here in
Washington State, however, there are other remedies, and YOUR
characterisation of SPAM could get you into trouble should someone be pissed
off enough to persue them.
>+ As far as TC using
>+ an autoresponder to enforce usenet etiquette, it could be in violation of
>+ most US State
>
>Mostly deal with *commercial* spam...
Uh, maybe, ours doesn't make a distinction.
>
>+ and Federal "SPAM" laws
>
>Name one. As in "one spam law of a federal nature".
>
------------------------------
Date: Wed, 18 Aug 1999 19:17:17 GMT
From: vwcorrado@my-deja.com
Subject: Re: Help Translating Apple IIe file
Message-Id: <7pf0rf$dp0$1@nnrp1.deja.com>
In article <19990817093449.22452.00000074@ng-cp1.aol.com>,
bbirthisel@aol.com (Bbirthisel) wrote:
> Hi Richard:
>
> >My wife inherited an old Apple IIe school library cataloging system
> >(Circulation Plus is the name of the system) that I need to convert
to a
> >new Macintosh they are getting. I can succesfully get the data out,
but
> >it has embedded HEX stuff in it
>
> Circulation Plus is a trade name of Follett Software for a series
> of library programs. I have not used the Apple versions, but
> Follett had utilities to convert MS-DOS versions to Win32 with
> a different database - so I would check with them for migration
> tools.
I did and they want $270 to do the conversion. I think I can do it for
less than that, besides it _might_ be fun. :)
> The embedded binary codes are NOT irrelevant - this program
> manages a database. On an Apple IIe they are probably not
> MARC records, either. But you may need to convert them to
> that format (to do inter-library loan, etc.).
Yea, I'm going to try and convert them to MARC records to import into
the new system. The database only contains basic info about each book
(bar code #, title, author, category1, category2). I'm not looking to
do anything fancy, just keep my wife (and probably me) from entering
5000 books into the new system.
> There is a perl-4-librarians mailing list. I don't have the details
> handy, but an announcement was made on this newsgroup in
> late July.
I'll look for it. Thanx!
> BTW: A bad choice for a second script. If you can get an
> existing->ASCII converter and deal just with ASCII, it would
> still be tricky. I'm assuming you intend to use the data in the
> future.
Yea, if I could just extract the ASCII data in some reasonable format, I
could write it back out in a simple MARC format. That's the plan
anyway.
--
Later...
Richard
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Wed, 18 Aug 1999 19:47:07 GMT
From: yangsu@ustc.edu
Subject: Is it possible to send oneway message to perl cgi?
Message-Id: <7pf2jm$f67$1@nnrp1.deja.com>
Maybe it sounds silly, but what I want is that when client sends
a http request to perl cgi script, the client only cares about sending
in the information and never cares about returning message, so after
the client sends the message to server, it should return immediately
(without waiting on the server processing)
Is this possible? My experience is that it has to wait until cgi program
finishes processing.
Thanks for any enlightment.
yang
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Thu, 19 Aug 1999 00:28:10 +0400
From: "Steve" <newsgroups@mail.ru>
Subject: Re: Matt's cookielib and Unicode
Message-Id: <37bb1738.0@news.ptt.ru>
Every post you've ever made is a stupid reply. Why do you bother?
Ah... you're from Texas, no explanation necessary.
Kent Perrier <kperrier@blkbox.com> wrote in message
news:5E7B11E3DA15E040.DED30CA758CE4BBC.3996F5F6BBE5AED6@lp.airnews.net...
> Steve <lebed@my-deja.com> writes:
>
> >
> > Surely this isn't difficult, but I've only been learning Perl for 2
> > days, and you never need to learn languages anyway, you just copy code.
> >
>
> Go away, troll. If you don't have the time to learn the language then
> no one here has the time to help you.
>
> Kent
>
------------------------------
Date: Wed, 18 Aug 1999 20:33:09 +0100
From: "Clinton Gormley" <clint@drtech.co.uk>
Subject: Passing undef to a subroutine
Message-Id: <7pf1qu$dfe$1@taliesin.netcom.net.uk>
I have found that in a few (to me unpredictable) cases, a parameter list
passed to a subroutine will delete the elements which are undef, moving the
other elements up one place.
Confused? Let me try to explain.
Consider this example:
sub bar {
return
}
sub foo {
print "$#_\n";
}
foo (1,2,3,4)
prints 3
foo (1,2,bar,4)
prints 2
so the parameter list is :
$_[0] = 1,
$_[1] = 2,
$_[2] = 4
However if we change bar to :
sub bar {
return $_[0];
}
then foo (1,2,bar,4)
prints 3
So when does Perl decide that a return value of undef should be an element
in the parameter list,and when not?
Any ideas?
Thanks
Clint
------------------------------
Date: 18 Aug 1999 19:54:48 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: Passing undef to a subroutine
Message-Id: <7pf328$m35$2@info2.uah.edu>
In article <7pf1qu$dfe$1@taliesin.netcom.net.uk>,
"Clinton Gormley" <clint@drtech.co.uk> writes:
: I have found that in a few (to me unpredictable) cases, a parameter list
: passed to a subroutine will delete the elements which are undef, moving the
: other elements up one place.
:
: Confused? Let me try to explain.
:
: Consider this example:
: sub bar {
: return
: }
:
: sub foo {
: print "$#_\n";
: }
:
: foo (1,2,3,4)
: prints 3
:
: foo (1,2,bar,4)
: prints 2
Go back and reread the return docs:
=item return EXPR
=item return
If no EXPR is given, returns an empty list in list context, an
undefined value in scalar context, or nothing in a void context.
Your second example is identical to
foo (1,2,(),4);
Greg
--
Nine out of ten men who try Camels prefer women.
------------------------------
Date: Wed, 18 Aug 1999 13:09:19 -0700
From: "Dr. Mark S. Reibert" <Mark_Reibert-SC2762@email.mot.com>
Subject: Re: Passing undef to a subroutine
Message-Id: <37BB12EF.3A292C7C@email.mot.com>
The key is that bar() in foo (1,2,bar,4) is called in list context, thus
the return statement in bar() is evaluated in list context. From the
perlfunc man page on return:
If no EXPR is given, returns an empty list in a list context, an undefined
value in a scalar context, or nothing in a void context.
Thus, you are returning an empty list and foo gets passed (1,2,,4) which
flattens to (1,2,4).
HTH,
Mark Reibert
Clinton Gormley wrote:
>
> I have found that in a few (to me unpredictable) cases, a parameter list
> passed to a subroutine will delete the elements which are undef, moving the
> other elements up one place.
--
------------------------------
Mark S. Reibert, Ph.D.
Motorola SSTG (Datasoft Corp.)
Tel: 480-732-3752
Page: 800-759-8352 #7689193
Mail: sc2762@email.mot.com
------------------------------
------------------------------
Date: Wed, 18 Aug 1999 17:07:00 -0700
From: "Mark Hammer" <mark@leaf.ee.ufl.edu>
Subject: Re: Pattern Matching
Message-Id: <7pf742$8fbq$1@spnode25.nerdc.ufl.edu>
What do you mean? I meant has anyone written code that can match patterns of
that type...
--
Mark Hammer
mark@leaf.ee.ufl.edu
http://free.prohosting.com/~maqua/
Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote in message
news:7pek9b$6ac$1@lublin.zrz.tu-berlin.de...
> Mark Hammer <mark@leaf.ee.ufl.edu> wrote in comp.lang.perl.misc:
>
> >Has anyone done this (made a general code):
>
> It doesn't pay to make a general code, they're no good at it.
>
> Anno
------------------------------
Date: Wed, 18 Aug 1999 13:23:24 -0700
From: Angelo Bonet <abonet@rincon.com>
Subject: Perl function that searches $PATH for a filename
Message-Id: <37BB163C.3075A37B@rincon.com>
Hello-
Is there any Perl function that searches $PATH for a file? Something
similar to the "which" or "whereis" command in Unix?
Thanks,
Angelo
------------------------------
Date: 18 Aug 1999 16:37:26 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Perl function that searches $PATH for a filename
Message-Id: <x7pv0kyge1.fsf@home.sysarch.com>
>>>>> "AB" == Angelo Bonet <abonet@rincon.com> writes:
AB> Hello-
AB> Is there any Perl function that searches $PATH for a file? Something
AB> similar to the "which" or "whereis" command in Unix?
you can write one in 5 minutes (or less). try it.
in fact it can be done in 1 line if you want all of the hits like some
versions of which generate.
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
uri@sysarch.com --------------------------- Perl, Internet, UNIX Consulting
Have Perl, Will Travel ----------------------------- http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
"F**king Windows 98", said the general in South Park before shooting Bill.
------------------------------
Date: Wed, 18 Aug 1999 22:14:57 +0200
From: "Juan Riera" <jriera@retemail.es>
Subject: Perl on Linux and MS SQL 7.0
Message-Id: <7pf4jj$kid6@SGI3651ef0>
Hello,
Does anybody know any DBI/DBD interface to access MS SQL 7.0 on NT from a
CGI perl script on Linux ?
Thanks,
Juan
------------------------------
Date: Wed, 18 Aug 1999 21:59:03 +0100
From: news <news@news.com>
Subject: Perl/ HTML form mail attachments
Message-Id: <37BB1E97.3BD68FB4@news.com>
If you offer users the opportunity to attach documents when using an
HTML form, e.g.
using something like:
<INPUT TYPE="File" NAME="attachment" VALUE="">
How do you then attach the file in the perl script that calls sendmail?
The example below
will just send the path and name of the file that was attached and not
the file itself.
....
open (MAIL, "|$mailprog -t") || die "Can't open $mailprog!\n";
print MAIL "To: $recipient\n";
print MAIL "From: $user\n";
print MAIL "Subject: Subject\n\n";
print MAIL "Reply-to: $user\n";
print MAIL
"------------------------------------------------------------\n";
print MAIL "$FORM{'first_name'} $FORM{'last_name'} sent the
following\n";
print MAIL "Phone: $FORM{'phone'}\n";
print MAIL "Email: $FORM{'email'}\n";
print MAIL "Attachment: $FORM{'attachment'}";
close (MAIL);
Any help would be much appreciated.
Thanks.
Saiid.
saiid@excite.com
------------------------------
Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 1 Jul 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.
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" from
almanac@ruby.oce.orst.edu. The real FAQ, as it appeared last in the
newsgroup, can be retrieved with the request "send perl-users FAQ" from
almanac@ruby.oce.orst.edu. 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" from
almanac@ruby.oce.orst.edu.
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 577
*************************************