Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

When magic goes awry - Tk and OLE mysterious problem

by John M. Dlugosz (Monsignor)
on Nov 21, 2002 at 23:13 UTC ( #214952=perlquestion: print w/ replies, xml ) Need Help??
John M. Dlugosz has asked for the wisdom of the Perl Monks concerning the following question:

This took some figuring, let me tell you!

Here's what I figured out:

A statement like

my $database= new Win32::OLE:: "SourceSafe"; $database->Open ($name);
fails if the variable $name is bound to a Tk text widget. Just making a local copy of the value and using that copy works fine!

My guess is that the XS code behind the OLE method generator is assuming plain scalars and doesn't like tied variables.



Comment on When magic goes awry - Tk and OLE mysterious problem
Download Code
Replies are listed 'Best First'.
Re: When magic goes awry - Tk and OLE mysterious problem
by theorbtwo (Prior) on Nov 21, 2002 at 23:29 UTC

    Another workaround would probably be to force stringification (or numification, if approprate). That is, do $database->Open ("$name");.

    Warning: Unless otherwise stated, code is untested. Do not use without understanding. Code is posted in the hopes it is useful, but without warranty. All copyrights are relinquished into the public domain unless otherwise stated. I am not an angel. I am capable of error, and err on a fairly regular basis. If I made a mistake, please let me know (such as by replying to this node).

Re: When magic goes awry - Tk and OLE mysterious problem
by mpeppler (Vicar) on Nov 22, 2002 at 01:23 UTC
    There are lots of gotchas with magic variables when writing XS code.

    My earliest exposure was when checking for a number (via SvNOK(sv)) and getting a false return - because the perl variable was tainted...


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://214952]
Approved by Mr. Muskrat
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (7)
As of 2015-11-26 01:31 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (695 votes), past polls