[32084] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 3348 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Apr 11 16:09:30 2011

Date: Mon, 11 Apr 2011 13:09:09 -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, 11 Apr 2011     Volume: 11 Number: 3348

Today's topics:
        Changing XML tag value in Perl <rajpreetsidhu@gmail.com>
    Re: Changing XML tag value in Perl <cartercc@gmail.com>
    Re: FAQ flood MUST end <anfi@onet.eu>
    Re: FAQ flood MUST end <kkeller-usenet@wombat.san-francisco.ca.us>
    Re: FAQ flood MUST end <brian.d.foy@gmail.com>
    Re: FAQ flood MUST end <cartercc@gmail.com>
    Re: Perl 5.8 and Perl 5.10 Porting - Unicode Error <junk@dlink.org>
    Re: Perl 5.8 and Perl 5.10 Porting - Unicode Error <*@eli.users.panix.com>
    Re: Perl 5.8 and Perl 5.10 Porting - Unicode Error sln@netherlands.com
    Re: Perl 5.8 and Perl 5.10 Porting - Unicode Error sln@netherlands.com
    Re: strawberry perl installation error num 2908   Huh? (David Canzi)
    Re: strawberry perl installation error num 2908   Huh? (David Combs)
    Re: strawberry perl installation error num 2908   Huh? <rvtol+usenet@xs4all.nl>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Mon, 11 Apr 2011 11:10:49 -0700 (PDT)
From: Rajpreet <rajpreetsidhu@gmail.com>
Subject: Changing XML tag value in Perl
Message-Id: <9437f6a4-beb5-414c-9174-6a3f5fbb27ef@d12g2000vbz.googlegroups.com>

Greetings,

Requirement goes like this. I have perl script reading from a MQ
Series queue. This queue has messages in form of XML.For exmpale
1 message is like  -
<CLIENT_INFO>
	<LOCATION>
		New York
	</LOCATION>
	<FIELD>
	FINANCE GROUP
	</FIELD>
	<NO_OF_WORKERS>
	123
	</NO_OF_WORKERS>
<CLIENT_INFO>


My perl script reads messgaes from this queue, and drops them to
another queue after creating a backup in a text file. My requirement
is I have check the value of a particular tag for example, value of
<FIELD>, if that is  say "FINANCE GROUP", I have to change it to
"FINANCIAL SYSTEMS" and then drop to the other queue. I tried below,
but for some reason it did not work. COuld you please help.

Sample of my script -


# Connect to qmgr
$qmgr = MQSeries::QueueManager->new ( QueueManager => $hOpts{m},
AutoConnect => 0)
        or die "Unable to instantiate MQSeries::QueueManager object
\n";

$qmgr->Connect() or die("Unable to connect to queue manager\n" .
"CompCode => " . $qmgr->CompCode() . "\n" .  "Reason => " .
 $qmgr->Reason() .  " (", MQReasonToText($qmgr->Reason()) . ")\n");

# open input and output queues
my $qIn =MQSeries::Queue->new(QueueManager => $qmgr, Queue =>
$hOpts{i}, Options=>MQSeries::MQOO_INPUT_SHARED )
         or die "Unable to open queue $hOpts{i}" ;

my $qOut=MQSeries::Queue->new ( QueueManager => $qmgr, Queue =>
$hOpts{o}, Options=>MQSeries::MQOO_OUTPUT | MQSeries::MQPMO_S
ET_ALL_CONTEXT )
         or die "Unable to open queue $hOpts{o}" ;

