[26047] in Perl-Users-Digest
Perl-Users Digest, Issue: 8255 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jul 16 20:48:25 2005
Date: Fri, 15 Jul 2005 21:05:05 -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 Fri, 15 Jul 2005 Volume: 10 Number: 8255
Today's topics:
Re: PAR 0.89 + Socket + ASP 5.8.7 = PL_memory_wrap <ron@savage.net.au>
Apache::Session simple test script <""alexjaquet\"@[no spam]msn.com">
Re: Apache::Session simple test script <""alexjaquet\"@[no spam]msn.com">
Re: Apache::Session simple test script <""alexjaquet\"@[no spam]msn.com">
Re: Can't find module <sisyphus1@nomail.afraid.org>
Re: Can't find module <sisyphus1@nomail.afraid.org>
Re: PAR 0.89 + Socket + ASP 5.8.7 = PL_memory_wrap <john@castleamber.com>
Re: PAR 0.89 + Socket + ASP 5.8.7 = PL_memory_wrap <sisyphus1@nomail.afraid.org>
Session question <""alexjaquet\"@[no spam]msn.com">
Turning off variable interpolation in strings <jgibson@mail.arc.nasa.gov>
Re: Turning off variable interpolation in strings <sisyphus1@nomail.afraid.org>
Re: Writing directly to system memory <rm@nospam.popeslane.clara.co.uk>
Re: Writing directly to system memory <sisyphus1@nomail.afraid.org>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 16 Jul 2005 11:54:30 +1000
From: Ron Savage <ron@savage.net.au>
Subject: Re: PAR 0.89 + Socket + ASP 5.8.7 = PL_memory_wrap
Message-Id: <2005716115430.046104@ron>
On Sat, 16 Jul 2005 11:17:47 +1000, John Bokma wrote:
Hi John
> Note (probably harmless): No library found for odbc32.lib Note
> (probably harmless): No library found for odbccp32.lib Note
> (probably harmless): No library found for msvcrt.lib
>
> the first two sound harmless to me. Can't remember what msvcrt.lib
> does (IIRC GUI related?)
msvcrt =3D> MS Visual C++ Run Time, I believe. I.e. fundamental!
------------------------------
Date: Fri, 15 Jul 2005 21:29:58 +0200
From: Alexandre Jaquet <""alexjaquet\"@[no spam]msn.com">
Subject: Apache::Session simple test script
Message-Id: <42d80ebe$0$1163$5402220f@news.sunrise.ch>
Hi I make a simple test script to work with
Apache::Session:MySQL
The problem is when I try to take back informations from
db the server didn't response.
usage :
http://localhost/cgi-bin/session.pl?action=login
http://localhost/cgi-bin/session.pl?action=test
http://localhost/cgi-bin/session.pl?action=test&session_id=[id]
#!/usr/bin/perl -w
use strict;
use Apache::Session::MySQL;
my %session;
my $session_id;
local our $query = CGI->new ;
my $action = $query->param('action');
if ($action eq "login") {
login();
}elsif ($action eq "test") {
test();
}
sub login {
tie %session, 'Apache::Session::MySQL', undef,
{
DataSource => 'dbi:mysql:recordz:localhost:sessions',
UserName => 'alexj',
Password => 'xx',
LockDataSource => 'dbi:mysql:recordz:localhost:sessions',
LockUserName => 'alexj',
LockPassword => 'xx'
};
$session{user} = "test";
$session_id = $session{_session_id};
print "Content-type: text/html\n\n";
print "New session created : $session_id<br/>";
}
sub test {
my $session_id = $query->param("session_id");
if ($session_id) {
tie %session, 'Apache::Session::MySQL', $session_id,
{
DataSource => 'dbi:mysql:recordz:localhost:sessions',
UserName => 'alexj',
Password => 'xx',
LockDataSource => 'dbi:mysql:recordz:localhost:sessions',
LockUserName => 'alexj',
LockPassword => 'xxx'
};
print "Content-type: text/html\n\n";
print "Session retrieved : $session_id<br/>";
my $user = $session{user};
print "User retrieved : $user<br/>";
} else {
print "Content-type: text/html\n\n";
print "redirect login <br/>";
login();
}
}
thanks for your help
------------------------------
Date: Fri, 15 Jul 2005 21:46:50 +0200
From: Alexandre Jaquet <""alexjaquet\"@[no spam]msn.com">
Subject: Re: Apache::Session simple test script
Message-Id: <42d812b2$0$1161$5402220f@news.sunrise.ch>
Alexandre Jaquet > a écrit :
> Hi I make a simple test script to work with
> Apache::Session:MySQL
>
> The problem is when I try to take back informations from
> db the server didn't response.
>
>
> usage :
>
> http://localhost/cgi-bin/session.pl?action=login
> http://localhost/cgi-bin/session.pl?action=test
> http://localhost/cgi-bin/session.pl?action=test&session_id=[id]
>
> #!/usr/bin/perl -w
> use strict;
> use Apache::Session::MySQL;
>
> my %session;
> my $session_id;
>
> local our $query = CGI->new ;
>
> my $action = $query->param('action');
>
> if ($action eq "login") {
> login();
> }elsif ($action eq "test") {
> test();
> }
>
> sub login {
>
> tie %session, 'Apache::Session::MySQL', undef,
> {
> DataSource => 'dbi:mysql:recordz:localhost:sessions',
> UserName => 'alexj',
> Password => 'xx',
> LockDataSource => 'dbi:mysql:recordz:localhost:sessions',
> LockUserName => 'alexj',
> LockPassword => 'xx'
> };
> $session{user} = "test";
> $session_id = $session{_session_id};
> print "Content-type: text/html\n\n";
> print "New session created : $session_id<br/>";
>
> }
>
> sub test {
> my $session_id = $query->param("session_id");
> if ($session_id) {
> tie %session, 'Apache::Session::MySQL', $session_id,
> {
> DataSource => 'dbi:mysql:recordz:localhost:sessions',
> UserName => 'alexj',
> Password => 'xx',
> LockDataSource => 'dbi:mysql:recordz:localhost:sessions',
> LockUserName => 'alexj',
> LockPassword => 'xxx'
> };
> print "Content-type: text/html\n\n";
> print "Session retrieved : $session_id<br/>";
> my $user = $session{user};
> print "User retrieved : $user<br/>";
> } else {
> print "Content-type: text/html\n\n";
> print "redirect login <br/>";
> login();
> }
> }
>
>
> thanks for your help
I try to add a db handler :
but I got error : Can't connect to datasource no database driver
specified :s
#!/usr/bin/perl -w
use strict;
use Apache::Session::MySQL;
local our %session;
local our $session_id;
local our $query = CGI->new ;
my $dbh = DBI->connect( "DBI:mysql:recordz:localhost", "xx", "xx");
my $action = $query->param('action');
if ($action eq "login") {
login();
}elsif ($action eq "test") {
test();
}
sub login {
tie %session, 'Apache::Session::MySQL', undef,
{
Handle => $dbh
};
$session{user} = "test";
$session_id = $session{_session_id};
print "Content-type: text/html\n\n";
print "New session created : $session_id<br/>";
}
sub test {
my $session_id = $query->param("session_id");
if ($session_id) {
tie %session, 'Apache::Session::MySQL', $session_id,
{
Handle => $dbh
};
print "Content-type: text/html\n\n";
print "Session retrieved : $session_id<br/>";
} else {
print "Content-type: text/html\n\n";
print "redirect <br/>";
login();
}
}
------------------------------
Date: Fri, 15 Jul 2005 22:06:48 +0200
From: Alexandre Jaquet <""alexjaquet\"@[no spam]msn.com">
Subject: Re: Apache::Session simple test script
Message-Id: <42d8175f$0$1145$5402220f@news.sunrise.ch>
Alexandre Jaquet > a écrit :
> Alexandre Jaquet > a écrit :
>
>> Hi I make a simple test script to work with
>> Apache::Session:MySQL
>>
>> The problem is when I try to take back informations from
>> db the server didn't response.
>>
>>
>> usage :
>>
>> http://localhost/cgi-bin/session.pl?action=login
>> http://localhost/cgi-bin/session.pl?action=test
>> http://localhost/cgi-bin/session.pl?action=test&session_id=[id]
>>
>> #!/usr/bin/perl -w
>> use strict;
>> use Apache::Session::MySQL;
>>
>> my %session;
>> my $session_id;
>>
>> local our $query = CGI->new ;
>>
>> my $action = $query->param('action');
>>
>> if ($action eq "login") {
>> login();
>> }elsif ($action eq "test") {
>> test();
>> }
>>
>> sub login {
>>
>> tie %session, 'Apache::Session::MySQL', undef,
>> {
>> DataSource => 'dbi:mysql:recordz:localhost:sessions',
>> UserName => 'alexj',
>> Password => 'xx',
>> LockDataSource => 'dbi:mysql:recordz:localhost:sessions',
>> LockUserName => 'alexj',
>> LockPassword => 'xx'
>> };
>> $session{user} = "test";
>> $session_id = $session{_session_id};
>> print "Content-type: text/html\n\n";
>> print "New session created : $session_id<br/>";
>>
>> }
>>
>> sub test {
>> my $session_id = $query->param("session_id");
>> if ($session_id) {
>> tie %session, 'Apache::Session::MySQL', $session_id,
>> {
>> DataSource => 'dbi:mysql:recordz:localhost:sessions',
>> UserName => 'alexj',
>> Password => 'xx',
>> LockDataSource => 'dbi:mysql:recordz:localhost:sessions',
>> LockUserName => 'alexj',
>> LockPassword => 'xxx'
>> };
>> print "Content-type: text/html\n\n";
>> print "Session retrieved : $session_id<br/>";
>> my $user = $session{user};
>> print "User retrieved : $user<br/>";
>> } else {
>> print "Content-type: text/html\n\n";
>> print "redirect login <br/>";
>> login();
>> }
>> }
>>
>>
>> thanks for your help
>
>
>
> I try to add a db handler :
>
> but I got error : Can't connect to datasource no database driver
> specified :s
>
> #!/usr/bin/perl -w
> use strict;
> use Apache::Session::MySQL;
>
> local our %session;
> local our $session_id;
>
> local our $query = CGI->new ;
> my $dbh = DBI->connect( "DBI:mysql:recordz:localhost", "xx", "xx");
>
> my $action = $query->param('action');
>
> if ($action eq "login") {
> login();
> }elsif ($action eq "test") {
> test();
> }
>
> sub login {
>
> tie %session, 'Apache::Session::MySQL', undef,
> {
> Handle => $dbh
> };
> $session{user} = "test";
> $session_id = $session{_session_id};
> print "Content-type: text/html\n\n";
> print "New session created : $session_id<br/>";
>
> }
>
> sub test {
> my $session_id = $query->param("session_id");
> if ($session_id) {
> tie %session, 'Apache::Session::MySQL', $session_id,
> {
> Handle => $dbh
> };
> print "Content-type: text/html\n\n";
> print "Session retrieved : $session_id<br/>";
> } else {
> print "Content-type: text/html\n\n";
> print "redirect <br/>";
> login();
> }
> }
>
>
Finally solved :
#!/usr/bin/perl -w
use strict;
use Apache::Session::MySQL;
local our %session;
local our $session_id;
local our $query = CGI->new ;
my $dbh = DBI->connect( "dbi:mysql:recordz:localhost", "alexj", "jaque21");
my $action = $query->param('action');
if ($action eq "login") {
login();
}elsif ($action eq "test") {
test();
}
sub login {
tie %session, 'Apache::Session::MySQL', undef,
{
Handle => $dbh,
LockHandle => $dbh
};
$session{user} = "test";
$session_id = $session{_session_id};
print "Content-type: text/html\n\n";
print "New session created : $session_id<br/>";
}
sub test {
my $session_id = $query->param("session_id");
if ($session_id) {
tie %session, 'Apache::Session::MySQL', $session_id,
{
Handle => $dbh,
LockHandle => $dbh
};
print "Content-type: text/html\n\n";
print "Session retrieved : $session_id<br/>";
} else {
print "Content-type: text/html\n\n";
print "redirect <br/>";
login();
}
}
------------------------------
Date: Sat, 16 Jul 2005 10:55:41 +1000
From: "Sisyphus" <sisyphus1@nomail.afraid.org>
Subject: Re: Can't find module
Message-Id: <42d85b30$0$26677$afc38c87@news.optusnet.com.au>
"Mark" <Mark.Fenbers@NOSPAMnoaa.gov> wrote in message
news:db8ibk$9ho$1@news.nems.noaa.gov...
> I wrote a Perl program which works fine on my Linux box, but not another
> one. It uses XML::Simple. When run on this other box, I get this error:
>
> XMLin() requires either XML::SAX or XML::Parser at /tmp/hg.pl line 342
>
> So this sounds like a simple module-location issue that is easy to
> solve, right? Not to me, anyway. The strange part is that when I print
> the contents of @INC, it shows me the expected PATH list and I have
> verified that XML/Parser.pm does indeed exist in at least one place in
> that PATH list. I don't understand why Perl can't find Parser.pm on
> this other box when it is clearly in the PATH. Could it be that
> XML/Simple.pm modifies @INC? If so, I couldn't find where... I tried
> moving XML/Parser.pm to other places in the PATH, including the same
> place that XML/Simple.pm exists, but still get the same error.
>
> Here is the contents of @INC that I print out:
>
> /usr/local/perl5.8.5/lib/site_perl/5.8.5/i686-linux
> /usr/local/perl5.8.5/lib/site_perl/5.8.5
> /usr/lib/perl5/vender_perl/5.8.0/i386-linux-thread-multi
> /usr/lib/perl5/vendor_perl/5.8.0
> /usr/local/perl5.8.5/lib/site_perl/5.8.5/ChartDirector
> /usr/local/perl/lib/site_perl/5.8.5/i686-linux
> /usr/local/perl/lib/site_perl/5.8.5
> /usr/local/perl/lib/site_perl
> /usr/local/perl/lib/5.8.5/i686-linux
> /usr/local/perl/lib/5.8.5
> /usr/local/perl/lib
> /usr/local/perl5.8.5/lib/5.8.5/i686-linux
> /usr/local/perl5.8.5/lib/5.8.5
> /usr/local/perl5.8.5/lib/site_perl
>
> Some places were added specifically to try to solve this problem, so
> there is more than there really needs to be for now... Parser.pm exists
> here:
> /usr/lib/perl5/vender_perl/5.8.0/i386-linux-thread-multi/XML/Parser.pm
>
> Any ideas?
A permissions issue, perhaps ? .... either with Parser.pm itself, or the
directory that houses it ?
Bear in mind that there's more to XML::Parser than just the .pm file.
Expat.so also needs to be locatable.
What happens when you run:
perl -MXML::Parser -le 'print OK'
Cheers,
Rob
------------------------------
Date: Sat, 16 Jul 2005 11:25:28 +1000
From: "Sisyphus" <sisyphus1@nomail.afraid.org>
Subject: Re: Can't find module
Message-Id: <42d8622b$0$13333$afc38c87@news.optusnet.com.au>
"Sisyphus" <sisyphus1@nomail.afraid.org> wrote
>
> What happens when you run:
>
> perl -MXML::Parser -le 'print OK'
>
I meant:
perl -MXML::Parser -le 'print "OK"'
Cheers,
Rob
------------------------------
Date: 16 Jul 2005 01:17:47 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: PAR 0.89 + Socket + ASP 5.8.7 = PL_memory_wrap
Message-Id: <Xns9694CE5255258castleamber@130.133.1.4>
"A. Sinan Unur" <1usa@llenroc.ude.invalid> wrote:
> John Bokma <john@castleamber.com> wrote in
[ Compiling PAR ]
>> You have helped me a lot. I am going to try to do the compile thing
>> tomorrow, and let you know if it works. Thanks!
>
> You are welcome. Let us know how that goes, I am curious.
Stuck at:
main.obj : error LNK2019: unresolved external symbol __imp__strnicmp
referenced in function ___findenv
(and several others...)
I installed the 2003 CLI stuff, and the SDK, but have no idea why I get
those (OK, there is a library missing, but which one, sounds quite basic).
I got in the beginning (perl Makefile.PL):
Note (probably harmless): No library found for odbc32.lib
Note (probably harmless): No library found for odbccp32.lib
Note (probably harmless): No library found for msvcrt.lib
the first two sound harmless to me. Can't remember what msvcrt.lib does
(IIRC GUI related?)
--
John Small Perl scripts: http://johnbokma.com/perl/
Perl programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html
------------------------------
Date: Sat, 16 Jul 2005 14:03:59 +1000
From: "Sisyphus" <sisyphus1@nomail.afraid.org>
Subject: Re: PAR 0.89 + Socket + ASP 5.8.7 = PL_memory_wrap
Message-Id: <42d88752$0$14755$afc38c87@news.optusnet.com.au>
"John Bokma" <john@castleamber.com>
>
> Stuck at:
>
> main.obj : error LNK2019: unresolved external symbol __imp__strnicmp
> referenced in function ___findenv
> (and several others...)
Looks like that will be fixed when you link to msvcrt.lib
>
> I installed the 2003 CLI stuff, and the SDK, but have no idea why I get
> those (OK, there is a library missing, but which one, sounds quite basic).
>
> I got in the beginning (perl Makefile.PL):
>
> Note (probably harmless): No library found for odbc32.lib
> Note (probably harmless): No library found for odbccp32.lib
Those 2 should be in the PlatformSDK/lib folder. Are they there ? (Doubt
that these 2 are needed anyway.)
> Note (probably harmless): No library found for msvcrt.lib
Should be in your VC7/lib folder. You'll need to link to it. (If you don't
have it, it will be available somewhere on the MS website.)
Cheers,
Rob
------------------------------
Date: Sat, 16 Jul 2005 04:40:02 +0200
From: Alexandre Jaquet <""alexjaquet\"@[no spam]msn.com">
Subject: Session question
Message-Id: <42d8738b$0$1159$5402220f@news.sunrise.ch>
does anybody know why when we create a new session and store
datas into it we have to do two queries to get values who cam from
the db
it's hard to explain here is what I say
1) go to
http://djmarketplace.no-ip.biz/cgi-bin/session.pl?action=login&user=test
2) copy and paste session id value to
http://djmarketplace.no-ip.biz/cgi-bin/session.pl?action=test&session_id=[id]
3) you will see you can get values stored into $session{user} only when
doing two or more post
and here is the code :
#!/usr/bin/perl -w
use strict;
use Apache::Session::MySQL;
my %session;
local our $session_id;
local our $query = CGI->new ;
my $dbh = DBI->connect( "dbi:mysql:test:localhost", "alexj", "dbasdf");
my $action = $query->param('action');
if ($action eq "login") {
login();
}elsif ($action eq "test") {
test();
}
sub login {
my $name = $query->param("user");
tie %session, 'Apache::Session::MySQL', undef,
{
Handle => $dbh,
LockHandle => $dbh
};
$session{user} = $name;
$session_id = $session{_session_id};
print "Content-type: text/html\n\n";
print "New session created : $session_id<br/>";
test2();
}
sub test {
my $session_id = $query->param("session_id");
if ($session_id) {
tie %session, 'Apache::Session::MySQL', $session_id,
{
Handle => $dbh,
LockHandle => $dbh
};
print "Content-type: text/html\n\n";
print "Session retrieved : $session_id<br/>";
my $user = $session{user};
print "user : $user";
} else {
print "Content-type: text/html\n\n";
print "redirect <br/>";
login();
}
}
sub test2 {
print "Content-type: text/html\n\n";
my $user = $session{user};
print "Value : $user<br/>";
}
thanks it's get my a bit crazy, I could not find why I'm getting this
kind of result
I'm using Apache/2.0.54 (Win32) mod_ssl/2.0.54 OpenSSL/0.9.7g PHP/4.3.11
mod_perl/2.0.1 Perl/v5.8.7
------------------------------
Date: Fri, 15 Jul 2005 17:21:10 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Turning off variable interpolation in strings
Message-Id: <150720051721103431%jgibson@mail.arc.nasa.gov>
I am writing test programs for a module I have written. Being thorough,
I want to generate lots of tests. Being lazy, I want to have Perl
generate the test programs for me, using the output results from the
module.
I ran into a problem turning off the interpolation of variables in a
double-quoted context. To explain: I have a variable in my test
generator holding the name of a variable in my test program, e.g.
my $var = '$x';
and I then want to use this variable in an output statement:
print "$var = 1;\n";
which should generate:
$x = 1;
Everything was OK until I used a hash reference:
my $var = '$hash';
print "$var->{key} = 'value';\n";
which I had hoped to output:
$hash->{key} = 'value';
The two lines in the test generator do not compile, since Perl looks
for the variable %var, which does not exist.
So I am trying to decide the best way (least typing and most readable)
to achieve this end. I have thought of 3 ways:
1. String concatenation:
print $var . "->{key} = 'value';\n";
2. String substitution:
$code = q( $var->{key} = 'value'; );
$code =~ s/\$var/$var/g;
print "$code\n";
3. String escapes:
print "$var\->{key} = 'value';\n";
Approach 1 requires the most typing and is not very readable. Approach
2 is OK, especially if I generate a lot of code lines and follow that
with a lot of substitutions using a hash of variables to be
substituted. Approach 3 looks good, but seems not too systematic, as I
could possibly miss escaping some character, and I would have make sure
I escape all the right characers for hashes ({), hash references (->),
and arrays ([), plus I am not sure this will always work.
Have I missed anything? Is there a simpler way to achieve this result?
Why don't I just use single-quote context? Because I want to do this in
a subroutine and generate differently named variables each time.
Here is a sample program illustrating these approaches, plus the use of
a here-document for output, which should be beneficial:
Jim 127% cat try.pl
#!/usr/bin/perl
use strict;
use warnings;
my $var1 = '$x1';
my $var2 = '$hashref1';
my $var3 = '$hash1';
my $var4 = '%hash1';
my $code1 =
"# code 2\n" .
"my $var1 = 1;\n" .
"my $var2 = { key => $var1 };\n" .
"my $var4 = ( key => $var1 );\n" .
"print \"" . $var2 . "->{key}\\n\";\n" .
"print \"" . $var3 . "{key}\\n\";\n";
print "$code1\n";
my $code2 = <<EOS;
# code 1
my $var1 = 2;
my $var2 = { key => $var1 };
my $var4 = ( key => $var1 );
print \"$var2\->{key}\\n\";
print \"$var3\{key}\\n\";
EOS
print "$code2\n";
my @lines1;
push( @lines1, <<EOS
# code 3
my $var1 = 3;
my $var2 = { key => $var1 };
my $var4 = ( key => $var1 );
print \"$var2\->{key}\\n\";
print \"$var3\{key}\\n\";
EOS
);
print join("\n",@lines1);
my @lines2;
push( @lines2, <<'EOS'
# code 4
my $var1 = 4;
my $var2 = { key => $var1 };
my $var4 = ( key => $var1 );
print "$var2->{key}\n";
print "$var3{key}\n";
EOS
);
my $code4 = join("\n",@lines2);
$code4 =~ s/\$var1/$var1/sg; # put this in a hash/loop later!
$code4 =~ s/\$var2/$var2/sg;
$code4 =~ s/\$var3/$var3/sg;
$code4 =~ s/\$var4/$var4/sg;
print $code4;
__END__
You can pipe the output of this program to perl:
Jim 128% try.pl | perl
1
1
2
2
3
3
4
4
Thanks.
----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
------------------------------
Date: Sat, 16 Jul 2005 11:04:05 +1000
From: "Sisyphus" <sisyphus1@nomail.afraid.org>
Subject: Re: Turning off variable interpolation in strings
Message-Id: <42d85d2c$0$13924$afc38c87@news.optusnet.com.au>
"Jim Gibson" <jgibson@mail.arc.nasa.gov>
>
> Everything was OK until I used a hash reference:
>
> my $var = '$hash';
> print "$var->{key} = 'value';\n";
>
> which I had hoped to output:
>
> $hash->{key} = 'value';
>
Try:
print "${var}->{key} = 'value';\n";
(Works for me :-)
Cheers,
Rob
------------------------------
Date: Sat, 16 Jul 2005 01:58:16 +0100
From: Rob <rm@nospam.popeslane.clara.co.uk>
Subject: Re: Writing directly to system memory
Message-Id: <X5ydnVonMPY0xkXfRVnyhA@pipex.net>
Sisyphus wrote:
> "Rob" <rm@nospam.popeslane.clara.co.uk> wrote:
>
>>If I have an SV that contains a real (valid) memory address I can read
>>bytes from that memory address using:
>>
>> unpack("I", unpack("P4", pack("L", $address)));
>
>>Is there a similar perl mechanism that would allow me to write bytes
>>back at that memory address?
>
> I really don't know [snip] (I hope someone will answer that
> question.)
Me too :-)
>
>>Background:
>>
>>Using Win32::GUI a number of callback functions for windows GUI events
>>pass the a win32api lParam value to the callback. For some events the
>>lParam value is a pointer to windows memory, and for some of those
>>events it is necessary to change parts of the structure pointed to in
>>order to get specific behaviour.
>>
>>I am currently using Win32::API and the win32api RtlMoveMemory function
>>to achieve what I need, but I would like to remove the Win32::API
>>dependency.
>>
>>Perhaps the best solution is to deal with this XS-side in the Win32::GUI
>>source?
>>
> In general, the simplest way to get away from Win32::API is to use
> Inline::C - which writes the xs code (from the C code that you've inlined),
> then compiles that code and executes your script. In terms of functionality,
> it's essentially the same as xs, but saves you the trouble of writing the xs
> file, the Makefile.PL, etc.
Right, but I really want to get away from all external dependencies -
particularly those that require the user to have a compiler.
> If you're interests are mainly based around Win32::GUI then it might be
> easier for you to hack at the Win32::GUI source than mess with Inline::C.
> It's difficult to tell from here :-)
I know my way round the Win32::GUI XS code pretty well (I'm a regular
contributor at the moment) - but Win32::GUI tends to have quite long
intervals between releases at the moment (although we're working on
getting that shorter), and I'm looking for a way that I can release some
code between releases without having to 'roll my own' distribution
(although this is looking like the best solution).
Thanks for your observations and suggestions,
Regards,
(another) Rob.
------------------------------
Date: Sat, 16 Jul 2005 11:57:18 +1000
From: "Sisyphus" <sisyphus1@nomail.afraid.org>
Subject: Re: Writing directly to system memory
Message-Id: <42d869a1$0$14485$afc38c87@news.optusnet.com.au>
"Rob" <rm@nospam.popeslane.clara.co.uk> wrote
> >
> >>Is there a similar perl mechanism that would allow me to write bytes
> >>back at that memory address?
> >
> > I really don't know [snip] (I hope someone will answer that
> > question.)
>
> Me too :-)
Not looking too promising ....
>
> I know my way round the Win32::GUI XS code pretty well (I'm a regular
> contributor at the moment) - but Win32::GUI tends to have quite long
> intervals between releases at the moment (although we're working on
> getting that shorter), and I'm looking for a way that I can release some
> code between releases without having to 'roll my own' distribution
> (although this is looking like the best solution).
>
Yeah - sounds like the best plan. Just produce 'development' releases in
between the 'stable' releases.
And it's probably easier and safer to modify the values at those specific
memory locations via xsubs, as opposed to pure-perl means (assuming that
such is even possible). It should also be safer and easier to *read* from
those locations using xsubs, rather than that unpack(unpack(pack()))
convolution - which is not portable, btw (though portability might not be an
issue since we're limited to Win32 in this case).
I guess you'll also release a ppm package for those who don't have a
compiler.
Cheers,
Rob
------------------------------
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 8255
***************************************