[29415] in Perl-Users-Digest
Perl-Users Digest, Issue: 659 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jul 18 11:10:03 2007
Date: Wed, 18 Jul 2007 08:09:10 -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 Wed, 18 Jul 2007 Volume: 11 Number: 659
Today's topics:
Apache Configuration with PERL nicklas.bornstein@gmail.com
Apache Configuration with PERL nicklas.bornstein@gmail.com
Re: Apache Configuration with PERL anno4000@radom.zrz.tu-berlin.de
Re: Array <rvtol+news@isolution.nl>
Re: catch-ing unsatisfied ``use'' anno4000@radom.zrz.tu-berlin.de
Re: catch-ing unsatisfied ``use'' (aka ? the Platypus)
Re: catch-ing unsatisfied ``use'' anno4000@radom.zrz.tu-berlin.de
here-doc issue <nmrabinovich@gmail.com>
Re: here-doc issue <noreply@gunnar.cc>
Re: here-doc issue <glennj@ncf.ca>
Re: here-doc issue <gcerrai@etnoteam.it>
Re: How do you retrieve a char from a string? anno4000@radom.zrz.tu-berlin.de
Regex insertion <dsphunxion@gmail.com>
Regex insertion <dsphunxion@gmail.com>
Re: Regex insertion (Jens Thoms Toerring)
regex to help with LDAP <jogdial@gmail.com>
Re: regex to help with LDAP <peter@makholm.net>
Re: regex to help with LDAP (Jens Thoms Toerring)
Re: regex to help with LDAP <wahab@chemie.uni-halle.de>
Re: The Modernization of Emacs: exists already <xah@xahlee.org>
Re: The Modernization of Emacs: exists already <walthervondervogelweide@gmx.de>
uncleared data on serial port problem <luhaorice@gmail.com>
XML::Twig segfault on solaris <braindumped@expires-31-07-2007.news-group.org>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 18 Jul 2007 01:24:05 -0700
From: nicklas.bornstein@gmail.com
Subject: Apache Configuration with PERL
Message-Id: <1184747045.809575.223960@o11g2000prd.googlegroups.com>
Hi,
I do somthing like;
push @{$VirtualHost{'*'}}, {
ServerName => 'www.firstdomain.com',
DocumentRoot => "C:/www/firstdoc",
...
};
push @{$VirtualHost{'*'}}, {
ServerName => 'www.seconddomain.com',
DocumentRoot => "C:/www/seconddoc",
...
};
But only the first one is active. Even if I call the domain www.seconddomain.com,
I get the first document root. Whats wrong?
------------------------------
Date: Wed, 18 Jul 2007 08:27:01 -0000
From: nicklas.bornstein@gmail.com
Subject: Apache Configuration with PERL
Message-Id: <1184747221.184945.296280@j4g2000prf.googlegroups.com>
Hi,
I do somthing like;
push @{$VirtualHost{'*'}}, {
ServerName => 'www.firstdomain.com',
DocumentRoot => "C:/www/firstdoc",
...
};
push @{$VirtualHost{'*'}}, {
ServerName => 'www.seconddomain.com',
DocumentRoot => "C:/www/seconddoc",
...
};
But only the first one is active. Even if I call the domain www.seconddomain.com,
I get the first document root. Whats wrong?
------------------------------
Date: 18 Jul 2007 09:25:20 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: Apache Configuration with PERL
Message-Id: <5g64k0F2gahjqU1@mid.dfncis.de>
<nicklas.bornstein@gmail.com> wrote in comp.lang.perl.misc:
> Hi,
>
> I do somthing like;
>
> push @{$VirtualHost{'*'}}, {
> ServerName => 'www.firstdomain.com',
> DocumentRoot => "C:/www/firstdoc",
> ...
> };
>
> push @{$VirtualHost{'*'}}, {
> ServerName => 'www.seconddomain.com',
> DocumentRoot => "C:/www/seconddoc",
> ...
> };
>
> But only the first one is active. Even if I call the domain
> www.seconddomain.com,
> I get the first document root. Whats wrong?
Nothing is wrong with your Perl (not PERL) code. You don't say which
Perl module for Apache configuration you are using, so we can't tell
whether those directives make sense.
This looks more like an Apache problem than a Perl problem. You'd
probably be better off asking this on a newsgroup about Apache. If
you do, mention the version of Apache you are running. They will
also ask you if both (all) server names have DNS entries.
Anno
------------------------------
Date: Wed, 18 Jul 2007 09:53:47 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: Array
Message-Id: <f7ko0u.os.1@news.isolution.nl>
Dave Weaver schreef:
> Dr.Ruud:
>> Jens Thoms Toerring:
>>> print join( ',', @signal ) . "\n";
>>
>> There will not be a "\n" at the end.
>
> ??
>
> There is a "\n" when I try it.
Don't know why, but I guess I was reading
print join( "\n", @signal )
in stead, and worked on from that.
If I would have read properly, I would have ended at
{ local ($\, $,) = ("\n", ','); print @signal }
which is similar to what Glenn replied.
--
Affijn, Ruud
"Gewoon is een tijger."
------------------------------
Date: 18 Jul 2007 10:14:06 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: catch-ing unsatisfied ``use''
Message-Id: <5g67feF3ed52pU1@mid.dfncis.de>
Mikhail Teterin <usenet+meow@aldan.algebra.com> wrote in comp.lang.perl.misc:
> Hello!
>
> I'm trying to modify a script, that uses ImageMagick bindings, to also work
> with those of GraphicsMagick.
>
> The script currently does simply:
>
> use Image::Magick;
>
> For GraphicsMagick one would say:
>
> use Graphics::Magick;
>
> I tried the following
>
> use Image::Magick or use Graphics::Magick;
> (syntax error)
>
> And
>
> try {
> use Image::Magick;
> } catch Error {
> use GraphicsMagick;
> };
>
> The second one does not cause syntax errors, but the script still fails with
> an error about being unable to find Image/Magick.pm. The `try/catch' does
> not seem to have any effect...
That's because "use" happens at compile time, while the "try" statement
(effectively an empty one) is executed at run time.
This should take you closer (untested):
BEGIN {
try {
require Image::Magick;
} catch Error {
require GraphicsMagick;
}
}
You may have to call each module's ->import method after require().
Anno
------------------------------
Date: Wed, 18 Jul 2007 12:59:18 GMT
From: "David Formosa (aka ? the Platypus)" <dformosa@usyd.edu.au>
Subject: Re: catch-ing unsatisfied ``use''
Message-Id: <slrnf9s457.219.dformosa@localhost.localdomain>
On 18 Jul 2007 10:14:06 GMT, anno4000@radom.zrz.tu-berlin.de
<anno4000@radom.zrz.tu-berlin.de> wrote:
[...]
> That's because "use" happens at compile time, while the "try" statement
> (effectively an empty one) is executed at run time.
>
> This should take you closer (untested):
>
> BEGIN {
> try {
> require Image::Magick;
> } catch Error {
> require GraphicsMagick;
> }
> }
Perl has try and catch now? My 5.8.8 definitly doesn't have anything
looking like it. Perhaps you mean
eval {
};
and
if ($@) {
}
------------------------------
Date: 18 Jul 2007 13:31:13 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: catch-ing unsatisfied ``use''
Message-Id: <5g6j11F3fd09jU1@mid.dfncis.de>
David Formosa (aka ? the Platypus) <dformosa@usyd.edu.au> wrote in comp.lang.perl.misc:
> On 18 Jul 2007 10:14:06 GMT, anno4000@radom.zrz.tu-berlin.de
> <anno4000@radom.zrz.tu-berlin.de> wrote:
>
> [...]
>
> > That's because "use" happens at compile time, while the "try" statement
> > (effectively an empty one) is executed at run time.
> >
> > This should take you closer (untested):
> >
> > BEGIN {
> > try {
> > require Image::Magick;
> > } catch Error {
> > require GraphicsMagick;
> > }
> > }
>
> Perl has try and catch now? My 5.8.8 definitly doesn't have anything
> looking like it. Perhaps you mean
>
> eval {
> };
>
> and
>
> if ($@) {
> }
There is code for a try/catch pair in perlsub (as an example for the
"&" prototype) which probably has found its way into an exception-handling
module or another. I was simply assuming the OP is using some such module
without caring enough to find out which it is.
Anno
------------------------------
Date: Wed, 18 Jul 2007 07:30:15 -0700
From: lnatz <nmrabinovich@gmail.com>
Subject: here-doc issue
Message-Id: <1184769015.044238.162750@e9g2000prf.googlegroups.com>
Hi, I'm having an issue with here docs, and I'm sure it's something
simple that I'm overlooking but it's annoying me. Here is a snippet
from my script.
sub usage {
print<<EOF;
>> The following single-character otions are accepted:
>> wih arguments: -T -S
>> without arguments(boolean): -g -e
>> Use:
>> -T followed by a target
>> -S followed by a source
>> -g to generate a runbook
>> -e to execute the runbook
>> Requirements:
>> you must specify a target and a source
>> you must specify either to generate a runbook, execute the
runbook or both
>> Example: perl exec_rnbk.pl -T UT -S testing -g
EOF
exit 0;
}
It is failing with error: Can't find string terminator "EOF" anywhere
before EOF at exec_rnbk.pl line 94.
Line 94 is "print<<EOF;".
Am I missing something obvious?
Thanks in advance!
------------------------------
Date: Wed, 18 Jul 2007 16:38:47 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: here-doc issue
Message-Id: <5g6n5tF3f82a5U1@mid.individual.net>
lnatz wrote:
> Hi, I'm having an issue with here docs, and I'm sure it's something
> simple that I'm overlooking but it's annoying me. Here is a snippet
> from my script.
>
> sub usage {
> print<<EOF;
>
> >> The following single-character otions are accepted:
> >> wih arguments: -T -S
> >> without arguments(boolean): -g -e
> >> Use:
> >> -T followed by a target
> >> -S followed by a source
> >> -g to generate a runbook
> >> -e to execute the runbook
> >> Requirements:
> >> you must specify a target and a source
> >> you must specify either to generate a runbook, execute the
> runbook or both
>
> >> Example: perl exec_rnbk.pl -T UT -S testing -g
> EOF
> exit 0;
> }
>
> It is failing with error: Can't find string terminator "EOF" anywhere
> before EOF at exec_rnbk.pl line 94.
> Line 94 is "print<<EOF;".
>
> Am I missing something obvious?
The docs will probably help you detect the problem:
http://perldoc.perl.org/perlop.html#%3c%3cEOF-here-doc-heredoc-here-document-%3c%3c
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: 18 Jul 2007 14:42:43 GMT
From: Glenn Jackman <glennj@ncf.ca>
Subject: Re: here-doc issue
Message-Id: <slrnf9s9n3.6km.glennj@smeagol.ncf.ca>
At 2007-07-18 10:30AM, "lnatz" wrote:
[...]
> It is failing with error: Can't find string terminator "EOF" anywhere
> before EOF at exec_rnbk.pl line 94.
> Line 94 is "print<<EOF;".
>
> Am I missing something obvious?
Run your code with "use diagnostics". You'll see this advice:
If you're getting this error from a here-document, you may have included
unseen whitespace before or after your closing tag. A good programmer's
editor will have a way to help you find these characters.
--
Glenn Jackman
"You can only be young once. But you can always be immature." -- Dave Barry
------------------------------
Date: Wed, 18 Jul 2007 16:47:31 +0200
From: Giacomo Cerrai <gcerrai@etnoteam.it>
Subject: Re: here-doc issue
Message-Id: <469e2827@news.x-privat.org>
lnatz wrote:
> Hi, I'm having an issue with here docs, and I'm sure it's something
> simple that I'm overlooking but it's annoying me. Here is a snippet
> from my script.
>
> sub usage {
> print<<EOF;
>
> >> The following single-character otions are accepted:
> >> wih arguments: -T -S
> >> without arguments(boolean): -g -e
> >> Use:
> >> -T followed by a target
> >> -S followed by a source
> >> -g to generate a runbook
> >> -e to execute the runbook
> >> Requirements:
> >> you must specify a target and a source
> >> you must specify either to generate a runbook, execute the
> runbook or both
>
> >> Example: perl exec_rnbk.pl -T UT -S testing -g
> EOF
> exit 0;
> }
>
> It is failing with error: Can't find string terminator "EOF" anywhere
> before EOF at exec_rnbk.pl line 94.
> Line 94 is "print<<EOF;".
are you sure you don't have any character in front of 'EOF'?
or maybe a non std newline in the previous line?
g.
>
> Am I missing something obvious?
>
> Thanks in advance!
------------------------------
Date: 18 Jul 2007 11:42:42 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: How do you retrieve a char from a string?
Message-Id: <5g6cliF3du42cU1@mid.dfncis.de>
Sherm Pendley <spamtrap@dot-app.org> wrote in comp.lang.perl.misc:
> Thierry <lamthierry@gmail.com> writes:
>
> > I have the following string:
> >
> > my $greet = "hello";
> > print $greet[0]."\n";
> >
> > The above clearly doesn't work since $greet is not an array. Is there
> > an easy way to access characters at specific index in a string without
> > losing $greet as a String?
>
> print substr($greet, 0);
That's the entire string. The first character is "substr($greet, 0, 1)".
> See "perldoc -f substr" for details.
I'll refrain fom commentig :)
Anno
------------------------------
Date: Wed, 18 Jul 2007 12:53:59 -0000
From: sil <dsphunxion@gmail.com>
Subject: Regex insertion
Message-Id: <1184763239.191859.164960@j4g2000prf.googlegroups.com>
I need a regex of sorts that will replace ONLY the line: P-Asserted-
Identity: <sip:+$fU@$tU;user=phone> with:
P-Asserted-Identity: <sip:19998887777@1.2.3.4:5060> (from line 1)
Here is my data:
f:"Operations"<sip:
19998887777@1.2.3.4:5060>;tag=3933ee6e1923de3601d9dab88b1dc4bf
t:<sip:12223334444@something.here.com>
m:<sip:0-d03365c213c46d247564@6.7.8.9:5060;transport=udp>
i:bf52f59d069087948090769a8a98fcdd-469d50d7@1.2.3.4
CSeq:21796 INVITE
User-Agent: Asterisk PBX
Max-Forwards:16
Date: Tue, 17 Jul 2007 23:29:27 GMT
Allow:INVITE,ACK,CANCEL,OPTIONS,BYE,REFER,SUBSCRIBE,NOTIFY
c:application/sdp
l:289
Remote-Party-ID: <sip:+$fU@$tU>;privacy=off;screen=no
P-Asserted-Identity: <sip:+$fU@$tU;user=phone>
1 will always start with "f:"
Maybe...
subst("/From: <sip.*)(@)(.*)/From: <sip:\1\2\3\r\nP-Asserted-
Identity: ?
Is there an alternative say if P-Asserted... was ALWAYS the 13th line
#!/usr/bin/perl
my $sipPacket = 1;
my @packetData = '';
while ( my $line = <> ) {
if ( $line =~ m/^From: <sip.*/ ) {
if ( $sipPacket < 1 ){
pwnPacket(@packetData);
@packetData = '';
}
$sipPacket--;
next;
}
push @packetData, $line;
}
sub pwnPacket {
if ($_[1] =~ /From: <sip.*)(@)(.*)/) {
# Confusion seeps in... How do I insert it into the 13 field...
print "From: <sip:\1\2\3\r\nP-Asserted-
Identity:";
}
So the packet would read:
f:"Operations"<sip:
19998887777@1.2.3.4:5060>;tag=3933ee6e1923de3601d9dab88b1dc4bf
t:<sip:12223334444@something.here.com>
m:<sip:0-d03365c213c46d247564@10.101.1.20:5060;transport=udp>
i:bf52f59d069087948090769a8a98fcdd-469d50d7@1.2.3.4
CSeq:21796 INVITE
User-Agent: Asterisk PBX
Max-Forwards:16
Date: Tue, 17 Jul 2007 23:29:27 GMT
Allow:INVITE,ACK,CANCEL,OPTIONS,BYE,REFER,SUBSCRIBE,NOTIFY
c:application/sdp
l:289
Remote-Party-ID: <sip:+$fU@$tU>;privacy=off;screen=no
P-Asserted-Identity: <sip:19998887777@1.2.3.4:5060>
------------------------------
Date: Wed, 18 Jul 2007 13:03:28 -0000
From: sil <dsphunxion@gmail.com>
Subject: Regex insertion
Message-Id: <1184763808.585091.183270@e16g2000pri.googlegroups.com>
I need a regex of sorts that will replace ONLY the line:
P-Asserted-Identity: <sip:+$fU@$tU;user=phone>
with:
P-Asserted-Identity: <sip:19998887777@1.2.3.4:5060> (from line 1)
Here is my data:
f:"Operations"<sip:
19998887777@1.2.3.4:5060>;tag=3933ee6e1923de3601d9dab88b1dc4bf
t:<sip:12223334444@something.here.com>
m:<sip:0-d03365c213c46d247564@10.101.1.20:5060;transport=udp>
i:bf52f59d069087948090769a8a98fcdd-469d50d7@1.2.3.4
CSeq:21796 INVITE
User-Agent: Asterisk PBX
Max-Forwards:16
Date: Tue, 17 Jul 2007 23:29:27 GMT
Allow:INVITE,ACK,CANCEL,OPTIONS,BYE,REFER,SUBSCRIBE,NOTIFY
c:application/sdp
l:289
Remote-Party-ID: <sip:+$fU@$tU>;privacy=off;screen=no
P-Asserted-Identity: <sip:+$fU@$tU;user=phone>
1 will always start with "f:"
New packet should read:
f:"Operations"<sip:
19998887777@1.2.3.4:5060>;tag=3933ee6e1923de3601d9dab88b1dc4bf
t:<sip:12223334444@something.here.com>
m:<sip:0-d03365c213c46d247564@10.101.1.20:5060;transport=udp>
i:bf52f59d069087948090769a8a98fcdd-469d50d7@1.2.3.4
CSeq:21796 INVITE
User-Agent: Asterisk PBX
Max-Forwards:16
Date: Tue, 17 Jul 2007 23:29:27 GMT
Allow:INVITE,ACK,CANCEL,OPTIONS,BYE,REFER,SUBSCRIBE,NOTIFY
c:application/sdp
l:289
Remote-Party-ID: <sip:+$fU@$tU>;privacy=off;screen=no
P-Asserted-Identity: <sip:19998887777@1.2.3.4:5060>
#!/usr/bin/perl
my $sipPacket = 1;
my @packetData = '';
while ( my $line = <> ) {
if ( $line =~ m/^From: <sip.*/ ) {
if ( $sipPacket < 1 ){
pwnPacket(@packetData);
@packetData = '';
}
$sipPacket--;
next;
}
push @packetData, $line;
}
sub pwnPacket {
if ($_[1] =~ /From: <sip.*)(@)(.*)/) {
# Confusion seeps in... How do I insert it into the 13 field...
print "From: <sip:\1\2\3\r\nP-Asserted-
Identity:";
}
------------------------------
Date: 18 Jul 2007 14:15:45 GMT
From: jt@toerring.de (Jens Thoms Toerring)
Subject: Re: Regex insertion
Message-Id: <5g6lkhF3eevtvU1@mid.uni-berlin.de>
sil <dsphunxion@gmail.com> wrote:
> I need a regex of sorts that will replace ONLY the line: P-Asserted-
> Identity: <sip:+$fU@$tU;user=phone> with:
> P-Asserted-Identity: <sip:19998887777@1.2.3.4:5060> (from line 1)
> Here is my data:
> f:"Operations"<sip:
> 19998887777@1.2.3.4:5060>;tag=3933ee6e1923de3601d9dab88b1dc4bf
> t:<sip:12223334444@something.here.com>
> m:<sip:0-d03365c213c46d247564@6.7.8.9:5060;transport=udp>
> i:bf52f59d069087948090769a8a98fcdd-469d50d7@1.2.3.4
> CSeq:21796 INVITE
> User-Agent: Asterisk PBX
> Max-Forwards:16
> Date: Tue, 17 Jul 2007 23:29:27 GMT
> Allow:INVITE,ACK,CANCEL,OPTIONS,BYE,REFER,SUBSCRIBE,NOTIFY
> c:application/sdp
> l:289
> Remote-Party-ID: <sip:+$fU@$tU>;privacy=off;screen=no
> P-Asserted-Identity: <sip:+$fU@$tU;user=phone>
> 1 will always start with "f:"
> So the packet would read:
> f:"Operations"<sip:
> 19998887777@1.2.3.4:5060>;tag=3933ee6e1923de3601d9dab88b1dc4bf
> t:<sip:12223334444@something.here.com>
> m:<sip:0-d03365c213c46d247564@10.101.1.20:5060;transport=udp>
> i:bf52f59d069087948090769a8a98fcdd-469d50d7@1.2.3.4
> CSeq:21796 INVITE
> User-Agent: Asterisk PBX
> Max-Forwards:16
> Date: Tue, 17 Jul 2007 23:29:27 GMT
> Allow:INVITE,ACK,CANCEL,OPTIONS,BYE,REFER,SUBSCRIBE,NOTIFY
> c:application/sdp
> l:289
> Remote-Party-ID: <sip:+$fU@$tU>;privacy=off;screen=no
> P-Asserted-Identity: <sip:19998887777@1.2.3.4:5060>
What about something (assuming that the line break in the line
starting with 'f:' is the result of mangling by my newsreader)
as simple as
my $f;
while ( my $line = <> ) {
$f = $1 if $line =~ /^f:[^<]*<(sip:[^>]*)>;/;
$line =~ s/sip:[^>]*/$f/ if $line =~ /^P-Asserted-Identity:/;
print $line;
}
Regards, Jens
--
\ Jens Thoms Toerring ___ jt@toerring.de
\__________________________ http://toerring.de
------------------------------
Date: Wed, 18 Jul 2007 10:35:09 -0000
From: jogdial <jogdial@gmail.com>
Subject: regex to help with LDAP
Message-Id: <1184754909.029971.57840@x35g2000prf.googlegroups.com>
Hi, My Perl is very rusty and I'm having huge problems trying to pull
a common name out of a distinguished name.
The distinguished name(s) example:
"CN=KLAdmins,CN=Users,DC=contuso,DC=com"
"CN=EMLibrary Users,CN=Users,DC=contuso,DC=com"
"CN=Administrators,CN=Builtin,DC=contuso,DC=com"
"CN=Schema Admins,CN=Users,DC=contuso,DC=com"
"CN=Exchange Domain Servers,CN=Ussers,DC=contuso,DC=com"
"CN=Domain Users,CN=Users,DC=contuso,DC=com"
"CN=Enterprise Admins,CN=Users,DC=contuso,DC=com"
"CN=Group Policy Creator Owners,CN=Users,DC=contuso,DC=com"
"CN=Domain Admins,CN=Users,DC=contuso,DC=com"
"CN=Exchange Enterprise Servers,CN=Users,DC=contuso,DC=com"
"CN=Pre-Windows 2000 Compatible Access,CN=Builtin,DC=contuso,DC=com"
"CN=Users,CN=Builtin,DC=contuso,DC=com"
I just need the first CN value from this. My problem is that I don't
know how to deal with multiple words...
I want to stop on the first comma... but as anything that will match
anything is "greedy" I get all the way to the very last comma, rather
than the first if I try
/"CN=(.*),/
yet I don't konw how many words with spaces between them there are
going to be in the common name. Could be one, could be five or
anything in between.
Seems like it should be simple, but my brain is fried today, can
anyone please help me out with matching this?
Thanks
------------------------------
Date: Wed, 18 Jul 2007 10:37:29 +0000
From: Peter Makholm <peter@makholm.net>
Subject: Re: regex to help with LDAP
Message-Id: <87hco2t2ty.fsf@hacking.dk>
jogdial <jogdial@gmail.com> writes:
> I want to stop on the first comma... but as anything that will match
> anything is "greedy" I get all the way to the very last comma, rather
> than the first if I try
>
> /"CN=(.*),/
Try reading the perlre documentation. Search for 'greedy' and see if
it helps.
//Makholm
------------------------------
Date: 18 Jul 2007 11:08:23 GMT
From: jt@toerring.de (Jens Thoms Toerring)
Subject: Re: regex to help with LDAP
Message-Id: <5g6al7F3dt3lrU2@mid.uni-berlin.de>
jogdial <jogdial@gmail.com> wrote:
> Hi, My Perl is very rusty and I'm having huge problems trying to pull
> a common name out of a distinguished name.
> The distinguished name(s) example:
> "CN=KLAdmins,CN=Users,DC=contuso,DC=com"
> "CN=EMLibrary Users,CN=Users,DC=contuso,DC=com"
> "CN=Administrators,CN=Builtin,DC=contuso,DC=com"
> "CN=Schema Admins,CN=Users,DC=contuso,DC=com"
> "CN=Exchange Domain Servers,CN=Ussers,DC=contuso,DC=com"
> "CN=Domain Users,CN=Users,DC=contuso,DC=com"
> "CN=Enterprise Admins,CN=Users,DC=contuso,DC=com"
> "CN=Group Policy Creator Owners,CN=Users,DC=contuso,DC=com"
> "CN=Domain Admins,CN=Users,DC=contuso,DC=com"
> "CN=Exchange Enterprise Servers,CN=Users,DC=contuso,DC=com"
> "CN=Pre-Windows 2000 Compatible Access,CN=Builtin,DC=contuso,DC=com"
> "CN=Users,CN=Builtin,DC=contuso,DC=com"
> I just need the first CN value from this. My problem is that I don't
> know how to deal with multiple words...
> I want to stop on the first comma... but as anything that will match
> anything is "greedy" I get all the way to the very last comma, rather
> than the first if I try
> /"CN=(.*),/
> yet I don't konw how many words with spaces between them there are
> going to be in the common name. Could be one, could be five or
> anything in between.
> Seems like it should be simple, but my brain is fried today, can
> anyone please help me out with matching this?
What about
/^"CN=([^,]*)/
i.e. accept all characters except a ',' (I did throw in the '^' at
the start since I suspect you only want to match at the start of a
line)?
Regards, Jens
--
\ Jens Thoms Toerring ___ jt@toerring.de
\__________________________ http://toerring.de
------------------------------
Date: Wed, 18 Jul 2007 13:36:32 +0200
From: Mirco Wahab <wahab@chemie.uni-halle.de>
Subject: Re: regex to help with LDAP
Message-Id: <f7ktvv$1jl6$1@nserver.hrz.tu-freiberg.de>
jogdial wrote:
> I just need the first CN value from this. My problem is that I don't
> know how to deal with multiple words...
>
> I want to stop on the first comma... but as anything that will match
> anything is "greedy" I get all the way to the very last comma, rather
> than the first if I try
>
> /"CN=(.*),/
>
> yet I don't konw how many words with spaces between them there are
> going to be in the common name. Could be one, could be five or
> anything in between.
>
In addition to the regular solutions posted or mentioned,
you could, corresponding to your real intention, split
on the tags, like:
...
my @stuff = grep length, split/\n/,'
"CN=KLAdmins,CN=Users,DC=contuso,DC=com"
"CN=EMLibrary Users,CN=Users,DC=contuso,DC=com"
"CN=Administrators,CN=Builtin,DC=contuso,DC=com"
"CN=Schema Admins,CN=Users,DC=contuso,DC=com"
"CN=Exchange Domain Servers,CN=Ussers,DC=contuso,DC=com"
"CN=Domain Users,CN=Users,DC=contuso,DC=com"
"CN=Enterprise Admins,CN=Users,DC=contuso,DC=com"
"CN=Group Policy Creator Owners,CN=Users,DC=contuso,DC=com"
"CN=Domain Admins,CN=Users,DC=contuso,DC=com"
"CN=Exchange Enterprise Servers,CN=Users,DC=contuso,DC=com"
"CN=Pre-Windows 2000 Compatible Access,CN=Builtin,DC=contuso,DC=com"
"CN=Users,CN=Builtin,DC=contuso,DC=com"
';
print
+(split /[",][CD][CN]=/)[1] . "\n"
for @stuff;
...
The [1] after the split gives you the first elements (names),
the [2] the second elements and so on ...
Regards
Mirco
------------------------------
Date: Wed, 18 Jul 2007 06:17:00 -0700
From: Xah Lee <xah@xahlee.org>
Subject: Re: The Modernization of Emacs: exists already
Message-Id: <1184764620.778937.264760@m37g2000prh.googlegroups.com>
About a month ago, i posted a message about modernization of emacs. I
enlisted several items that i think emacs should adapt.
Today I added another section to the frequestly asked questions.
The new section is pasted below. The full article can be found at
http://xahlee.org/emacs/modernization.html
------------------------------
Q: The Meta key is logical and proper, it shouldn't be renamed to Alt.
A: Most computer geekers think that the so-called "Meta" key of Emacs
is a more general and logical naming, and they believe in Emacs
documentation the term "Meta key" should not be called the "Alt key"
to fit the mundane PC keyboard.
[image]
above: The Space-cadet keyboard (Source , 2007-07) .
Emacs's naming of Meta key isn't actually a general naming scheme. It
is simply the name of a special modifier key on a particular keyboard
popularly used with Emacs in the 1980s. (see Space-cadet keyboard ) On
this keyboard, it has several modifier keys, including Ctrl, Meta,
Super, Hyper. The Emacs's use of the term "Meta key" simply referred
to that key on that keyboard. Emacs actually also support the other
modifier keys Super and Hyper to this day. The Space-cadet keyboard
fell out of use along with Lisp machine . The IBM PC keyboard (and
its decendents) becomes the most popular since the 1990s and is
practically the standard keyboard used today. The IBM PC keyboard does
not have Super and Hyper keys, so Emacs's support for them becomes
little known, but Ctrl remains Ctrl while Meta is mapped to the Alt
key.
In Emacs's documentation, the term Meta key should be replaced with
the Alt key, to reflect current usage, since that is the keyboard 99%
of personal computer users know. The "Meta key" name is a major point
of confusion for getting people to learn Emacs. The abbreviation C-
<key> and M-<key> to represent keyboard shortcuts should similarly be
updated to the more easy-to-understand and universal Ctrl-<key> and
Alt-<key>.
Xah
xah@xahlee.org
http://xahlee.org/
------------------------------
Date: Wed, 18 Jul 2007 16:43:27 +0200
From: Wolfgang Mederle <walthervondervogelweide@gmx.de>
Subject: Re: The Modernization of Emacs: exists already
Message-Id: <yj9vechwz5c.fsf@elvis.mederle.de>
Xah Lee wrote:
> In Emacs's documentation, the term Meta key should be replaced with
> the Alt key, to reflect current usage, since that is the keyboard 99%
> of personal computer users know. The "Meta key" name is a major point
> of confusion for getting people to learn Emacs.
This is utter bullshit. On my Mac, the Meta key is mapped to the Command
key, while the Alt (Option) key is used by the system.
Follow-up to comp.emacs.
------------------------------
Date: Wed, 18 Jul 2007 07:34:28 -0700
From: hl <luhaorice@gmail.com>
Subject: uncleared data on serial port problem
Message-Id: <1184769268.325760.68800@g12g2000prg.googlegroups.com>
Hello all,
I am trying to write a simple perl script communicate with my
serial port. Every one second, it will send a command to a
specific device(keithley 2400); and the device will response
with
some data. The problem I have right now is after the correct
first
command, the code will precede the command with the previous
data
from the device.
I am using activeperl 5.8.8 on Windows XP Home.
Here is the code:
# ==============================
open (FH,'+<','COM1') or die "failed to open serial port: $!";
open (OUT,'>',"DATA.txt") or die "failed to open data file: $!";
sub clearup {
close(FH);
close(OUT);
exit;
}
$SIG{'INT'}=\&clearup;
$|=1;
while(1){
print FH "read?\n";
$dat=<FH>;
print OUT $dat;
sleep 1;
}
#==============end==============
The data I collected from a monitering software looks like(data not
real):
send: read?..
receive: 1.82331,3.1201,8.3883,1384,0120..
this is the problem--->send: 1.82331,3.1201,8.3883,1384,0120read?..
receive: 1.9339,3.8504,9.8383,1808,3930
Any suggestions?
Thanks!
--
------------------------------
Date: Wed, 18 Jul 2007 11:50:23 +0200
From: Thomas Peter <braindumped@expires-31-07-2007.news-group.org>
Subject: XML::Twig segfault on solaris
Message-Id: <1184752223.06@user.newsoffice.de>
Hi,
i use xml-twig to cut one xml-file into many small ones.
i do this by cutting out one node that holds all the elements that
should be seperated into many xml files in the structure of the original
document.
i iterate over that array (of cut nodes), add the current node to the
old xml-tree write it to a file, cut the current element from the tree
again and proceed to the next array element and so on.
i do this with a 3.6mb xml-file that is split into 300 files.
so far no problem. this works like a charm on windows with cygwin perl
and on linux. both 5.8.8. it takes ~31seconds to do the job, but no
problem.
but on solaris[1] i get a "Segmentation Fault (core dumped)".
This seg-fault appears when everything is done, the files are written
and the very last statement in my script (print finished) is processed.
i tried sun-perl 5.8.5 and self compiled 5.8.8
XML-Twig is in all cases 3.29 and XML::Parser version is 2.34
(the modules are the same version on windows, linux and solaris)
do you have any hint, what to debug or where to look at?
thanx in advance
thomas
[1] uname -a: SunOS gseual01 5.8 Generic_117350-38 sun4u sparc
SUNW,Sun-Fire-V440
------------------------------
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 V11 Issue 659
**************************************