[31380] in Perl-Users-Digest
Perl-Users Digest, Issue: 2632 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Oct 12 14:09:48 2009
Date: Mon, 12 Oct 2009 11:09:14 -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, 12 Oct 2009 Volume: 11 Number: 2632
Today's topics:
Re: Advice on proper command to use <jurgenex@hotmail.com>
FAQ 6.18 Why don't word-boundary searches with "\b" wor <brian@theperlreview.com>
Re: Help needed with tough regular expression matching sln@netherlands.com
Re: Help needed with tough regular expression matching <ramon@conexus.net>
Re: Help needed with tough regular expression matching <tim@tim-landscheidt.de>
Re: Help needed with tough regular expression matching <ben@morrow.me.uk>
Re: Help needed with tough regular expression matching <jurgenex@hotmail.com>
Re: problem with perl + thread + extension <ben@morrow.me.uk>
Re: problem with perl + thread + extension <aotto1968@users.sourceforge.net>
Re: problem with perl + thread + extension <ben@morrow.me.uk>
Re: regexp assistance <ben@morrow.me.uk>
Re: regexp assistance <ben@morrow.me.uk>
Re: regexp assistance sln@netherlands.com
Re: regexp assistance sln@netherlands.com
Re: regexp assistance sln@netherlands.com
Re: time format +1 hour (Randal L. Schwartz)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 12 Oct 2009 09:09:45 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Advice on proper command to use
Message-Id: <otk6d5l17esj1rnu984nl1b97a09lgbrpf@4ax.com>
mike <mikaelpetterson@hotmail.com> wrote:
>On 12 Okt, 15:33, Jürgen Exner <jurge...@hotmail.com> wrote:
>> mike <mikaelpetter...@hotmail.com> wrote:
>> >I will be doing some file modification depending on certain conditions
>> >like:
>>
>> >If the file contains xxxDefault() then check if it has comments
>> >(preceeding it).
>> >If not add getXXX();
>> >if true then add getXXX() before comments.
>>
>> >I need some advice which command/s is/are most efficient to use.
>>
>> How would efficient commands help you if they don't solve your problem?
>
>Well I don't know what command is most appropriate for the task.
>Please advice me.
To the best of my knowledge there is no single command that would
accomplish what you are trying to do. Therefore most likely you will
have to write an algorithm, combining many different commands into a
program.
Some commands you might find useful are probably open(), index() or
m//, print(), and close().
You may also want to re-read 'perldoc -q insert'.
jue
------------------------------
Date: Mon, 12 Oct 2009 16:00:03 GMT
From: PerlFAQ Server <brian@theperlreview.com>
Subject: FAQ 6.18 Why don't word-boundary searches with "\b" work for me?
Message-Id: <7oIAm.88132$4t6.14535@newsfe06.iad>
This is an excerpt from the latest version perlfaq6.pod, which
comes with the standard Perl distribution. These postings aim to
reduce the number of repeated questions as well as allow the community
to review and update the answers. The latest version of the complete
perlfaq is at http://faq.perl.org .
--------------------------------------------------------------------
6.18: Why don't word-boundary searches with "\b" work for me?
(contributed by brian d foy)
Ensure that you know what \b really does: it's the boundary between a
word character, \w, and something that isn't a word character. That
thing that isn't a word character might be \W, but it can also be the
start or end of the string.
It's not (not!) the boundary between whitespace and non-whitespace, and
it's not the stuff between words we use to create sentences.
In regex speak, a word boundary (\b) is a "zero width assertion",
meaning that it doesn't represent a character in the string, but a
condition at a certain position.
For the regular expression, /\bPerl\b/, there has to be a word boundary
before the "P" and after the "l". As long as something other than a word
character precedes the "P" and succeeds the "l", the pattern will match.
These strings match /\bPerl\b/.
"Perl" # no word char before P or after l
"Perl " # same as previous (space is not a word char)
"'Perl'" # the ' char is not a word char
"Perl's" # no word char before P, non-word char after "l"
These strings do not match /\bPerl\b/.
"Perl_" # _ is a word char!
"Perler" # no word char before P, but one after l
You don't have to use \b to match words though. You can look for
non-word characters surrounded by word characters. These strings match
the pattern /\b'\b/.
"don't" # the ' char is surrounded by "n" and "t"
"qep'a'" # the ' char is surrounded by "p" and "a"
These strings do not match /\b'\b/.
"foo'" # there is no word char after non-word '
You can also use the complement of \b, \B, to specify that there should
not be a word boundary.
In the pattern /\Bam\B/, there must be a word character before the "a"
and after the "m". These patterns match /\Bam\B/:
"llama" # "am" surrounded by word chars
"Samuel" # same
These strings do not match /\Bam\B/
"Sam" # no word boundary before "a", but one after "m"
"I am Sam" # "am" surrounded by non-word chars
--------------------------------------------------------------------
The perlfaq-workers, a group of volunteers, maintain the perlfaq. They
are not necessarily experts in every domain where Perl might show up,
so please include as much information as possible and relevant in any
corrections. The perlfaq-workers also don't have access to every
operating system or platform, so please include relevant details for
corrections to examples that do not work on particular platforms.
Working code is greatly appreciated.
If you'd like to help maintain the perlfaq, see the details in
perlfaq.pod.
------------------------------
Date: Mon, 12 Oct 2009 08:52:14 -0700
From: sln@netherlands.com
Subject: Re: Help needed with tough regular expression matching
Message-Id: <vrj6d51u9f6tbkj361au9ehn9ltcf0aam2@4ax.com>
On Mon, 12 Oct 2009 07:48:54 -0700 (PDT), Ramon F Herrera <ramon@conexus.net> wrote:
>On Oct 12, 10:41 am, Ramon F Herrera <ra...@conexus.net> wrote:
>> Hello all,
>>
>> My initial task was to match the well-known notation used in math and
>> other fields to denote integer sequences. Such notation is nice,
>> unambiguous and -some times- succinct:
>>
>> 1,2,3,4,8-10,11-14
>>
>> which is equivalent to:
>>
>> 1-4,8-14
>>
>> (and to may other possibilities, the one immediately above being the
>> most succinct possible)
>>
>> I have been able to come up with a regular expression which
>> unequivocally matches any valid "statement" of such "language". See
>> below.
>>
>> My problem is that now I would like to write a more general form of
>> such sequence matching. The "base unit" is not an integer anymore. I
>> will post the actual question next.
>>
>> -Ramon
>>
>> ps: You will notice that this is not written in Perl, but in C++ and
>> will be used in some sort of "Perl emulator" (actually a Regex package
>> for C++). For obvious reason, a Perl NG is the best place to find the
>> appropriate experts. I am sure some of you can devise regexes in your
>> sleep. :-)
>>
>> ---------------------------
>>
>> const char hyphen = '-';
>> const char left_paren = '(';
>> const char right_paren = ')';
>> const char bar = '|';
>> const char comma = ',';
>> const char star = '*';
>>
>> const string number = "[0-9]+";
>> const string range = number + hyphen + number;
>> const string term = left_paren + number + bar + range +
>> right_paren;
>> const string sequence = term + bar + left_paren + term + comma +
>> right_paren + star + term;
>
>I guess the first question is this: is my initial (based on plain old
^^^^^^^^^^^^^^
>integers) version already posted correct? Are there any comments about
>it? The actual program is working properly.
>
>Once again, I got into trouble when I tried to develop a more general
>version, not based on integers but in "base units" slightly more
>complicated. I keep on thinking that my problem is the parentheses
>(excess or deficit of them). I can never figure those out.
>
>I still owe you the actual question.
^^^^^^^^^^^^^^^
Is this the first question or the actual question?
You will have to translate this string into something readable
with an explanation of how it works.
-sln
------------------------------
Date: Mon, 12 Oct 2009 09:32:46 -0700 (PDT)
From: Ramon F Herrera <ramon@conexus.net>
Subject: Re: Help needed with tough regular expression matching
Message-Id: <bba30dc4-20a6-47dd-9370-f18dc0c2b0af@e34g2000vbm.googlegroups.com>
On Oct 12, 11:52=A0am, s...@netherlands.com wrote:
> On Mon, 12 Oct 2009 07:48:54 -0700 (PDT), Ramon F Herrera <ra...@conexus.=
net> wrote:
>
>
>
> >On Oct 12, 10:41=A0am, Ramon F Herrera <ra...@conexus.net> wrote:
> >> Hello all,
>
> >> My initial task was to match the well-known notation used in math and
> >> other fields to denote integer sequences. Such notation is nice,
> >> unambiguous =A0and -some times- succinct:
>
> >> 1,2,3,4,8-10,11-14
>
> >> which is equivalent to:
>
> >> 1-4,8-14
>
> >> (and to may other possibilities, the one immediately above being the
> >> most succinct possible)
>
> >> I have been able to come up with a regular expression which
> >> unequivocally matches any valid "statement" of such "language". See
> >> below.
>
> >> My problem is that now I would like to write a more general form of
> >> such sequence matching. The "base unit" is not an integer anymore. I
> >> will post the actual question next.
>
> >> -Ramon
>
> >> ps: You will notice that this is not written in Perl, but in C++ and
> >> will be used in some sort of "Perl emulator" (actually a Regex package
> >> for C++). For obvious reason, a Perl NG is the best place to find the
> >> appropriate =A0experts. I am sure some of you can devise regexes in yo=
ur
> >> sleep. :-)
>
> >> ---------------------------
>
> >> const char hyphen =A0 =A0 =A0 =A0 =3D '-';
> >> const char left_paren =A0 =A0 =3D '(';
> >> const char right_paren =A0 =A0=3D ')';
> >> const char bar =A0 =A0 =A0 =A0 =A0 =A0=3D '|';
> >> const char comma =A0 =A0 =A0 =A0 =A0=3D ',';
> >> const char star =A0 =A0 =A0 =A0 =A0 =3D '*';
>
> >> const string number =A0 =A0 =A0 =3D "[0-9]+";
> >> const string range =A0 =A0 =A0 =A0=3D number + hyphen + number;
> >> const string term =A0 =A0 =A0 =A0 =3D left_paren + number + bar + rang=
e +
> >> right_paren;
> >> const string sequence =A0 =A0 =3D term + bar + left_paren + term + com=
ma +
> >> right_paren + star + term;
>
> >I guess the first question is this: is my initial (based on plain old
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0^^^^^^^^^^^^^^>integers) version already poste=
d correct? Are there any comments about
> >it? The actual program is working properly.
>
> >Once again, I got into trouble when I tried to develop a more general
> >version, not based on integers but in "base units" slightly more
> >complicated. I keep on thinking that my problem is the parentheses
> >(excess or deficit of them). I can never figure those out.
>
> >I still owe you the actual question.
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0^^^^^^^^^^^^^^^
> Is this the first question or the actual question?
> You will have to translate this string into something readable
> with an explanation of how it works.
>
> -sln
Okay, sorry about the pre-questioning and post-questioning caches. :-)
Too many lookahead buffers, but at least now I know that somebody is
reading this with interest...
My definite question is about the notation that I am trying to
implement.
(1) Older version is based on a sequence of integers, at it works as
expected with the regexes already posted:
1,5,7-11,13
(2) My future feature will be based on "quarters" instead of integers.
This is an instance of the most basic unit:
4/2008
(meaning the 4th. quarter of year 2008, of course).
Therefore the notation (I don't allow spaces, btw) will look like
this:
2/2000,3/2000,4/2000,1/2005,2/2005-1/2006
Which could be minimally expressed like this:
2/2000-4/2000,1/2005-1/2006
My failed attempt at dealing with calendar quarters is lifted entirely
from the integer version, but for some reasons it doesn't seem to
scale well.
-Ramon
------------------------------
Date: Mon, 12 Oct 2009 17:01:58 +0000
From: Tim Landscheidt <tim@tim-landscheidt.de>
Subject: Re: Help needed with tough regular expression matching
Message-Id: <m3d44smtq1.fsf@passepartout.tim-landscheidt.de>
Ramon F Herrera <ramon@conexus.net> wrote:
> [...]
> My failed attempt at dealing with calendar quarters is lifted entirely
> from the integer version, but for some reasons it doesn't seem to
> scale well.
If you don't post it, we can't take a look at it (at least I
do not believe in telepathy). If you post it, please do not
use yet another grammar, but a valid Perl regular expres-
sion, i. e. the output of "printf ("%s\n", sequence);" or
something like it.
Tim
------------------------------
Date: Mon, 12 Oct 2009 18:27:46 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Help needed with tough regular expression matching
Message-Id: <ih5cq6-9bp2.ln1@osiris.mauzo.dyndns.org>
Quoth Ramon F Herrera <ramon@conexus.net>:
>
> (2) My future feature will be based on "quarters" instead of integers.
> This is an instance of the most basic unit:
>
> 4/2008
>
> (meaning the 4th. quarter of year 2008, of course).
>
> Therefore the notation (I don't allow spaces, btw) will look like
> this:
>
> 2/2000,3/2000,4/2000,1/2005,2/2005-1/2006
>
> Which could be minimally expressed like this:
>
> 2/2000-4/2000,1/2005-1/2006
Right... so you want
my $qtr = qr! [1234] / \d{4} !x;
my $range = qr! $qtr - $qtr !x;
my $item = qr! $qtr | $range !x;
my $expr = qr! $item (?: , $item )* !x;
Translating that into <whatever it is you're using> is left as an
exercise.
Why couldn't you just ask the straightforward question first?
Ben
------------------------------
Date: Mon, 12 Oct 2009 11:02:00 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Help needed with tough regular expression matching
Message-Id: <46r6d590da1rr0rpoiu265v5mtvkjgkljr@4ax.com>
Ramon F Herrera <ramon@conexus.net> wrote:
>> On Mon, 12 Oct 2009 07:48:54 -0700 (PDT), Ramon F Herrera <ra...@conexus.net> wrote:
>> >> I have been able to come up with a regular expression which
>> >> unequivocally matches any valid "statement" of such "language". See
>> >> below.
>(2) My future feature will be based on "quarters" instead of integers.
>This is an instance of the most basic unit:
>
>4/2008
>
>(meaning the 4th. quarter of year 2008, of course).
>
>Therefore the notation (I don't allow spaces, btw) will look like
>this:
>
>2/2000,3/2000,4/2000,1/2005,2/2005-1/2006
>
>Which could be minimally expressed like this:
>
>2/2000-4/2000,1/2005-1/2006
>
>My failed attempt at dealing with calendar quarters is lifted entirely
>from the integer version, but for some reasons it doesn't seem to
>scale well.
I will never understand the obsession involved with regular expressions.
Of course you CAN use them to parse the above syntax, but why would you
insist on doing so? Your syntax are so simple, a trivial
split/,/
will give you a sequence of ranges already, some of them representing
single quarters. And that is all you need.
And then just walk through them one by one and check if the beginning
quarter of the next entry is one larger than the ending quarter of the
current entry(*). If so then merge the two.
*: this one is the only function that requires a tiny bit of
intelligence. But as your data seems to be in chonological sequence you
don't even have to deal with overlaps or included subsets or any of
those things, that hit you when you least expect it.
jue
------------------------------
Date: Mon, 12 Oct 2009 16:06:15 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: problem with perl + thread + extension
Message-Id: <78tbq6-4eo2.ln1@osiris.mauzo.dyndns.org>
Quoth Andreas Otto <aotto1968@users.sourceforge.net>:
>
> the following scenario:
>
> I use perl (see below) and write an extension (perlmsgque) as wrapper for
> an existing shared library (libmsgque).
> everything works fine without threads:
>
> now I add threads.
>
<snip>
> 7) but the first callback:
>
> >>>>>>>>>>>>>>>>>>>>>>>>>
> static enum MqErrorE
> ProcCall (
> struct MqS * const context,
> MQ_PTR const data
> )
> {
> dSP;
> SV * method = (SV*) data;
> enum MqErrorE ret = MQ_OK;
>
> ENTER;
> SAVETMPS;
>
> PUSHMARK(SP);
> XPUSHs((SV*)context->self);
> PUTBACK;
>
> call_sv (method, G_SCALAR|G_DISCARD|G_EVAL);
>
> ret = ProcError (aTHX_ context, ERRSV);
>
> FREETMPS;
> LEAVE;
>
> return ret;
> }
> <<<<<<<<<<<<<<<<<<<<<<<<<<<
I'm surprised that even compiled. Where is that function getting its THX
from?
I don't really understand how these functions interact, or (for example)
which thread ProcCall is being called from. If you can cut out libmsgque
for now, and produce a minimal complete program using just
pthread_create or some such that shows the same failure, maybe someone
can help you.
FWIW I don't know that cloning an interpreter to live in a thread you
created (rather than using the threads.pm API) is supported, as such, so
it may not be possible to make this work.
Ben
------------------------------
Date: Mon, 12 Oct 2009 18:05:45 +0200
From: Andreas Otto <aotto1968@users.sourceforge.net>
Subject: Re: problem with perl + thread + extension
Message-Id: <havk4q$tin$03$1@news.t-online.com>
Ben Morrow wrote:
>
> I'm surprised that even compiled.
The code is only a subset of existing code
> Where is that function getting its THX
> from?
I do not change anything the THX is from behind perl macro call
>
> I don't really understand how these functions interact,
1. original process
2. libmsgque create a new thread
3. SysServerThreadCreate calling FactoryCreate on the new thread using
the tmpl argument from original process
3. perl_clone is called as first step in FactoryCreate
>>>>>>>>>>>>>>>>>>>>>
static enum MqErrorE FactoryCreate (
struct MqS * const tmpl,
enum MqFactoryE create,
MQ_PTR data,
struct MqS ** contextP
) {
if (create == MQ_FACTORY_NEW_THREAD) {
perl_clone ((PerlInterpreter*)tmpl->threadData, CLONEf_KEEP_PTR_TABLE |
CLONEf_CLONE_HOST);
}
{
dSP;
enum MqErrorE ret = MQ_OK;
int count;
ENTER;
SAVETMPS;
PUSHMARK(SP);
count = call_sv ((SV*)data, G_SCALAR|G_NOARGS|G_EVAL);
SPAGAIN;
if ((ret = ProcError (aTHX_ tmpl, ERRSV)) == MQ_OK) {
if (count != 1) {
ret = MqErrorC(tmpl, __func__, -1, "factory return more than one
value!");
} else {
SV * sv = POPs;
if (sv_derived_from(sv, "MqS")) {
IV tmp = SvIV((SV*)SvRV(sv));
MqS * context = *contextP = INT2PTR(MqS*,tmp);
MqConfigDup (context, tmpl);
if ((ret = MqSetupDup (context, tmpl)) != MQ_OK) {
MqErrorCopy (tmpl, context);
}
} else {
ret = MqErrorC(tmpl, __func__, -1, "factory return is not of type
'MqS'");
}
}
}
PUTBACK;
FREETMPS;
LEAVE;
return ret;
}
}
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
4. now context is setup for current thread
5. call the perl "Factory" from FactoryCreate to return
the new Object reference
>>> $ctx->ConfigSetFactory(sub {new Server()});
6. the new Server create the object
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
void
new(SV* MqS_class)
PPCODE:
if (!SvROK(MqS_class)) {
// called by a "class"
MqS * context = (MqS*) MqContextCreate(sizeof(struct PerlContextS),
NULL);
ST(0) = sv_newmortal();
sv_setref_pv(ST(0), SvPV_nolen(MqS_class), (void*)context);
context->self = SvREFCNT_inc(ST(0));
context->setup.Child.fCreate = MqDefaultLinkCreate;
context->setup.Parent.fCreate = MqDefaultLinkCreate;
context->setup.fProcessExit = ProcessExit;
//context->setup.fThreadInit = ThreadInit;
context->setup.fThreadExit = ThreadExit;
context->setup.Factory.Delete.fCall = FactoryDelete;
context->threadData = PERL_GET_CONTEXT;
} else {
MqConfigReset (INT2PTR(MqS*,SvIV((SV*)SvRV(ST(0)))));
}
XSRETURN(1);
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
7. after the object is available the SysServerThreadCreate continue
to setup the connection
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
static mqthread_ret_t mqthread_stdcall sSysServerThreadCreate (
void * data
)
{
struct SysServerThreadCreateS * argP = (struct SysServerThreadCreateS *)
data;
// save data local
struct MqS * tmpl = argP->tmpl;
struct MqFactoryS factory = argP->factory;
struct MqBufferLS * argv = argP->argv;
struct MqBufferLS * alfa = argP->alfa;
struct MqS * newctx;
// cleanup
free(argP);
// create the new context
MqErrorCheck(pCallFactory (tmpl, MQ_FACTORY_NEW_THREAD, factory,
&newctx));
^^^^^^^^^^^^^^^^^ call factory ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// add my configuration
newctx->statusIs = (enum MqStatusIsE) (newctx->statusIs |
MQ_STATUS_IS_THREAD);
// the new CONTEXT is always a SERVER
newctx->setup.isServer = MQ_YES;
// join argvP alfaP
if (alfa != NULL) {
MqBufferLAppendC(argv, MQ_ALFA_STR);
MqBufferLMove(argv, &alfa);
}
// create link
MqErrorCheck(MqLinkCreate(newctx, &argv));
^^^^^^^^^^^^^^ setup connection ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
//MqDLogC(msgque,0,"THREAD exit");
// the MqProcessEvent is necessary because "ParentCreate" have to come
back
// ifNot: java create object will fail
if (newctx->setup.isServer == MQ_YES) {
MqProcessEvent(newctx, MQ_TIMEOUT, MQ_WAIT_FOREVER);
}
error:
MqBufferLDelete (&argv);
<<<<<<<<<<<<<<<<<<<<<<<<<<<<
8. the connection setup code call a perl setup function ProcCall
with the setup callback sub-ref as argument
>>> $ctx->ConfigSetServerSetup(\&ServerSetup);
>>>>>>>>>>>>>>>>>>>>>>>
sub ServerSetup {
my $ctx = shift;
print "ctx<$ctx>\n";
if ($ctx->ConfigGetIsSlave()) {
# add "slave" services here
} else {
...
<<<<<<<<<<<<<<<<<<<<<<<
9. ServerSetup fails .. because the argument from the stack is not visible
ERROR: $ctx is empty !!!!
> or (for example)
> which thread ProcCall is being called from.
ProcCall is a callback called from the libraray libmsgque
> If you can cut out libmsgque
> for now, and produce a minimal complete program using just
> pthread_create or some such that shows the same failure, maybe someone
> can help you.
it is not a problem from libmsgque because the same thread code is used
for C, C++, C#, JAVA, TCL, PYTHON .....
without problems ....
the problem is only the PERL stack arguments missing
>
> FWIW I don't know that cloning an interpreter to live in a thread you
> created (rather than using the threads.pm API) is supported, as such, so
> it may not be possible to make this work.
>
> Ben
------------------------------
Date: Mon, 12 Oct 2009 18:17:03 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: problem with perl + thread + extension
Message-Id: <ft4cq6-9bp2.ln1@osiris.mauzo.dyndns.org>
Quoth Andreas Otto <aotto1968@users.sourceforge.net>:
> Ben Morrow wrote:
>
> >
> > I'm surprised that even compiled.
>
> The code is only a subset of existing code
>
> > Where is that function getting its THX
> > from?
>
> I do not change anything the THX is from behind perl macro call
On threaded perls, aTHX expands to a variable called 'my_perl', which is
supposed to be a PerlInterpreter *. AFAIXS, the function you posted
doesn't take a pTHX parameter and doesn't use dTHX to declare and
initialize a local variable, so where is it getting its my_perl variable
from?
I suspect this is actually behind your immediate problem: you are ending
up with some bits of the perl API talking to a different interpreter
from others. It's very important to keep your idea of which interpreter
you're using and the one recorded in TLS in sync.
> > I don't really understand how these functions interact,
>
> 1. original process
> 2. libmsgque create a new thread
> 3. SysServerThreadCreate calling FactoryCreate on the new thread using
> the tmpl argument from original process
> 3. perl_clone is called as first step in FactoryCreate
> >>>>>>>>>>>>>>>>>>>>>
> static enum MqErrorE FactoryCreate (
> struct MqS * const tmpl,
> enum MqFactoryE create,
> MQ_PTR data,
> struct MqS ** contextP
> ) {
>
> if (create == MQ_FACTORY_NEW_THREAD) {
> perl_clone ((PerlInterpreter*)tmpl->threadData, CLONEf_KEEP_PTR_TABLE |
> CLONEf_CLONE_HOST);
> }
You weren't using KEEP_PTR_TABLE or CLONE_HOST last time. Why have you
changed it?
> {
> dSP;
Which perl interpreter do you expect to be using here? I believe this
thread has now been switched over to using the new interpreter created
by perl_clone, but I'm not entirely sure.
For that matter, how on earth does *this* function compile? dSP; expands
to
SV **sp = (my_perl->Istack_sp);
so where is the my_perl variable coming from? Do you have a global
declared somewhere that you haven't shown me?
<snip>
> if (sv_derived_from(sv, "MqS")) {
(You probably shouldn't be using top-level namespaces. Put your packages
under Net::MsqQue or some such.)
<snip>
> 4. now context is setup for current thread
> 5. call the perl "Factory" from FactoryCreate to return
> the new Object reference
> >>> $ctx->ConfigSetFactory(sub {new Server()});
Where does this piece of Perl come from? What is $ctx, and how did you
create it? What does the ConfigSetFactory method do?
You need to start posting *complete* bits of code that actually make
sense. I realise this is difficult when dealing with XS and embedding,
but I can't yet make any sense out of what you've posted.
<snip>
> 8. the connection setup code call a perl setup function ProcCall
> with the setup callback sub-ref as argument
>
> >>> $ctx->ConfigSetServerSetup(\&ServerSetup);
Again, what is this Perl and how does it relate to the C? What does
ConfigSetServerSetup do with its argument?
> > or (for example)
> > which thread ProcCall is being called from.
>
> ProcCall is a callback called from the libraray libmsgque
Right... *which* *thread* is it called in, the same thread as called
perl_clone or a new one? Are either of these the same as the thread the
*original* interpreter was created in?
>
>
> > If you can cut out libmsgque
> > for now, and produce a minimal complete program using just
> > pthread_create or some such that shows the same failure, maybe someone
> > can help you.
>
> it is not a problem from libmsgque because the same thread code is used
> for C, C++, C#, JAVA, TCL, PYTHON .....
> without problems ....
> the problem is only the PERL stack arguments missing
Right. libmsgque is (probably) not part of the problem, so *remove it*.
Figure out how to create perl interpreters in random threads first.
Ben
------------------------------
Date: Mon, 12 Oct 2009 16:14:42 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: regexp assistance
Message-Id: <2otbq6-4eo2.ln1@osiris.mauzo.dyndns.org>
Quoth Ramon F Herrera <ramon@conexus.net>:
>
> Parentheses will be the bane of me. I always seem to have too few or
> too many. The crux of such problem is that parentheses have two
> distinct purposes in regexes:
>
> (1) The normal grouping used in math and programming languages.
>
> (2) The "grab this part" function.
These two functions can be separated. (?: ) will group only, without
capturing. (The unfortunately ugly syntax is the result of not wanting
to break Perl 4 programs.)
> Who invented regexes anyway, was it Larry Wall? I would have used
> angle brackets for the functionality (2) above.
No, regular expressions have been around since long before perl was
written. The basic syntax using . * + () | [] was, I believe, first used
in the 'ed' editor.
Larry has, in fact, completely revised regex syntax for Perl 6. Perl 6
uses () for capturing and [] for grouping; <> is used for 'special'
constructions and subrules, because of its use in ABNF.
Ben
------------------------------
Date: Mon, 12 Oct 2009 16:17:31 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: regexp assistance
Message-Id: <bttbq6-4eo2.ln1@osiris.mauzo.dyndns.org>
Quoth Sherm Pendley <spamtrap@shermpendley.com>:
> mike <mikaelpetterson@hotmail.com> writes:
>
> > Is \z not to match at the end of a string?
>
> Yes, but $ is far more commonly used for that.
The difference is important. /$/ will match before a newline at the end
of the string; /\z/ will not. When you are certain your strings won't
contain newlines, there is no difference, but once you start considering
using /m and /s you should also consider whether you need /\z/ instead
of /$/.
Ben
------------------------------
Date: Mon, 12 Oct 2009 08:31:35 -0700
From: sln@netherlands.com
Subject: Re: regexp assistance
Message-Id: <6qi6d5p2v5en6v95ta75gr083jcondsse7@4ax.com>
On Mon, 12 Oct 2009 06:25:38 -0700 (PDT), mike <mikaelpetterson@hotmail.com> wrote:
>Hi,
>
>I am trying to get files that looks like:
>
>xxxInds.java
>yyyReset.java
>zzzRespone.java
>
>I am using the following regexp:
>
>return unless -f $File::Find::name;
> /^.*Inds|Reset|Response\.java\z/s
/^.*(?:Inds|Reset|Response)\.java$/s
-sln
------------------------------
Date: Mon, 12 Oct 2009 08:32:57 -0700
From: sln@netherlands.com
Subject: Re: regexp assistance
Message-Id: <00j6d5h4kl4qfe8vuacqsi7d7347snlu8n@4ax.com>
On Mon, 12 Oct 2009 08:31:35 -0700, sln@netherlands.com wrote:
>On Mon, 12 Oct 2009 06:25:38 -0700 (PDT), mike <mikaelpetterson@hotmail.com> wrote:
>
>>Hi,
>>
>>I am trying to get files that looks like:
>>
>>xxxInds.java
>>yyyReset.java
>>zzzRespone.java
>>
>>I am using the following regexp:
>>
>>return unless -f $File::Find::name;
>> /^.*Inds|Reset|Response\.java\z/s
>
> /^.*(?:Inds|Reset|Response)\.java$/s
/^.*(?:Inds|Reset|Response)\.java$/
-sln
------------------------------
Date: Mon, 12 Oct 2009 08:43:54 -0700
From: sln@netherlands.com
Subject: Re: regexp assistance
Message-Id: <chj6d51smnhke4ufq069nqdsjhmhif4dfg@4ax.com>
On Mon, 12 Oct 2009 16:17:31 +0100, Ben Morrow <ben@morrow.me.uk> wrote:
>
>Quoth Sherm Pendley <spamtrap@shermpendley.com>:
>> mike <mikaelpetterson@hotmail.com> writes:
>>
>> > Is \z not to match at the end of a string?
>>
>> Yes, but $ is far more commonly used for that.
>
>The difference is important. /$/ will match before a newline at the end
>of the string; /\z/ will not. When you are certain your strings won't
>contain newlines, there is no difference, but once you start considering
>using /m and /s you should also consider whether you need /\z/ instead
>of /$/.
>
>Ben
I guess \A\Z\z in multiple lines, mean "only" to be once.
-sln
------------------------------
Date: Mon, 12 Oct 2009 09:55:02 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: time format +1 hour
Message-Id: <864oq4lfh5.fsf@blue.stonehenge.com>
>>>>> "Slickuser" == Slickuser <slick.users@gmail.com> writes:
>>> Is this GMT, or a local time? If a local time, which timezone, and
>> >> under what DST rules?
Slickuser> Local time, Pacific, and 1 for DST.
In that case, you understand that there will be once a year (in fall) where
"add an hour" changes nothing in your string, and once a year (in spring)
where "add an hour" changes the apparent time by two hours. It would be less
ambiguous if you included the timezone as part of your string.
Or maybe you should just use GMT, which doesn't have this problem.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion
------------------------------
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:
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests.
#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 V11 Issue 2632
***************************************