[26007] in Perl-Users-Digest
Perl-Users Digest, Issue: 8225 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jul 4 09:05:29 2005
Date: Mon, 4 Jul 2005 06:05:06 -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 Mon, 4 Jul 2005 Volume: 10 Number: 8225
Today's topics:
Re: "Variable ... is not imported..." using an import (Volker Nicolai)
Re: "Variable ... is not imported..." using an import <pilkowsk@informatik.uni-marburg.de>
Re: ActiveState license: I can't distribute perl with m <ThomasKratz@REMOVEwebCAPS.de>
Gtk2 radio buttons problem <no@reply.invalid>
Gtk2 radio buttons problem <no@reply.invalid>
Help to get started with Module Games::QuizTaker <mstep@t-online.de>
Re: How do I implement open(FOO, "foo |") with fork()? (Anno Siegel)
IO::Socket using $! == EINTR <konrad@gaisler.com>
Re: scope question <joe@inwap.com>
Re: SOAP::Lite proxied <vek@station02.ohout.pharmapartners.nl>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 4 Jul 2005 00:43:44 -0700
From: vnick@freenet.de (Volker Nicolai)
Subject: Re: "Variable ... is not imported..." using an imported variable from a module
Message-Id: <de7655a5.0507032343.13a51fe1@posting.google.com>
Fabian Pilkowski <pilkowsk@informatik.uni-marburg.de> wrote in message news:<3il8viFm54j0U1@individual.net>...
> Well, you know you should use strict. But please do it in your modules
> too. After doing so, you have to declare your vars used in your module.
> But remember to declare each var you want to export with our() instead
> of my() -- better yet: each var you want to access from outside. Btw, I
> don't see a declaration of your package in that package. I'd write it as
> something like:
>
>
> #!/usr/local/bin/perl -w
>
> package import_pack;
> use strict;
> use Exporter;
>
> our @ISA = qw(Exporter);
> our @EXPORT = qw(%p_hash);
>
> our %p_hash = (
> x => 123,
> y => 888,
> );
>
> 1;
> __END__
>
>
> >
> > If I run it without use stricts it is fine.
> > But if I use strict [...] I get:
> > Variable "%p_hash" is not imported at [...]
> > So where is the crux?
>
> I suggest to fix your module first. To understand the error message you
> have to know what use() is doing (see `perldoc -f use`). In short, it
> require()s the file and tries to call import() from the package. The
> latter is your problem. It's not possible to call import_pack->import()
> since there is no package called "import_pack". It is just part of the
> file's name and that is not what Perl uses as the default package name.
> The default package is called "main", and all you have done in the file
> "import_pack.pm" is done in package "main" though.
>
> Your script is running fine with stricts if you only add the declaration
> of the package's name in your package file. But familiarize yourself
> with using strict in your modules too. My example above shows you what
> you need for that. Btw, our() creates exactly the same type of globals
> as you would do without any declaration under "no strict", but it has
> the same scoping rules as a declaration with my(). Please read `perldoc
> -f our` for details.
>
> regards,
> fabian
Thanks to you too, Fabian, but why does it work after I have corrected the
error, Paul Lalli has found - this works with the old module, without
any name space change by package...
---------------------------------------
#!/usr/local/bin/perl
use strict;
use import_pack;
use vars qw(%p_hash);
print "P_HASH: $p_hash{x} , $p_hash{y}\n";
---------------------------------------
Please also see my answer to Paul (the name space change seem to not be
mandatory).
------------------------------
Date: Mon, 4 Jul 2005 10:34:51 +0200
From: Fabian Pilkowski <pilkowsk@informatik.uni-marburg.de>
Subject: Re: "Variable ... is not imported..." using an imported variable from a module
Message-Id: <3isajrFmuaptU1@individual.net>
* Volker Nicolai schrieb:
>
> Thanks to you too, Fabian, but why does it work after I have corrected the
> error, Paul Lalli has found - this works with the old module, without
> any name space change by package...
In Paul's version all the vars are settled in package "main", regardless
in which file they are declared.
>
> Please also see my answer to Paul (the name space change seem to not be
> mandatory).
It is mandatory if you really want to export something. That is what I
thought when reading your "use Exporter".
Please also see my answer there.
regards,
fabian
------------------------------
Date: Mon, 04 Jul 2005 11:29:45 +0200
From: Thomas Kratz <ThomasKratz@REMOVEwebCAPS.de>
Subject: Re: ActiveState license: I can't distribute perl with my Windows application?
Message-Id: <42c90189$0$11224$bb690d87@news.main-rheiner.de>
Arvin Portlock wrote:
[ redistribution and copyright issues with AS perl]
> Does anybody know whether ActiveState looks favorably on
> written requests for my type of distribution? Is my only other
> alternative to use perl2exe?
In addition to the other good advice about compiling your own perl for
windows, have a look at the PAR module to generate distributable
standalone executables from your perl script (like perl2exe but free).
Thomas
--
$/=$,,$_=<DATA>,s,(.*),$1,see;__END__
s,^(.*\043),,mg,@_=map{[split'']}split;{#>J~.>_an~>>e~......>r~
$_=$_[$%][$"];y,<~>^,-++-,?{$/=--$|?'"':#..u.t.^.o.P.r.>ha~.e..
'%',s,(.),\$$/$1=1,,$;=$_}:/\w/?{y,_, ,,#..>s^~ht<._..._..c....
print}:y,.,,||last,,,,,,$_=$;;eval,redo}#.....>.e.r^.>l^..>k^.-
------------------------------
Date: Mon, 4 Jul 2005 11:28:16 +0200
From: "Sylvie" <no@reply.invalid>
Subject: Gtk2 radio buttons problem
Message-Id: <daavmo$1n0t$2@textnews.euro.net>
Hi group,
I try to use radio buttons in my Gtk2 perl script so that when the user
clicks one a variable changes of value and a sub routine is called. This is
my code:
my $button1 = Gtk2::RadioButton->new(undef,"Radio Button 1");
$button1->signal_connect("toggled" => sub { $value = "button1";
sighandler(); },"Radio Button 1" );
$vbox->pack_start($button1, TRUE, TRUE, 0);
$button1->set_active(TRUE);
$button1->show;
my @group = $button1->get_group;
my $button2 = Gtk2::RadioButton->new_with_label(@group,"Radio Button 1");
$button2->signal_connect("toggled" => sub {$value = "button2";
sighandler(); },"Radio Button 1" );
$vbox->pack_start($button2, TRUE, TRUE, 0);
$button2->show;
sub sighandler {
print "DEBUG: value = $value\n";
}
The problem I'm having is that everytime a new radio button is toggled, the
sighandler gets called twice: once for the old value of the radio button and
one for the new value. So if I start the script and click on Radio Button 2
it prints:
DEBUG: value = Radio Button 1
DEBUG: value = Radio Button 2
If I now change back to Radio Button 1 I see:
DEBUG: value = Radio Button 2
DEBUG: value = Radio Button 1
I tried naming the buttons the same ($button1 -> $button and $button2 ->
$button) but that didn't matter. What am I doing wrong and how can I fix
this?
Thanks in advance, Sylvie.
------------------------------
Date: Mon, 4 Jul 2005 11:25:57 +0200
From: "Sylvie" <no@reply.invalid>
Subject: Gtk2 radio buttons problem
Message-Id: <daavmn$1n0t$1@textnews.euro.net>
Hi group,
I try to use radio buttons in my Gtk2 perl script so that when the user
clicks one a variable changes of value and a sub routine is called. This is
my code:
my $button1 = Gtk2::RadioButton->new(undef,"Radio Button 1");
$button1->signal_connect("toggled" => sub { $value = "button1";
sighandler(); },"Radio Button 1" );
$vbox->pack_start($button1, TRUE, TRUE, 0);
$button1->set_active(TRUE);
$button1->show;
my @group = $button1->get_group;
my $button2 = Gtk2::RadioButton->new_with_label(@group,"Radio Button 1");
$button2->signal_connect("toggled" => sub {$value = "button2";
sighandler(); },"Radio Button 1" );
$vbox->pack_start($button2, TRUE, TRUE, 0);
$button2->show;
sub sighandler {
print "DEBUG: value = $value\n";
}
The problem I'm having is that everytime a new radio button is toggled, the
sighandler gets called twice: once for the old value of the radio button and
one for the new value. So if I start the script and click on Radio Button 2
it prints:
DEBUG: value = Radio Button 1
DEBUG: value = Radio Button 2
If I now change back to Radio Button 1 I see:
DEBUG: value = Radio Button 2
DEBUG: value = Radio Button 1
I tried naming the buttons the same ($button1 -> $button and $button2 ->
$button) but that didn't matter. What am I doing wrong and how can I fix
this?
Thanks in advance, Sylvie.
------------------------------
Date: Mon, 04 Jul 2005 14:12:33 +0200
From: Marek Stepanek <mstep@t-online.de>
Subject: Help to get started with Module Games::QuizTaker
Message-Id: <BEEEF451.145BF%mstep@t-online.de>
Hello all,
I am a newbie in Perl, I am able to write my Perl filters, and simple
programs of text manipulating. But now I am looking for something, which
puts in a bit complex learning stuff for an examination with questions and
answers. I tested on my Macintosh several "Vocabulary Trainers" ( UniLingua,
Kurisu ) but they are far too primitive. I need something more flexible, for
example multiple choice answers or one question with at least five right
answers out of seven ...
So I decided to test a Perl Mudule Games::QuizTaker
But I am unable to understand the manual % perldoc Games::QuizTaker
Is here perhaps somebody who could help me to make me start ? Or perhaps
suggest an other Module for such kind of learning help ? I would be really
very grateful for any help.
Thank you and greetings from Munich
marek
--
______________________________________________________________________
___PODIUM_INTERNATIONAL_//_the_embassy_for_talented_young_musicians___
______ Marek_Stepanek mstep_[at]_PodiumInternational_[dot]_org ______
_________________ http://www.PodiumInternational.org _________________
______________________________________________________________________
------------------------------
Date: 4 Jul 2005 07:42:13 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: How do I implement open(FOO, "foo |") with fork()?
Message-Id: <daap8l$k4m$1@mamenchi.zrz.TU-Berlin.DE>
Christian Winter <thepoet_nospam@arcor.de> wrote in comp.lang.perl.misc:
> Anno Siegel wrote:
> > Christian Winter <thepoet_nospam@arcor.de> wrote in comp.lang.perl.misc:
> >
> >>Anno Siegel wrote:
> >>
> >>> pipe R, W;
> >>> defined( my $pid = fork) or die "fork: $!";
> >>> if ( $pid ) {
> >>> close W;
> >>> print while <R>;
> >>> } else {
> >>> close R;
> >>
> >>You accidentially left out the vital
> >> close STDOUT;
> >>here.
> >
> >
> > Opening a file handle implies closing of the current one if it is open.
> > When would explicit close of STDOUT make a difference?
>
> Even though "perldoc perlopen" only mentions that for
ITYM "perldoc -f open".
> in-memory files (i.e. scalars) i have experienced that
> this also applies to pipes on my platform (testet here
> on ActiveState, v5.8.0 built for MSWin32-x86-multi-thread).
> If I omit the explicit close, the program will run into
> a deadlock.
That would be a bug in Perl then. Closing a filehandle before
re-opening it is a fundamental property of Perl's open (under
Unix, it maps directly to the corresponding property of freopen()).
I never noticed the exception with in-memory files.
Anno
------------------------------
Date: Mon, 04 Jul 2005 10:19:36 GMT
From: Konrad Eisele <konrad@gaisler.com>
Subject: IO::Socket using $! == EINTR
Message-Id: <Y28ye.141437$dP1.494604@newsc.telia.net>
Does anyone know a IO::Socket module that handles
signal interrupt on blocking calls correctly (i.e.
when using IO::Socket with Curses and receiving xterm
resize). IO::Socket's filehandler will get invalid
when returning from a interrupted recv call. It should
check $! == EINTR but doesn't.
-- Konrad
------------------------------
Date: Mon, 04 Jul 2005 00:28:53 -0700
From: Joe Smith <joe@inwap.com>
Subject: Re: scope question
Message-Id: <36WdnUZQKqnfeFXfRVn-sw@comcast.com>
Richard Trahan wrote:
> Consider the following code:
>
> use strict;
> {
> my $x = 5;
> our $sr = sub { print "$x\n"; };
> }
> &$sr;
With 'our', the value is global but the permission to access
it is scoped. It would work if you replace the last line with
{
our $sr;
&$sr;
}
-Joe
------------------------------
Date: 04 Jul 2005 07:36:48 GMT
From: Villy Kruse <vek@station02.ohout.pharmapartners.nl>
Subject: Re: SOAP::Lite proxied
Message-Id: <slrndchpog.pj.vek@station02.ohout.pharmapartners.nl>
On Sat, 02 Jul 2005 01:19:29 +0100,
Big and Blue <No_4@dsl.pipex.com> wrote:
> Ian Wilson wrote:
>>
>> I hadn't found anywhere in that document where it explains how to set
>> the credentials required by the proxy for authorization - i.e. a user-ID
>> and password (for the HTTP proxy, not the endpoint).
>
> I have problems trying to remember what to do here too.
>
> And, at least with LWP, if not with SOAP (I don't know), there is a
> difference between using the function calls to set a proxy and setting
> environment variables. It applies to HTTPS calls. One will end up doing a
> GET and the other a CONNECT through the proxy (IIRC I have to set the
> environment variables in order to use CONNECT, which is what is needed for
> teh proxy I use). And I've never found any documentations in the modules
> there as to the difference and the effect. Discovered by trial, error some
> network snooping and a helpful proxy admin who made some comments on the
> log entries I generated.
>
As SOAP::Lite is using LWP, whatever applies to LWP also aplies to
SOAP::Lite. You also need Crypt::SSLeay for https proxy, even though
you can use Net::SSLeay when you don't need to use a proxy server.
See tha documentation for Crypt::SSLeay.
It can be confusing, though, that in the SOAP terminology the proxy
server is the actual web server and not the proxy server you will
use to reach the web server.
Villy
------------------------------
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 8225
***************************************