[22847] in Perl-Users-Digest
Perl-Users Digest, Issue: 5068 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jun 3 11:05:52 2003
Date: Tue, 3 Jun 2003 08:05:08 -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 Tue, 3 Jun 2003 Volume: 10 Number: 5068
Today's topics:
Re: "Standard" modules missing in ActivePerl <kalinabears@hdc.com.au>
Re: Efficient Date Sorting (Sara)
howto update a print to STDOUT <talong@nospamonline.no>
Re: howto update a print to STDOUT <usenet@expires082003.tinita.de>
Re: Is there a bail() function? (Anno Siegel)
perl script <jamesbond_422@hotmail.com>
Re: perl script <goedicke@goedsole.com>
Re: perl script <usenet@expires082003.tinita.de>
Re: perl script <nobody@dev.null>
Re: regexp to negate 2 chars at once <usenet@expires082003.tinita.de>
Remove first character in a string? <jon@rogers.tv>
Re: Remove first character in a string? <bernard.el-hagin@DODGE_THISlido-tech.net>
Re: Remove first character in a string? <koos_pol@NO.nl.JUNK.compuware.MAIL.com>
Re: Remove first character in a string? <roobarb@fastmail.fm>
selecting more than 1 record from database with win32:: <w@wp.pl>
simple script error (Jerry Maguire)
Re: simple script error (Anno Siegel)
Re: Sorting hash ctcgag@hotmail.com
Re: Still puzzled, file handles and infinite loops (Anno Siegel)
Re: test (Tad McClellan)
Re: Weird Perl Performance Issues (Anno Siegel)
Win32::OLE::Variant and variant data type VT_DISPATC (Graham Smith)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 3 Jun 2003 20:29:09 +1000
From: "Sisyphus" <kalinabears@hdc.com.au>
Subject: Re: "Standard" modules missing in ActivePerl
Message-Id: <3edc7999$0$18562@echo-01.iinet.net.au>
"William Goedicke" <goedicke@goedsole.com> wrote
>
> ppm> query --nocase dumper
>
> Go figure.
>
I think 'query' searches the ppm data file - which contains entries only for
modules that have been installed using ppm.
I don't know for sure the name of that data file, but some brief testing I
just did indicates that it's 'ppm.xml'.
(I don't think you need to specify '--nocase' on Win32. At least, I couldn't
find a use for it :-)
Cheers,
Rob
------------------------------
Date: 3 Jun 2003 07:54:48 -0700
From: genericax@hotmail.com (Sara)
Subject: Re: Efficient Date Sorting
Message-Id: <776e0325.0306030654.7d07a819@posting.google.com>
"Gregory Toomey" <nobody@noplace.com> wrote in message news:<01c32684$599b62c0$f5498a90@gmtoomey>...
> Matthew Braid <mbear@uq.net.au> wrote in article
> <bb6ucb$87n$1@bunyip.cc.uq.edu.au>...
> > Hi all,
> >
> > I have to write a coderef to pass to sort so that it takes a list of
> > 'human-readable' dates. I can't preparse the list in any way first as it
> > is being used as part of a Tk widget (Tk::MListbox), so I can't do any
> > groovy map-sort-map tricks.
>
> Why not? Try the Schwartzian transform:
> http://prometheus.frii.com/~gnat/yapc/2000-stages/slide40.html
>
> Then getting your dates into some canonical form such as YYYYMMDDHHMMSS
> (eg 12:59 am on Mon 31/12/2003 becomes "300423422359")
> so you can do a simple string compasrision in the sort.
>
> gtoomey
actually a 'simple string comparison" may not work, a numeric
comparison would probably be a more successful choice.
Gx
------------------------------
Date: Tue, 03 Jun 2003 11:07:59 +0000
From: Trygve Aspenes <talong@nospamonline.no>
Subject: howto update a print to STDOUT
Message-Id: <3EDC818F.3040601@nospamonline.no>
Hello
I want to print a message to STDOUT (perl 5.6.0, debian)with a
persentage of a working job, and I want it to update just the numbers
and not write a new line every time.
Anyone who got an idea?
Regards Trygve
------------------------------
Date: 3 Jun 2003 12:05:17 GMT
From: Tina Mueller <usenet@expires082003.tinita.de>
Subject: Re: howto update a print to STDOUT
Message-Id: <bbi2ts$9f86j$1@ID-24002.news.dfncis.de>
Trygve Aspenes wrote:
> I want to print a message to STDOUT (perl 5.6.0, debian)with a
> persentage of a working job, and I want it to update just the numbers
> and not write a new line every time.
here's an example:
$|=1; # flush STDOUT
for (0..100) {
do_something();
# carriage-return will go back to the start of the line
printf "\r %02d%%",$_;
}
print "\n";
hth, tina
--
http://www.tinita.de/ \ enter__| |__the___ _ _ ___
http://Movies.tinita.de/ \ / _` / _ \/ _ \ '_(_-< of
http://www.perlquotes.de/ \ \ _,_\ __/\ __/_| /__/ perception
- my mail address expires end of august 2003 -
------------------------------
Date: 3 Jun 2003 12:55:26 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Is there a bail() function?
Message-Id: <bbi5ru$kr9$1@mamenchi.zrz.TU-Berlin.DE>
Unknown Poster <use63net@yahoo.com> wrote in comp.lang.perl.misc:
> I can't find it in Programming Perl 3E, but it's used like die() in
> Learning Perl 2E, as in the following:
>
> open(CHANDLE, "+< $CHATNAME") || bail ("cannot open $CHATNAME: $!");
Are you sure that line is in _Learning Perl_? "$CHATNAME" in all-caps
looks awfully strange for something that must have been run by Randal
Schwartz.
Anno
------------------------------
Date: Tue, 3 Jun 2003 12:33:26 +0000 (UTC)
From: "Jerry Maguire" <jamesbond_422@hotmail.com>
Subject: perl script
Message-Id: <bbi4im$pu3$1@hercules.btinternet.com>
Hi,
Can anyone look at the following script and let me know the resolution to
the error:
-----------------------------------------------------------------
#!/usr/bin/perl
##
$| = 1;
$HOST1 = "foo.net";
$HOST2 = "foo.com";
$HOST_RESULT1 ="https://foo.net/$_";
$HOST_RESULT2 = "https://foo.com/$_";
$PORT = "443";
$URLPAGE = "GET /";
$TELNET = "/usr/bin/telnet $HOST1 443";
#exec echo "$URLPAGE" |"$TELNET $HOST1 $PORT" |grep Connected;
exec (echo $URLPAGE|$TELNET|grep "Connected to $HOST1") 1<&2 ;
if ( $? ne 0 ) {
while ( <STDIN> ) {
print "$HOST_RESULT2/$_";
if ( $? ne 0 ) {
while ( <STDIN> ) {
print "$HOST_RESULT2/$_";
}
} elsif ( $? eq 0 ) {
while (<STDIN>) {
print "$HOST_RESULT1/$_";
}
}
---------------------------------------------------------------------
I am looking for a simple per script whihc cheks the url and if it is up
then print a correct URL.
Following are the errors in this script:
Not enough arguments for grep at ./status.pl line 12, near ""Connected to
$HOST1")"
syntax error at ./status.pl line 13, near "."
./status.pl had compilation errors.
Thanks
jerry
------------------------------
Date: Tue, 03 Jun 2003 13:22:01 GMT
From: William Goedicke <goedicke@goedsole.com>
Subject: Re: perl script
Message-Id: <m3k7c3wb2l.fsf@mail.goedsole.com>
Dear Jerry -
"Jerry Maguire" <jamesbond_422@hotmail.com> writes:
> I am looking for a simple per script whihc cheks the url and if it
> is up then print a correct URL.
Check out netsaint (i.e. http://www.netsaint.org).
Yours - Billy
============================================================
William Goedicke goedicke@goedsole.com
http://www.goedsole.com:8080
============================================================
Lest we forget:
Approach the pockets.
- William Goedicke
------------------------------
Date: 3 Jun 2003 13:54:08 GMT
From: Tina Mueller <usenet@expires082003.tinita.de>
Subject: Re: perl script
Message-Id: <bbi9a0$9fclq$1@ID-24002.news.dfncis.de>
Jerry Maguire wrote:
> exec (echo $URLPAGE|$TELNET|grep "Connected to $HOST1") 1<&2 ;
> Not enough arguments for grep at ./status.pl line 12, near ""Connected to
> $HOST1")"
> syntax error at ./status.pl line 13, near "."
well, exec() takes a list as an argument. you have to quote the
arguments, or perl thinks you mean the perl grep() function.
exec "echo $URLPAGE...";
--
http://www.tinita.de/ \ enter__| |__the___ _ _ ___
http://Movies.tinita.de/ \ / _` / _ \/ _ \ '_(_-< of
http://www.perlquotes.de/ \ \ _,_\ __/\ __/_| /__/ perception
- my mail address expires end of august 2003 -
------------------------------
Date: Tue, 03 Jun 2003 14:23:19 GMT
From: Andras Malatinszky <nobody@dev.null>
Subject: Re: perl script
Message-Id: <3EDCAF22.3010305@dev.null>
Jerry Maguire wrote:
> Hi,
> Can anyone look at the following script and let me know the resolution to
> the error:
> -----------------------------------------------------------------
> #!/usr/bin/perl
> ##
> $| = 1;
> $HOST1 = "foo.net";
> $HOST2 = "foo.com";
> $HOST_RESULT1 ="https://foo.net/$_";
> $HOST_RESULT2 = "https://foo.com/$_";
> $PORT = "443";
> $URLPAGE = "GET /";
> $TELNET = "/usr/bin/telnet $HOST1 443";
> #exec echo "$URLPAGE" |"$TELNET $HOST1 $PORT" |grep Connected;
> exec (echo $URLPAGE|$TELNET|grep "Connected to $HOST1") 1<&2 ;
This preceding line is totally bogus. First of all, to quote perlfunc,
The "exec" function executes a system command *and never
returns*-- use "system" instead of "exec" if you want it to
return.
So it's not clear why you are bothering with the rest of your program,
since it will never be executed. You probably want system or backticks.
Then, think for a moment about what list of commands you want to send to
your shell. Right now you are asking perl to make sense of the
one-element list
(echo $URLPAGE|$TELNET|grep "Connected to $HOST1") 1<&2
as best it can, and then pass the results to the shell. But
(echo $URLPAGE|$TELNET|grep "Connected to $HOST1") 1<&2
is a big fat syntax error as far as perl is concerned.
What you might want to do is to put your --properly quoted -- command
string into a variable, like
$this=qq[(echo $URLPAGE|$TELNET|grep "Connected to $HOST1") 1<&2
];
then
print $this;
to see if $this is really what you would type in at the shell prompt,
end if it is, then do a system($this).
>
> if ( $? ne 0 ) {
> while ( <STDIN> ) {
> print "$HOST_RESULT2/$_";
>
Looks like you put these three lines in twice by accident. As it is, you have more left curlies than right curlies.
>
> if ( $? ne 0 ) {
> while ( <STDIN> ) {
> print "$HOST_RESULT2/$_";
> }
> } elsif ( $? eq 0 ) {
> while (<STDIN>) {
> print "$HOST_RESULT1/$_";
> }
> }
> ---------------------------------------------------------------------
> I am looking for a simple per script whihc cheks the url and if it is up
> then print a correct URL.
>
> Following are the errors in this script:
> Not enough arguments for grep at ./status.pl line 12, near ""Connected to
> $HOST1")"
> syntax error at ./status.pl line 13, near "."
> ./status.pl had compilation errors.
>
> Thanks
> jerry
>
>
>
------------------------------
Date: 3 Jun 2003 14:05:13 GMT
From: Tina Mueller <usenet@expires082003.tinita.de>
Subject: Re: regexp to negate 2 chars at once
Message-Id: <bbi9up$9fclq$2@ID-24002.news.dfncis.de>
Dan Jacobson wrote:
>> Look for the (?! ) operator in perldoc perlre
> I did. Now what?
Q: I have to put a nail into a wall.
A: Look for a hammer in the garage.
Q: I did. Now what?
SCNR =)
--
http://www.tinita.de/ \ enter__| |__the___ _ _ ___
http://Movies.tinita.de/ \ / _` / _ \/ _ \ '_(_-< of
http://www.perlquotes.de/ \ \ _,_\ __/\ __/_| /__/ perception
- my mail address expires end of august 2003 -
------------------------------
Date: Tue, 03 Jun 2003 15:05:24 +0200
From: Jon Rogers <jon@rogers.tv>
Subject: Remove first character in a string?
Message-Id: <3EDC9D14.C1F3637A@rogers.tv>
Hi,
Is there an easy way of removing the first character of a string?
I presently use substr. Stupid, I guess.
Thanks,
JR
------------------------------
Date: Tue, 3 Jun 2003 13:04:49 +0000 (UTC)
From: "Bernard El-Hagin" <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: Remove first character in a string?
Message-Id: <Xns938F990EFB894elhber1lidotechnet@62.89.127.66>
Jon Rogers wrote:
> Hi,
>
> Is there an easy way of removing the first character of a string?
>
> I presently use substr. Stupid, I guess.
On the contrary. It's not stupid. But if you want an alternative there's
always:
$text =~ s/^.//;
--
Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'
------------------------------
Date: Tue, 03 Jun 2003 15:30:46 +0200
From: Koos Pol <koos_pol@NO.nl.JUNK.compuware.MAIL.com>
Subject: Re: Remove first character in a string?
Message-Id: <newscache$avqwfh$2r$1@news.emea.compuware.com>
Bernard El-Hagin wrote (Tuesday 03 June 2003 15:04):
> Jon Rogers wrote:
>
>> Is there an easy way of removing the first character of a string?
>>
>> I presently use substr. Stupid, I guess.
>
>
> On the contrary. It's not stupid. But if you want an alternative there's
> always:
>
> $text =~ s/^.//;
chip() should make a fine opposite to chop()
I find myself removing a first char regularly.
--
KP
"You never run out of hardware-you either run out of skill or judgement"
- His Philness
------------------------------
Date: Tue, 3 Jun 2003 14:49:52 +0100
From: Keith Anderson <roobarb@fastmail.fm>
Subject: Re: Remove first character in a string?
Message-Id: <K82Da.33571$xd5.1553102@stones.force9.net>
On Tue, 03 Jun 2003 15:05:24 +0200
in news:<3EDC9D14.C1F3637A@rogers.tv>
Jon Rogers wrote:
> Hi,
>
> Is there an easy way of removing the first character of a string?
>
> I presently use substr. Stupid, I guess.
substr sounds fine to me, maybe an lvalue, as in:
substr($x, 0, 1) = '';
>
> Thanks,
> JR
--
Keith Anderson
------------------------------
Date: Tue, 03 Jun 2003 11:24:15 GMT
From: <w@wp.pl>
Subject: selecting more than 1 record from database with win32::0dbc
Message-Id: <zz%Ca.95081$_c6.783128@news.chello.at>
Anyone knows how to read more than one row of data from database using
win32::odbc.
I am trying to select all records containing specific value with " SELECT *
FROM table WHERE columnvalue = 'value'" and then use fetchrow() to see
selected records but it is not working. Is there any other way to do this.
Thanks for any help
------------------------------
Date: 3 Jun 2003 05:40:01 -0700
From: jamesbond_422@hotmail.com (Jerry Maguire)
Subject: simple script error
Message-Id: <89262113.0306030440.56f0a35d@posting.google.com>
Hi,
Can anyone look at the following script and let me know the resolution
to the error:
-----------------------------------------------------------------
#!/usr/bin/perl
##
$| = 1;
$HOST1 = "foo.net";
$HOST2 = "foo.com";
$HOST_RESULT1 ="https://foo.net/$_";
$HOST_RESULT2 = "https://foo.com/$_";
$PORT = "443";
$URLPAGE = "GET /";
$TELNET = "/usr/bin/telnet $HOST1 443";
#exec echo "$URLPAGE" |"$TELNET $HOST1 $PORT" |grep Connected;
exec (echo $URLPAGE|$TELNET|grep "Connected to $HOST1") 1<&2 ;
if ( $? ne 0 ) {
while ( <STDIN> ) {
print "$HOST_RESULT2/$_";
if ( $? ne 0 ) {
while ( <STDIN> ) {
print "$HOST_RESULT2/$_";
}
} elsif ( $? eq 0 ) {
while (<STDIN>) {
print "$HOST_RESULT1/$_";
}
}
---------------------------------------------------------------------
I am looking for a simple per script whihc cheks the url and if it is
up then print a correct URL.
Following are the errors in this script:
Not enough arguments for grep at ./status.pl line 12, near ""Connected
to $HOST1")"
syntax error at ./status.pl line 13, near "."
./status.pl had compilation errors.
Thanks
jerry
------------------------------
Date: 3 Jun 2003 13:21:48 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: simple script error
Message-Id: <bbi7dc$mtl$1@mamenchi.zrz.TU-Berlin.DE>
Jerry Maguire <jamesbond_422@hotmail.com> wrote in comp.lang.perl.misc:
> Hi,
> Can anyone look at the following script and let me know the resolution
> to the error:
> -----------------------------------------------------------------
> #!/usr/bin/perl
> ##
> $| = 1;
> $HOST1 = "foo.net";
> $HOST2 = "foo.com";
> $HOST_RESULT1 ="https://foo.net/$_";
> $HOST_RESULT2 = "https://foo.com/$_";
> $PORT = "443";
> $URLPAGE = "GET /";
> $TELNET = "/usr/bin/telnet $HOST1 443";
> #exec echo "$URLPAGE" |"$TELNET $HOST1 $PORT" |grep Connected;
> exec (echo $URLPAGE|$TELNET|grep "Connected to $HOST1") 1<&2 ;
Have you looked up "exec" in perldoc? Realized that it wants one
or more *strings* as arguments? Noted that exec() never returns
to your program? If you do, you'll find that you can't use exec
like that and that you don't want to use it here at all.
>
> if ( $? ne 0 ) {
Wrong comparison operator. Numbers are compared with "==".
> while ( <STDIN> ) {
^
There is no closing "}" that corresponds to this.
What do you expect to read from STDIN here?
> print "$HOST_RESULT2/$_";
>
>
> if ( $? ne 0 ) {
Why check $? again? You just did.
> while ( <STDIN> ) {
> print "$HOST_RESULT2/$_";
> }
> } elsif ( $? eq 0 ) {
> while (<STDIN>) {
> print "$HOST_RESULT1/$_";
> }
> }
> ---------------------------------------------------------------------
> I am looking for a simple per script whihc cheks the url and if it is
> up then print a correct URL.
Have you even taken a second look at your sentence above? Occasional
typos are one thing, not even trying to make sense is another.
Please invest a little effort on your own and look up the functions you're
using. Re-post if you still have trouble.
Anno
------------------------------
Date: 03 Jun 2003 14:50:02 GMT
From: ctcgag@hotmail.com
Subject: Re: Sorting hash
Message-Id: <20030603105002.688$lV@newsreader.com>
Gunnar Hjalmarsson <noreply@gunnar.cc> wrote:
> Considering the above, do you still recommend that the sort is
> stabilized, or would such a measure be redundant?
I am not he, but I recommend that you stabilize the sort, even though
it is probably redundant. The performance impact is probably low, and
better safe than sorry. It's foolish to tempt fate when the defensive
solution is so readily available.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service New Rate! $9.95/Month 50GB
------------------------------
Date: 3 Jun 2003 10:27:23 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Still puzzled, file handles and infinite loops
Message-Id: <bbht6b$do0$1@mamenchi.zrz.TU-Berlin.DE>
fatted <fatted@yahoo.com> wrote in comp.lang.perl.misc:
> Thanks for previous help (posted under "scope of variable"). But I'm
> still puzzled. Looking at the following script:
>
> use warnings;
> use strict;
>
> open(OUT,">>","test.log");
>
> while(1)
> {
> sleep(2);
> my($seconds, $minutes, $hours, $day_of_month, $month, $year,
> $wday, $yday, $isdst) = localtime(time);
Better written as
my ( $seconds, $minutes, $hours) = localtime;
> print OUT (sprintf("%02d:%02d:%02d",$hours,$minutes,$seconds)."\n");
Better written as
printf OUT "%02d:%02d:%02d\n",$hours,$minutes,$seconds;
> print(sprintf("%02d:%02d:%02d",$hours,$minutes,$seconds)."\n");
Same here. "printf" prints directly.
> }
>
> When this is run, it prints the time to the screen every 2 seconds.
> Eggcellent. However it doesn't write the time to the file at all
> (although the file is created, as expected).
>
> Now try the following script:
>
> use warnings;
> use strict;
>
> while(1)
> {
> sleep(2);
> my($seconds, $minutes, $hours, $day_of_month, $month, $year,
> $wday, $yday, $isdst) = localtime(time);
> open(OUT,">>","test.log");
> print OUT (sprintf("%02d:%02d:%02d",$hours,$minutes,$seconds)."\n");
> print(sprintf("%02d:%02d:%02d",$hours,$minutes,$seconds)."\n");
> }
>
> Again prints time to screen every 2 seconds, and now also writes to
> file. *Except*, the file is 2 seconds (1 loop?) behind. So As soon as
> time 10:58:03 is printed to screen, I hit ^C, looking in file and last
> time printed is 10:58:01. Looking at code the write to the file is
> before the write to the screen, so I couldn't have just got lucky
> (stopping program between the 2 prints) with where I ^C'ed.
>
> From previous discussion, I understand (hopefully :) that there
> shouldn't be a difference between where the open command is called,
> the file handle should still be available in the while loop, so why
> does the program perform differently?
> Why is the write to the file appear to be behind the write to STDOUT?
Buffering.
What you writ to out in the first program is buffered. As long
as the buffer doesn't fill up, nothing is written to disk until
the program flushes its buffers.
You don't say so, but since the program runs in an infinite loop
you probably stop it using some signal (probably ^C, which sends an
INT). Unlike a normal program exit, this doesn't flush buffers,
so the (final) buffer for OUT never gets written. Add
select OUT;
$| = 1;
select STDOUT;
or equivalent to your program. Alternatively you can catch INT
(and/or other likely signals) in %SIG and close OUT in the handler.
Anno
------------------------------
Date: Tue, 3 Jun 2003 08:13:19 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: test
Message-Id: <slrnbdp7nf.gch.tadmc@magna.augustmail.com>
Nils Petter Vaskinn <no@spam.for.me.invalid> wrote:
> On Mon, 02 Jun 2003 13:27:59 -0700, DA wrote:
>
>> testing. pl. ignore
>
> No I won't.
Me either.
I killfiled him, as I do with most newsgroup abusers.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 3 Jun 2003 10:36:35 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Weird Perl Performance Issues
Message-Id: <bbhtnj$do0$2@mamenchi.zrz.TU-Berlin.DE>
Janek Schleicher <bigj@kamelfreund.de> wrote in comp.lang.perl.misc:
> Geoffrey Zhu wrote at Mon, 02 Jun 2003 21:45:02 -0700:
>
> > I encountered a very interesting perl performance issue recently.
> >
> > I have three functions on an object, fn_a, fn_b, fn_c. I have verified
> > that they do not interfere with each other. The following are highly
> > interesting:
> >
> > 1. If you call three functions together in a loop, like the following,
> > it takes 26 seconds.
> >
> > [...]
> >
> > 2. If you call the three functions separately, like the following, it
> > takes a total of 4 seconds.
> >
> > [...]
> >
> > The question is why the execution time reduces so much if I put the
> > function calls in separate loops. Any hint?
>
>
> That's odd. Show us the full code.
> (Normally you won't need 4 seconds only to call some functions).
Well, that would depend a bit on the functions, wouldn't it?
> We can only guess what's going on if we know what the hash consists of and
> what the functions do.
Indeed. There are plenty reasons why the sequence of processing may
influence performance. IO buffering is one candidate, memory caching
is another. It could also be normal behavior for the final three of
the functions to do nothing if the first one has run on all objects.
We simply don't know.
Anno
------------------------------
Date: 3 Jun 2003 04:04:20 -0700
From: grehom@ntlworld.com (Graham Smith)
Subject: Win32::OLE::Variant and variant data type VT_DISPATCH
Message-Id: <98eb7f13.0306030304.50b9180a@posting.google.com>
As part of using OLE automation to control DesignCAD (2D/3D CAD
package for Windows) I am trying to understand how VT_DISPATCH works
as part of Win32::OLE::Variant usage.
There is a function within DesignCAD called FindFirstItem which
retrieves first component of a drawing, documented as follows:
Function FindFirstItem(foundEntity as Entity, direction as Integer) As
Long
Arguments: foundEntity - The first (or last) entity in the drawing is
returned in this variable as a DesignCAD Entity object.
direction - An integer, used to determine the direction of the search.
If this number is less than zero, FindFirstItem finds the "last"
entity in the drawing. Otherwise, it finds the "first" entity.
Returns: Long - The return value is used by DesignCAD to identify the
starting location for any subsequent uses of the FindNextItem command.
The result of FindFirstItem should be stored in a variable, which will
be passed as a parameter to FindNextItem. A negative result indicates
that nothing was found.
The way I managed to get this function to 'work!' was using the
following piece of perl:
# I want a reference to the first Entity Object
my $DcEnt = Variant( VT_DISPATCH | VT_BYREF, 0 );
# search through the drawing for entities
my $FindResult = $DcEntities->FindFirstItem($DcEnt, -1);
this returns a sensible value in the $FindResult variable, however the
bit I am interested in is the $DcEnt variable which I defined above.
The first thing I want to do having got the first entity is to print
what type of entity it is:
if ($FindResult < 0) {
die "No items found in the selection set";
} else {
print "Object's type is: ", $DcEnt->EntityType, "\n";
}
The 'EntityType' property is a readonly property which returns the
entity's type (line, curve, circle, etc.). The problem I am having is
that $DcEnt appears to have remained unset - it is set to null and the
program returns an error message
C:\perlSrcs\DesignCad>perl -w findEntities.pl
Can't locate object method "EntityType" via package
"Win32::OLE::Variant" at findEntities.pl line 41.
Which is fair enough I suppose since EntityType is a property of the
Entity which I'd rather hoped would be referred to by $DcEnt.
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 5068
***************************************