[27398] in Perl-Users-Digest
Perl-Users Digest, Issue: 9065 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Mar 18 21:05:44 2006
Date: Sat, 18 Mar 2006 18:05:04 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sat, 18 Mar 2006 Volume: 10 Number: 9065
Today's topics:
Re: A Problem With GD <abigail@abigail.nl>
Tranlating VB code into Perl to utilise Outlook Redempt <graham@letsgouk.com>
Re: Tranlating VB code into Perl to utilise Outlook Red <matthew.garrish@sympatico.ca>
Re: Tranlating VB code into Perl to utilise Outlook Red <graham@letsgouk.com>
Re: Tranlating VB code into Perl to utilise Outlook Red <graham@letsgouk.com>
Re: Using a variable to call a sub-routine... robic0
Re: Using a variable to call a sub-routine... robic0
vec - a misunderstanding (Mark Hobley)
Re: vec - a misunderstanding <john@castleamber.com>
Re: vec - a misunderstanding (Anno Siegel)
Re: XML::Simple and utf8 woes <corff@zedat.fu-berlin.de>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 18 Mar 2006 20:48:44 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: A Problem With GD
Message-Id: <slrne1oshc.46n.abigail@alexandra.abigail.nl>
Mark Manning (markem@airmail.net) wrote on MMMMDLXXXII September MCMXCIII
in <URL:news:121o831h4u70if9@corp.supernews.com>:
"" Abigail wrote:
"" > == Well that's strange. I thought one of the strong points of Perl was th
"" > == guaranteed to always do the pre-increment command before doing anything
"" >
"" >
"" > It doesn't. And this fact is documented.
""
"" I'm sorry, but - I just did a search using Google to find where this is
"" documented and looked through all of my Perl books. I can not find where th
"" is documented. Do you have a website where I may read up on this?
Website? Why would you need the web to read the Perl documentation?
Perl comes with its own documentation.
""
"" > == Unlike C/C++ where you are not guaranteed to be able to do this.
"" >
"" > Pre/post increment/decrement works "as in C". With the same benefits.
"" > And the same flexibility for the implementation.
""
"" Well, I know Perl works a lot like C/C++ but if I remember correctly, Mr. Wa
"" stated a number of years ago that since Perl was in interpreter instead of a
"" compiler that the interpreter he had written (which may now be in Lex & Yacc
"" all I know and I do recall that Perl 5 had many changes to it) corrected the
"" problem the compilers introduced by ensuring that pre-incremented variables
"" would always be pre-incremented before the rest of the equation was evalutat
Do you have a reference for this statement? Anyway, Perl is a language, and
perl is a compiler/run-time environment.
No piece of Perl is executed before it is compiled.
"" Still, would you consider: $a = &funca($a) + &funcb($a)
"" bad if both funca and funcb modified $a?
Yes, because I don't want to remember whether Perl defines an order of
evaluation of '+', and if it does, what it is.
However, AFAIK, Perl does define the order (left to right) so the value
of $a isn't undefined. But I consider it bad style anyway.
Abigail
--
echo "==== ======= ==== ======"|perl -pes/=/J/|perl -pes/==/us/|perl -pes/=/t/\
|perl -pes/=/A/|perl -pes/=/n/|perl -pes/=/o/|perl -pes/==/th/|perl -pes/=/e/\
|perl -pes/=/r/|perl -pes/=/P/|perl -pes/=/e/|perl -pes/==/rl/|perl -pes/=/H/\
|perl -pes/=/a/|perl -pes/=/c/|perl -pes/=/k/|perl -pes/==/er/|perl -pes/=/./;
------------------------------
Date: Sat, 18 Mar 2006 19:28:33 -0000
From: "Graham" <graham@letsgouk.com>
Subject: Tranlating VB code into Perl to utilise Outlook Redemption
Message-Id: <441c6009.0@entanet>
Outlook Redemption is a COM object that works around the security issues of
Outlook 2002+, and I wanna use this in a Perl script that works with Outlook
in sending email. My problem is that I don't know VB well enough to
translate the sample VB code for 'Send email bypassing the security prompt'
at the following address
http://www.dimastr.com/redemption/objects.htm#examples , into Perl.
Can anyone help?
------------------------------
Date: Sat, 18 Mar 2006 15:28:46 -0500
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: Tranlating VB code into Perl to utilise Outlook Redemption
Message-Id: <04_Sf.18038$ng.720840@news20.bellglobal.com>
"Graham" <graham@letsgouk.com> wrote in message news:441c6009.0@entanet...
> Outlook Redemption is a COM object that works around the security issues
> of Outlook 2002+, and I wanna use this in a Perl script that works with
> Outlook in sending email. My problem is that I don't know VB well enough
> to translate the sample VB code for 'Send email bypassing the security
> prompt' at the following address
> http://www.dimastr.com/redemption/objects.htm#examples , into Perl.
>
> Can anyone help?
This should get you started: (untested, of course, as I don't have
Redemption)
use Win32::OLE;
my $Application = new Win32::OLE('Outlook.Application');
my $oItem = $Application->CreateItem(0);
my $SafeItem = new Win32::OLE('Redemption.SafeMailItem');
$SafeItem->{'Item'} = $oItem;
Translating the rest on your own shouldn't be too much to ask.
Matt
------------------------------
Date: Sat, 18 Mar 2006 20:18:08 -0000
From: "Graham" <graham@letsgouk.com>
Subject: Re: Tranlating VB code into Perl to utilise Outlook Redemption
Message-Id: <441c6bad.0@entanet>
Silly me..., the VB code in question is as follows:-
dim SafeItem, oItem
set SafeItem = CreateObject("Redemption.SafeMailItem") 'Create an instance
of Redemption.SafeMailItem
set oItem = Application.CreateItem(0) 'Create a new message
SafeItem.Item = oItem 'set Item property
SafeItem.Recipients.Add "somebody@somewhere.com"
SafeItem.Recipients.ResolveAll
SafeItem.Subject = "Testing Redemption"
SafeItem.Send
------------------------------
Date: Sat, 18 Mar 2006 22:47:15 -0000
From: "Graham" <graham@letsgouk.com>
Subject: Re: Tranlating VB code into Perl to utilise Outlook Redemption
Message-Id: <441c8e9e.0@entanet>
Aah - that looks more familiar. Thanks Matt!
"Matt Garrish" <matthew.garrish@sympatico.ca> wrote in message
news:04_Sf.18038$ng.720840@news20.bellglobal.com...
>
> "Graham" <graham@letsgouk.com> wrote in message news:441c6009.0@entanet...
>> Outlook Redemption is a COM object that works around the security issues
>> of Outlook 2002+, and I wanna use this in a Perl script that works with
>> Outlook in sending email. My problem is that I don't know VB well enough
>> to translate the sample VB code for 'Send email bypassing the security
>> prompt' at the following address
>> http://www.dimastr.com/redemption/objects.htm#examples , into Perl.
>>
>> Can anyone help?
>
> This should get you started: (untested, of course, as I don't have
> Redemption)
>
> use Win32::OLE;
>
> my $Application = new Win32::OLE('Outlook.Application');
>
> my $oItem = $Application->CreateItem(0);
>
> my $SafeItem = new Win32::OLE('Redemption.SafeMailItem');
>
> $SafeItem->{'Item'} = $oItem;
>
>
> Translating the rest on your own shouldn't be too much to ask.
>
> Matt
>
------------------------------
Date: Sat, 18 Mar 2006 17:16:05 -0800
From: robic0
Subject: Re: Using a variable to call a sub-routine...
Message-Id: <364p12pjkh84j1bug2k5velfm2in5n2o51@4ax.com>
On Wed, 15 Mar 2006 23:54:49 GMT, "Big Jay" <jbredice@hotmail.com> wrote:
>Hi all,
>
>I'm trying to call a sub-routine based on the value of a variable.
>
>More specifically, I'm developing a menu system, where each level of the
>menu has it's own sub-routine, but for a generalized "back" function, I'm
>trying to call the last menu based on a variable, something like:
>
>$lastMenu = apiMenu;
>
>&$lastMenu; #I want this to be the same as calling &apiMenu
>
>Does this make any sense?
>
>Any help is greatly appreciated!
>
I guess I'll try to appretiate your post one more time, being in a
diffrent frame of mind.
Like I said, don't really know *what* type of menu system your talking about,
the availability of options on each level, saved frames, and so forth..
It does not appear you want anything other than a level scalar array of hashes
that contain sub references to handlers that know and where it is and can react,
based on some interpreted *key* selected via keyboard (?) input.
The sub's probably have identical parameters, or passed a constant structure
from which more sub/level, individual data can be processed. This is not easy.
Also, you may want to save state of the data previously entered if its revisited.
Likewise, you may want to carry around a master data structure that has been sucessfully
populated from previous visits as you progress down the menu tree towards the
final *SUBMIT/SAVE* conclusion. Again not easy. But entirely possible.
Consider that its a windows menu tree, where you are calling successive dialog's,
populating a master data structure along the way. A cancel out of a single dialog
invalidates *only* a portion of the master that you are populating. Consecutive
<backspace> could load previously entered data (incase the user just wanted to
change one item), but would probably invalidate the forward data if a backward
change deems it so.
............
One way is:
# in key form, @menutext_hasharrays contains "Text" to display and
# corresponding index to the selected @m(x) that is current.
@menutext_hasharrays = (
# main
{'N' => [1, "'N'ext"], 'Q' => [3, "'Q'uit"],
'A' => [4, "'A'item"], 'B' => [5, "'B'item"], 'C' => [6, "'C'item"] },
# level 1
{'N' => [1, "'N'ext"], 'B' => [2, "'B'ack"], 'Q' => [3, "'Q'uit"],
'A' => [4, "'A'item"], 'B' => [5, "'B'item"], 'C' => [6, "'C'item"] },
# level 2
{'N' => [1, "'N'ext"], 'B' => [2, "'B'ack"], 'Q' => [3, "'Q'uit"],
'A' => [4, "'A'item"], 'B' => [5, "'B'item"] },
# level 3
{'N' => [1, "'N'ext"], 'B' => [2, "'B'ack"], 'Q' => [3, "'Q'uit"],
'A' => [4, "'A'item"], 'B' => [5, "'B'item"], 'C' => [6, "'C'item"] },
);
# @m(x) handler array's:
# index 0 always equals index to @menutext_hasharrays (for menu display options and
# holds indexes to handlers at the current level, this so a particular item need not
# be in order when displaying the option),
# index 1 always equals ref to "next" @m(x) array
# index 2 always equals ref to "last" @m(x) array (if back)
# index 3 always equals ref to "quit", can be custom specific to a menu ..
# index 4 - ... are the specific handlers for this menu level
# indexes > 2 are handlers
@mm = (0, \@m1, undef, \&quit);
@m1 = (1, \@m2, \@mm, \$quit, \&h11, \&h12, \&h13);
@m2 = (2, \@m3, \@m1, \$quit, \&h21, \&h22);
@m3 = (3, undef, \@m2, \$quit, \&h31, \&h32, \&h33);
.........
The rest is left as an exercise.
You have to read between the lines. All values in the anom array's in
@menutext_hasharrays are arbitrary except for the indexes into the @m(x) handler array's
The concept is driven from the knowledge of initially starting with a known @m(x) array
by default.
This is one of several ways to implement this in Perl, depending on your perspective.
There is always a *static* degree to this process. It *always* has some degree of
indirection, ie: building tables of references to others.
This is for character driven menu's. There's another way which is a derritive of this
that involves further indirection might drive you insane to even think about it.
Or that I don't care to explain...
The graphic method and the issues discussed above all can work depending on what wants
to be accomplished.
Hey, I'm not getting paid for this shit....
robic0
------------------------------
Date: Sat, 18 Mar 2006 17:34:15 -0800
From: robic0
Subject: Re: Using a variable to call a sub-routine...
Message-Id: <iacp125k3iph4o0p9p9ltmgmso82s3smmu@4ax.com>
On Wed, 15 Mar 2006 23:31:52 -0500, Uri Guttman <uri@stemsystems.com> wrote:
>>>>>> "r" == robic0 <robic0> writes:
>
> r> On Wed, 15 Mar 2006 20:15:09 -0600, Tad McClellan <tadmc@augustmail.com> wrote:
> >> That is what is known as a "dispatch table".
> >>
> r> Maybe Tad, you can explain "dispatch table" a phrase used
> r> exclusively for NT drivers...
> r> Expanding out of Perl Tad?
>
>hmm, did your addlepated brain ever allow the possibility that the term
^^^^^^^^^^
hmm, 10 whole letters in that word, but begins with 'A'... no biggie!
>dispatch table is slightly older than nt?
Yeah? NT dates back to 3.50, how slightly?
> and the concept is even older
>than that?
What a concept!! Dispatch is a word dating back to Greece.
How far back u gonna go dudet!
> you really think that redmond both invented the concept and
>the term?
They "strong typed" the phrase to driver development.
> i was coding dispatch tables way before uncle bill robbed his
>first billion. but you won't understand this anymore than you know why
>the sky is blue.
>
Your idea of a dispatch table is an "array of function pointers".
I guess the point on your head is a "dispatch table"!
>
>how do you function in the real world with such delusions and
>miscomprehensions? but your alter ego rm will soon pop in. ever notice
>how the two of you are never seen at the same time?
>
>uri
Its really hard to tell the level knowledge in this group.
Seems the regulars here make new shit up every day. Don't confuse
the word 'regulars' with anone remotely connected to intelligence.
Back in the day asshole, I wrote thousand of handlers in a program,
the address of which, each took up a space in an array of function
pointers (can you show me that 'C' prototype), the index
of which were imbedded into packets.
You don't know your asshole from your elbow.
Do the world a favor and stay off the fuckin inet!!
robic0
------------------------------
Date: Sat, 18 Mar 2006 19:07:55 GMT
From: markhobley@hotpop.deletethisbit.com (Mark Hobley)
Subject: vec - a misunderstanding
Message-Id: <8b2ue3-tmt.ln1@neptune.markhobley.yi.org>
Keywords: perl,vec,function,how,help,documentation,use,usage
I am trying to understand how the vec function is used.
I have produced the following code, but the behaviour is not as expected.
$binstring = '@' ; # 01000000 binary ascii code
print vec($binstring,0,1); # returns 0, the binary value of bits 0 and 1
vec($binstring,0,1) = 3; # bits 0 and 1
print $binstring; # returns A, I am expecting C (binary ascii code 01000011)
vec($binstring,2,1) = 3; # bits 2 and 3
print $binstring; # returns E, I am expecting O (binary ascii code 01001111)
Documentation tells me that vec has the syntax:
vec EXPR, OFFSET, BITS
where BITS is a power of 2 from 1 to 32.
I presumed offset of zero would give me the leftmost (most significant) bit.
It actually gives me the rightmost bit.
Is this expected behaviour?
The number of bits is a power of two ranging from 1 to 32. Presumably this
means that minimum element size (BITS = 1) is 2^1 = 2 bits, and therefore I
cannot use single bit elements.
Is it correct that if BITS = 1, my elements should be 2 bits wide?
I presumed that the offset was in number of elements, so an offset of 1, would
point to bits two and three. It actually appears to point to bit 1, which is
part of the first element.
Presumably then, offset is in number of bits, not number of elements. Is this
correct?
When I set the value of my element to three, indicating both bits set to 1, I
only appear to be getting a single bit set.
What is going on here?
--
Mark Hobley
393 Quinton Road West
QUINTON
Birmingham
B32 1QE
Telephone: (0121) 247 1596
International: 0044 121 247 1596
Email: markhobley at hotpop dot donottypethisbit com
http://markhobley.yi.org/
------------------------------
Date: 18 Mar 2006 19:32:12 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: vec - a misunderstanding
Message-Id: <Xns978A89B28D193castleamber@130.133.1.4>
markhobley@hotpop.deletethisbit.com (Mark Hobley) wrote:
> The number of bits is a power of two ranging from 1 to 32. Presumably
> this means that minimum element size (BITS = 1) is 2^1 = 2 bits, and
> therefore I cannot use single bit elements.
Yes you can, but you can't use 3 or 5, the *number* has to be a power of
two, so 2^0, 2^1, 2^2, 2^3, 2^4.
> Is it correct that if BITS = 1, my elements should be 2 bits wide?
No, it's 1, but you can't use 3 bits wide, since 3 is not a power of 2 (if
I read the documentation correctly).
--
John Bokma Freelance software developer
&
Experienced Perl programmer: http://castleamber.com/
------------------------------
Date: 18 Mar 2006 22:12:41 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: vec - a misunderstanding
Message-Id: <483eupFi5mvtU1@news.dfncis.de>
Keywords: perl,vec,function,how,help,documentation,use,usage
[newsgroups trimmed]
Mark Hobley <markhobley@hotpop.deletethisbit.com> wrote in comp.lang.perl.misc:
> I am trying to understand how the vec function is used.
>
> I have produced the following code, but the behaviour is not as expected.
>
> $binstring = '@' ; # 01000000 binary ascii code
> print vec($binstring,0,1); # returns 0, the binary value of bits 0 and 1
> vec($binstring,0,1) = 3; # bits 0 and 1
> print $binstring; # returns A, I am expecting C (binary ascii code 01000011)
> vec($binstring,2,1) = 3; # bits 2 and 3
> print $binstring; # returns E, I am expecting O (binary ascii code 01001111)
>
> Documentation tells me that vec has the syntax:
>
> vec EXPR, OFFSET, BITS
>
> where BITS is a power of 2 from 1 to 32.
Quite so, a power of two, not the exponent of two, as you appear to believe.
> I presumed offset of zero would give me the leftmost (most significant) bit.
> It actually gives me the rightmost bit.
>
> Is this expected behaviour?
Yes. Bit strings are numbered least significant bit first.
[misunderstandings snipped]
With vec, it is useful to look at the third argument (BITS) first.
It determines in chunks of what size the string is divided. As the
description says, only powers of 2 (1, 2, 4, ... 32) are allowed, 64
too if the architecture supports it. The BITS gives the number of
bits in each chunk. The value of OFFSET is counted in these units,
it is the 0-based number of the chunk to retrieve.
Anno
--
If you want to post a followup via groups.google.com, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers.
------------------------------
Date: 18 Mar 2006 20:52:59 GMT
From: <corff@zedat.fu-berlin.de>
Subject: Re: XML::Simple and utf8 woes
Message-Id: <483a9bFi74t2U1@uni-berlin.de>
ngoc <ngoc@yahoo.com> wrote:
: I tried your code in Windows XP. It gives utf-8 output.
Really? I'll have to try tomorrow, don't have an XP box here right now.
: RootName => 'unicode here', only the output of rootname is changed
: (manual fix will help), other parts are in utf-8.
Sounds interesting, I'll try this one, too.
: 1. To save your perl program in utf-8 encoding.
Doesn't make sense, I write everything in utf-8 environment. Did you
notice the a-umlaut and u-caret in the data?
: 2. This step in theory is not necessary. But maybe it helps
: open my $fh, '>:encoding(UTF-8)', $path or die "open($path): $!";
: XMLout($ref, OutputFile => $fh);
I had tried this already before posting, but to no avail.
: 3. Try in Windows XP or 2000 environment to see it is different
Tomorrow.
Thanks, Oliver.
--
Dr. Oliver Corff e-mail: corff@zedat.fu-berlin.de
------------------------------
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.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 9065
***************************************