until( $time_to_die )
{
        my $message = MQSeries::Message-
>new(MsgDesc=>{Persistence=>1});

	# Get message from queue
        $result = $qIn->Get( Message => $message, Sync=>1,
Wait=>-1 );
my $msgDescRef = $message->MsgDesc;
my $data = $message->Data;
my $field_name = GetXMLValue($data, "FIELD");
if ($field_name eq 'FINANCE GROUP')
{

$field_name = 'FINANCIAL SYSTEMS';

$msgDescRef->{"FIELD"} = $field_name ;
}
        for(1..$num_retries) {
                $result = $qOut->Put( Message => $message, Sync => 1,
                                PutMsgOpts
=>{ Options=>MQSeries::MQPMO_SET_ALL_CONTEXT ||
 
MQSeries::MQPMO_FAIL_IF_QUIESCING});
                if ($result > 0) { last; }

                sleep $time_to_wait;
        }




------------------------------

Date: Mon, 11 Apr 2011 12:26:07 -0700 (PDT)
From: ccc31807 <cartercc@gmail.com>
Subject: Re: Changing XML tag value in Perl
Message-Id: <44c85303-29a5-4523-90f3-412968c09fbf@d28g2000yqf.googlegroups.com>

On Apr 11, 2:10=A0pm, Rajpreet <rajpreetsi...@gmail.com> wrote:
> My perl script reads messgaes from this queue, and drops them to
> another queue after creating a backup in a text file. My requirement
> is I have check the value of a particular tag for example, value of
> <FIELD>, if that is =A0say "FINANCE GROUP", I have to change it to
> "FINANCIAL SYSTEMS" and then drop to the other queue.

As a general rule, manipulation of data is much easier if you put it
into some data structure resident in memory. My strategy would be to
read your data into a multi-level hash, using the XML tags as keys,
and then iterate through the hash creating new keys and deleting old
ones as necessary. This is trivial if you have well formed XML, which
you apparently do.

I would recommend that you use XSLT, a tool which is designed for this
purpose. You can write an XSLT script that will do this
transformation. I've never called an XSLT script from a Perl script,
but it ought to be pretty easy.

I don't see any reason to use Perl for this job when a better tool is
available.

CC.


------------------------------

Date: Mon, 11 Apr 2011 19:31:42 +0200
From: Andrzej Adam Filip <anfi@onet.eu>
Subject: Re: FAQ flood MUST end
Message-Id: <dmt6aomfmu+B4B@tara.huge.strangled.net>

PerlFAQ Server <brian@theperlreview.com> wrote:
> This is an excerpt from the latest version perlfaq8.pod,  [...]

Could you limit rate of FAQ post flood to 25%-50% of all threads in the group?

-- 
[pl>en Andrew] Andrzej A. Filip : anfi@onet.eu : Andrzej.Filip@gmail.com
Call me bored, but don't call me boring.
  -- Larry Wall in <199705101952.MAA00756@wall.org>


------------------------------

Date: Mon, 11 Apr 2011 10:58:15 -0700
From: Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us>
Subject: Re: FAQ flood MUST end
Message-Id: <n2sb78x5im.ln2@goaway.wombat.san-francisco.ca.us>

On 2011-04-11, Andrzej Adam Filip <anfi@onet.eu> wrote:
> PerlFAQ Server <brian@theperlreview.com> wrote:
>> This is an excerpt from the latest version perlfaq8.pod,  [...]
>
> Could you limit rate of FAQ post flood to 25%-50% of all threads in the group?

What is the rationale for doing so?  Can't you simply killfile on ^FAQ
or some such?

--keith


-- 
kkeller-usenet@wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://www.therockgarden.ca/aolsfaq.txt
see X- headers for PGP signature information



------------------------------

Date: Mon, 11 Apr 2011 13:08:07 -0500
From: brian d foy <brian.d.foy@gmail.com>
Subject: Re: FAQ flood MUST end
Message-Id: <110420111308070481%brian.d.foy@gmail.com>

In article <dmt6aomfmu+B4B@tara.huge.strangled.net>, Andrzej Adam Filip
<anfi@onet.eu> wrote:

> PerlFAQ Server <brian@theperlreview.com> wrote:
> > This is an excerpt from the latest version perlfaq8.pod,  [...]
> 
> Could you limit rate of FAQ post flood to 25%-50% of all threads in the group?

I probably could spend a few hours to write a script that measures the
activity of the group and throttles the faq poster, but there are much
better things to do in life. If you don't want to see the FAQ, just
killfile them or score them down.

For what it's worth, this newsgroup is the reason that the FAQ is so
good. The readers in this group are the ones reporting most of the
errors, out-of-date examples, and other corrections. There's a lot of
benefit to posting the FAQs here, and there has been for years.


------------------------------

Date: Mon, 11 Apr 2011 12:16:32 -0700 (PDT)
From: ccc31807 <cartercc@gmail.com>
Subject: Re: FAQ flood MUST end
Message-Id: <81a18694-f64f-4899-95a1-50e08db7188c@f18g2000yqd.googlegroups.com>

On Apr 11, 1:31=A0pm, Andrzej Adam Filip <a...@onet.eu> wrote:
> Could you limit rate of FAQ post flood to 25%-50% of all threads in the g=
roup?

The FAQ posts are, for me, a valuable resource for keeping up-to-date
with Perl. I have a habit of reading through the documentation,
although normally by work takes precedence so that I mostly in
dereliction of it. The FAQs remind me on a daily basis of things that
I don't know but should, and of those things that I have forgotten. I
know that I'm not the only one that reads these FAQ posts regularly,
and I appreciate having these posts appear regularly.

As a note, the percentage depends on the number of other posts, and
the percentage approaches 100 percent as other posts decline, and 0
percent as other posts increase. How can you determine a target
percentage when you don't control the other posts?

CC.


------------------------------

Date: Sat, 9 Apr 2011 21:18:16 -0700 (PDT)
From: Aqua <junk@dlink.org>
Subject: Re: Perl 5.8 and Perl 5.10 Porting - Unicode Error
Message-Id: <a13328c5-2b2d-419e-8cd1-ca7c51bad3b6@l11g2000yqb.googlegroups.com>

> This works for me in 5.10.1:
>
> use charnames ':full';
>
> print "[\N{EN DASH}]\n";
> my $dash = "\N{EN DASH}";
> my $enre = qr"[${dash}]";
> print "$enre\n";
>
> A few quick stabs using eval didn't work.

Dear Eli,

My web server admins suddenly upgraded perl version to 5.10.x and I
was also suggested to use

$ReNumRng  = encode("UTF-8","qr/$ReNum[\N{EN DASH}]$ReNum/");

I am not sure here as I have so many references to different unicode
"long" names. I am using qr to pre-compile my regex and check for
matches on the strings.

Appreciate further suggestions.

Regards
Dominic


------------------------------

Date: Sun, 10 Apr 2011 17:47:14 +0000 (UTC)
From: Eli the Bearded <*@eli.users.panix.com>
Subject: Re: Perl 5.8 and Perl 5.10 Porting - Unicode Error
Message-Id: <eli$1104101342@qz.little-neck.ny.us>

In comp.lang.perl.misc, Aqua  <junk@dlink.org> wrote:
> My web server admins suddenly upgraded perl version to 5.10.x and I
> was also suggested to use
> 
> $ReNumRng  = encode("UTF-8","qr/$ReNum[\N{EN DASH}]$ReNum/");

That's not going to do what you/they expect: it isn't goint to
be a regexp in $ReNumRng, but the perl code for the regexp you
want.

> I am not sure here as I have so many references to different unicode
> "long" names. I am using qr to pre-compile my regex and check for
> matches on the strings.
> 
> Appreciate further suggestions.

It did give me an idea which seems to work: add "use utf8;" to your
scripts:

$ cat /tmp/charname
#!/usr/local/bin/perl -w
use strict;
use Encode;
use utf8;
use charnames ':full'; 

print "[\N{EN DASH}]\n";
my $dash = "\N{EN DASH}";
my $enre = qr"[${dash}]";
my $dashre = encode("UTF-8","qr/[\N{EN DASH}]/");

print "enre: $enre\n";
print "dashre: $dashre\n";
$_ = 'abc';
/$enre/;
/$dashre/;

__END__
$ perl5.10.1 /tmp/charname-e
[–]
enre: (?-xism:[–])
dashre: qr/[–]/
$

Elijah
------
can see the valid reasoning behind that change


------------------------------

Date: Sun, 10 Apr 2011 11:10:26 -0700
From: sln@netherlands.com
Subject: Re: Perl 5.8 and Perl 5.10 Porting - Unicode Error
Message-Id: <5is3q6dbpqvposb20v84894q7cdcl4ncg3@4ax.com>

On Sat, 9 Apr 2011 00:19:31 -0700 (PDT), Aqua <junk@dlink.org> wrote:

>I have a simple script
>
>=====
>use charnames ':full';
>
>$ReNum    = qr/(\\d+[A-Z]?)/i;
>$ReNumRng = qr/$ReNum[\N{EN DASH}]$ReNum/;
>$Line     = "foo";
>$Line     =~ /$ReNumRng/;
>=====
>
>This works in perl 5.8 and I am getting a big error in 5.10.
>
>Constant(\N{EN DASH}) unknown: (possibly a missing "use
>charnames ...") in regex
>; marked by <-- HERE in m/(?i-xsm:(\\d+[A-Z]?))[\N{EN DASH} <-- HERE ]
>(?i-xsm:(\
>\d+[A-Z]?))/ at C:\projects\test.pl line 4.
>

I verify this quirk on 5.10.

I always thought quoting in qr// is different than qq//.
I never quite trust qr// for constants when mixed with variables.

-sln


use strict;
use warnings;

use charnames ':full';

print "\n1:\t", qr/ a [\N{EN DASH}] b /, "\n";
print "\n2:\t", qq/ c [\N{EN DASH}] d /, "\n";

my $Dash     = qq/[\N{EN DASH}]/;
my $ReNum    = qr/(\d+[A-Z]?)/;
my $ReNumRng = qr/$ReNum$Dash$ReNum/;
print "\n3:\t$ReNumRng\n\n";

my $var = 'a';
print "----------------------\n";
print "\n", qr/ ${var} [\N{EN DASH}] b /, "\n";

__END__



1:	(?-xism: a [\N{EN DASH}] b )

2:	 c [–] d 

3:	(?-xism:(?-xism:(\d+[A-Z]?))[–](?-xism:(\d+[A-Z]?)))

----------------------
Constant(\N{EN DASH}) unknown: (possibly a missing "use charnames ...") in regex
; marked by <-- HERE in m/ a [\N{EN DASH} <-- HERE ] b / at pp.pl line 16.




------------------------------

Date: Sun, 10 Apr 2011 20:22:42 -0700
From: sln@netherlands.com
Subject: Re: Perl 5.8 and Perl 5.10 Porting - Unicode Error
Message-Id: <sqs4q6hp5qpbs0fga5940oku95uepff39q@4ax.com>

On Sun, 10 Apr 2011 11:10:26 -0700, sln@netherlands.com wrote:

>On Sat, 9 Apr 2011 00:19:31 -0700 (PDT), Aqua <junk@dlink.org> wrote:
>
>>I have a simple script
>>
>>=====
>>use charnames ':full';
>>
>>$ReNum    = qr/(\\d+[A-Z]?)/i;
>>$ReNumRng = qr/$ReNum[\N{EN DASH}]$ReNum/;
>>$Line     = "foo";
>>$Line     =~ /$ReNumRng/;
>>=====
>>
>>This works in perl 5.8 and I am getting a big error in 5.10.
>>
>>Constant(\N{EN DASH}) unknown: (possibly a missing "use
>>charnames ...") in regex
>>; marked by <-- HERE in m/(?i-xsm:(\\d+[A-Z]?))[\N{EN DASH} <-- HERE ]
>>(?i-xsm:(\
>>\d+[A-Z]?))/ at C:\projects\test.pl line 4.
>>
>
>I verify this quirk on 5.10.
>
>I always thought quoting in qr// is different than qq//.
>I never quite trust qr// for constants when mixed with variables.
>
>-sln
>
>
>use strict;
>use warnings;
>
>use charnames ':full';
>
>print "\n1:\t", qr/ a [\N{EN DASH}] b /, "\n";
>print "\n2:\t", qq/ c [\N{EN DASH}] d /, "\n";
>
>my $Dash     = qq/[\N{EN DASH}]/;
>my $ReNum    = qr/(\d+[A-Z]?)/;
>my $ReNumRng = qr/$ReNum$Dash$ReNum/;
>print "\n3:\t$ReNumRng\n\n";
>
>my $var = 'a';
>print "----------------------\n";
>print "\n", qr/ ${var} [\N{EN DASH}] b /, "\n";
>
>__END__
>
>
>
>1:	(?-xism: a [\N{EN DASH}] b )
>
>2:	 c [–] d 
>
>3:	(?-xism:(?-xism:(\d+[A-Z]?))[–](?-xism:(\d+[A-Z]?)))
>
>----------------------
>Constant(\N{EN DASH}) unknown: (possibly a missing "use charnames ...") in regex
>; marked by <-- HERE in m/ a [\N{EN DASH} <-- HERE ] b / at pp.pl line 16.
>

Add use re 'debug'; for some interresting insight as to what the use charnames module
seems to do. Its like a user defined function for Unicode properties, like \p{your function}
does.

-sln


------------------------------

Date: Sun, 10 Apr 2011 18:19:54 +0000 (UTC)
From: dmcanzi@remulak.uwaterloo.ca (David Canzi)
Subject: Re: strawberry perl installation error num 2908   Huh?
Message-Id: <inssca$u8m$1@rumours.uwaterloo.ca>

In article <inqv2p$s85$1@panix3.panix.com>,
David Combs <dkcombs@panix.com> wrote:
>
>Trying to load, on to xp, perl 5.12.
>
>Installation error meg:
>
>    strawbery perl setup
>
>    the installer has encountered an unexpected error installing this
>package.  This may indicate a problem with the package.  The error code
>is 2908.
>
>
>
>Any suggestions?

Search for 2908 in the strawberry perl documentation.

Search Google for: strawberry perl 2908

-- 
David Canzi		| Life is too short to point out every mistake. |


------------------------------

Date: Sun, 10 Apr 2011 21:59:02 +0000 (UTC)
From: dkcombs@panix.com (David Combs)
Subject: Re: strawberry perl installation error num 2908   Huh?
Message-Id: <int976$igv$4@reader1.panix.com>

In article <inssca$u8m$1@rumours.uwaterloo.ca>,
David Canzi <dmcanzi@remulak.uwaterloo.ca> wrote:
>In article <inqv2p$s85$1@panix3.panix.com>,
>David Combs <dkcombs@panix.com> wrote:
>>
>>Trying to load, on to xp, perl 5.12.
>>
>>Installation error meg:
>>
>>    strawbery perl setup
>>
>>    the installer has encountered an unexpected error installing this
>>package.  This may indicate a problem with the package.  The error code
>>is 2908.
>>
>>
>>
>>Any suggestions?
>
>Search for 2908 in the strawberry perl documentation.
>
>Search Google for: strawberry perl 2908
>
>-- 
>David Canzi		| Life is too short to point out every mistake. |

I did the google you suggested.  One guy said you have to use administrative
priviledges.  Well, here's the whole (short) thread (minus one signiture
quotation):


Comment on strawberry perl installation
Re: strawberry perl installation
by CountZero (Canon) on Jul 02, 2010 at 20:30 UTC
Error code 2908 for MSI is "Could not register component".
Try running the MSI installer under administrative privileges.

CountZero

[reply]
Re^2: strawberry perl installation
by rahed (Scribe) on Jul 03, 2010 at 12:39 UTC

That was it, thank you. That's been the first time I had to use the
administrator like this.

Radek
[reply]
Re: strawberry perl installation
by adsard (Initiate) on Dec 24, 2010 at 07:28 UTC

I too am facing the same problem and I am installing with a user
having administrative rights? Can there be some other cause to the
issue?

[reply]
Re^2: strawberry perl installation
by Anonymous Monk on Feb 07, 2011 at 03:14 UTC

I thought I was installing Strawberry Perl as administrator (Using the
default administrator logon that appears in Windows XP when you
haven't created any other users) but I kept getting error 2908. It
wasn't until I made a new user and gave them admin privileges that I
could install without that error. When is an admin not an admin? When
on Windows.

[reply]
Re: strawberry perl installation
by Anonymous Monk on Feb 14, 2011 at 13:19 UTC
Same problem!






So now I'll go see about admin priviledges, and will
report back.


David




------------------------------

Date: Mon, 11 Apr 2011 09:23:16 +0200
From: "Dr.Ruud" <rvtol+usenet@xs4all.nl>
Subject: Re: strawberry perl installation error num 2908   Huh?
Message-Id: <4da2ac64$0$41110$e4fe514c@news.xs4all.nl>

On 2011-04-10 23:59, David Combs wrote:

> So now I'll go see about admin priviledges, and will
> report back.

IIRC, you can right-click and then "Run as ...".

(though maybe that only exists on Win-NT)

-- 
Ruud


------------------------------

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 3348
***************************************


home help back first fref pref prev next nref lref last post