[28965] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 209 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Mar 9 11:10:03 2007

Date: Fri, 9 Mar 2007 08:09:04 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 9 Mar 2007     Volume: 11 Number: 209

Today's topics:
    Re: ${{ foo => bar, baz => faz }}{ baz } <bik.mido@tiscalinet.it>
    Re: ${{ foo => bar, baz => faz }}{ baz } <uri@stemsystems.com>
    Re: Error description. <rajendra.prasad@in.bosch.com>
    Re: How get cell count and match total column value <tadmc@augustmail.com>
    Re: How get cell count and match total column value <bik.mido@tiscalinet.it>
    Re: Killing threads in perl <zentara@highstream.net>
    Re: Net-SSH-W32Perl strange behaviour. chenws3000@gmail.com
    Re: Net::SMTP connection problems <simon.andrews@bbsrc.ac.uk>
    Re: Net::SMTP connection problems <prawnMUNG@prawn.me.uk>
    Re: Posting guidelines work <bik.mido@tiscalinet.it>
        Problems with XML::Parser::Lite <scobloke2@infotop.co.uk>
    Re: Question about scoping <megapode@gmail.com>
    Re: Tk::DropSite question <zentara@highstream.net>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 09 Mar 2007 12:55:44 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: ${{ foo => bar, baz => faz }}{ baz }
Message-Id: <rmi2v2lgdfc1atnsdf9kqjdga4gt6daapr@4ax.com>

On 9 Mar 2007 01:39:14 -0800, "Mons" <inthrax@gmail.com> wrote:

>What about if this name is long (for ex: $myBigObjectName-
>>getObjectType ).

Choose a shorter, more sensible name. Not too long, not too short.
Just the right(TM) length. Alias if necessary.


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Fri, 09 Mar 2007 10:15:11 -0500
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: ${{ foo => bar, baz => faz }}{ baz }
Message-Id: <x7slce1m9s.fsf@mail.sysarch.com>

>>>>> "MD" == Michele Dondi <bik.mido@tiscalinet.it> writes:

  MD> As a side note, the above dereferencing syntax works with a single
  MD> key, but not with multiple ones since

  MD>   }->{ $type1, $type2 }

  MD> may actually mean two different things and Perl choose the IMHO less
  MD> intuitive one. But maybe it was the most intuitive one when it was
  MD> introduced.

that is a case of backward compatibility with perl4. multiple hash keys
in scalar context was used as a pseudo multilevel hash in perl4 (keys
are joined with $; into a single key. works if no key has $; inside
it). this still is the case in perl5 but is rarely used. the problem
with making it truly a slice is the multilevel problem. you can slice at
the bottom most level with no problem but what does it mean at higher
levels? you would need to create a deep data structure on the fly and it
couldn't be used for anything but returning it (via a ref). perl6 does
have this but it is consistant with lazy eval and other things. it would
be very odd in perl5 and a clunky special case. 

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Fri, 9 Mar 2007 17:48:02 +0530
From: "rajendra" <rajendra.prasad@in.bosch.com>
Subject: Re: Error description.
Message-Id: <esriog$c0t$1@news4.fe.internet.bosch.com>

Hello All,


The actual error is "Free to wrong pool 1c7ef28 not 15d2cb8 during global
destruction." .


The error mentioned below was due to the fact that I had included the
package "Win32::OLE" in my code.


With Rgds,
Raj
"rajendra" <rajendra.prasad@in.bosch.com> wrote in message
news:esr7c4$uvh$1@news4.fe.internet.bosch.com...
> Hello All,
>
> Please assist me in rectifying the bbelow error.
>
> Win32::OLE(0.1701): GetOleObject() Not a Win32::OLE object during global
> destruction.
> Win32::OLE(0.1701): GetOleObject() Not a Win32::OLE object during global
> destruction.
> Free to wrong pool 95c1fc0 not 15d2cb8 during global destruction.
>
> With Rgds,
> Raj
>
>




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

Date: Fri, 9 Mar 2007 06:03:12 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: How get cell count and match total column value
Message-Id: <slrnev2j80.ek7.tadmc@tadmc30.august.net>

Rahul <sahoo.byomokesh@gmail.com> wrote:

> I am trying to cell count 


There are no cells.

You are trying to column count, I guess.


> and match in tgroup cols value in XML file
> (through perl). if cell count and tgrou cols value is mismatch, its
> showing error.
>
> My xml
> --------------
><tgroup cols="3">
><colspec colnum="1" colname="col1"/>
><colspec colnum="2" colname="col2"/>
><colspec colnum="3" colname="col3"/>
><tbody>


That is not XML.

Where is the endtag for tgroup and tbody?


> If someone could help..


You forgot to show us what you have tried so far.

Here's a fish anyway.

-----------------------
#!/usr/bin/perl
use warnings;
use strict;
use XML::Simple;

my $xml = '<tgroup cols="3">
<colspec colnum="1" colname="col1"/>
<colspec colnum="2" colname="col2"/>
<colspec colnum="3" colname="col3"/>
</tgroup>';

my $ref = XMLin( $xml );
my $cols = $ref->{cols};
my $colspec = @{ $ref->{colspec} };

print "showing error\n" unless $cols == $colspec;
-----------------------


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Fri, 09 Mar 2007 13:26:02 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: How get cell count and match total column value
Message-Id: <ack2v2pfk5mke6hqv4fa7j3t0esl8bnrgi@4ax.com>

On 9 Mar 2007 00:39:58 -0800, "Rahul" <sahoo.byomokesh@gmail.com>
wrote:

>I am trying to cell count and match in tgroup cols value in XML file
>(through perl). if cell count and tgrou cols value is mismatch, its
>showing error.
>
>My xml
>--------------
><tgroup cols="3">
><colspec colnum="1" colname="col1"/>
><colspec colnum="2" colname="col2"/>
><colspec colnum="3" colname="col3"/>
><tbody>

This is not your complete xml. Show us a minimal adaptation of it.
Show us also what output you would expect. Better yet: show us what
you've tried thus far and how it fails to work. Without knowing these
details, I may point you to some xml parsing module. If the xml is not
huge and you want something simple, you can try XML::Simple. Otherwise
someone will know better than me.


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Fri, 09 Mar 2007 12:30:39 GMT
From: zentara <zentara@highstream.net>
Subject: Re: Killing threads in perl
Message-Id: <slk2v21rfshfjg0uhueufk1v77mo0dcpk4@4ax.com>

On 9 Mar 2007 00:58:53 -0800, joergwenzel@gmx.de wrote:

>
>> Like:
>>
>> my $die:shared;
>> $die =0;
>>
>> #in thread code check for it:
>> if($die){return}
>>
>> If you don't detach, you still need to return from the thread
>> block, before a join can happen.
>>
>> Joining is preferred over detaching, because you can reuse
>> the thread, or it's space, and that will avoid gaining memory as
>> you constantly spawn threads.
>
>Yes, but my tar still running at the thread? My $return come back
>at the end of the tar. the next line of the script start behind the
>tar
>no "if" help me at this time.
>
>threads:
>
>1. running tar 50min   finished ok
>2. running tar 30min   breakup error
>3. running tar 90min   running  <-- to kill
>4. running tar 120min  running  <-- to kill
>

Without seeing your thread code, you have 2 options.
1. Write the tar procedure in chunks, and in between chunks,
test for $die.

2. Find the pid of the tar command after it's launched in the thread,
and put it in a shared variable. Then have the main thread kill -9 it,
before you set $die = 1.


Just ideas,
zentara


-- 
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html


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

Date: 9 Mar 2007 07:21:03 -0800
From: chenws3000@gmail.com
Subject: Re: Net-SSH-W32Perl strange behaviour.
Message-Id: <1173453663.133950.270590@n33g2000cwc.googlegroups.com>

On Mar 6, 3:54 am, fhorn...@gmail.com wrote:
> Hi,
>
> Well, I am currently stuck with a stange Perl behaviour.
> Indeed, I am trying to create a Perl SSH client script on Windows -
> but you have already noticed that in the title of this message :) -
> which could be connected on a Vandyke Vshell - SSH deamon for Ms
> Windows -.
>
> This is the content of my script I have mostly retreived from the CPAN
> web site -http://search.cpan.org/~scotts/Net-SSH-W32Perl-0.05/lib/Net/SSH/W32Pe...
> - :
>
>      use strict;
>      use warnings;
>      use Net::SSH::W32Perl;
>
>      &windows();
>
>      sub windows ()
>      {
>            my ($user,$pass,$host,$cmd)
> =("MY_USER","MY_PASSWORD","MY_MACHINE_ADDRESS","MY_NICE _COMMAND");
>            my $ssh = Net::SSH::W32Perl->new($host,protocole =>2, debug
> => 0);
>            $ssh->login($user, $pass);
>            my($stdout, $stderr, $exit) = $ssh->cmd($cmd);
>            print "Standard out: $stdout\nStandard Error: $stderr\nExit
> code: $exit\n";
>      }
>
> The problem is firstly it returns the following messages :
>
>     IO::Socket::INET at C:/Perl/site/lib/Net/SSH/Perl/SSH2.pm line 295
>     IO::Socket::INET at C:/Perl/site/lib/Net/SSH/Perl/SSH2.pm line 295
>     IO::String at C:/Perl/site/lib/Net/SSH/Perl/Channel.pm line 110
>     IO::Socket::INET at C:/Perl/site/lib/Net/SSH/Perl/SSH2.pm line 295
>     IO::String at C:/Perl/site/lib/Net/SSH/Perl/Channel.pm line 110
>     IO::Socket::INET at C:/Perl/site/lib/Net/SSH/Perl/SSH2.pm line 295
>     IO::String at C:/Perl/site/lib/Net/SSH/Perl/Channel.pm line 110
>     IO::Socket::INET at C:/Perl/site/lib/Net/SSH/Perl/SSH2.pm line 295
>     IO::String at C:/Perl/site/lib/Net/SSH/Perl/Channel.pm line 110
>     IO::Socket::INET at C:/Perl/site/lib/Net/SSH/Perl/SSH2.pm line 295
>     IO::String at C:/Perl/site/lib/Net/SSH/Perl/Channel.pm line 110
>     IO::Socket::INET at C:/Perl/site/lib/Net/SSH/Perl/SSH2.pm line 295
>     IO::String at C:/Perl/site/lib/Net/SSH/Perl/Channel.pm line 110
>     IO::Socket::INET at C:/Perl/site/lib/Net/SSH/Perl/SSH2.pm line 295
>     IO::String at C:/Perl/site/lib/Net/SSH/Perl/Channel.pm line 110
>     IO::String at C:/Perl/site/lib/Net/SSH/Perl/Channel.pm line 118
>     IO::Socket::INET at C:/Perl/site/lib/Net/SSH/Perl/SSH2.pm line 295
>     IO::String at C:/Perl/site/lib/Net/SSH/Perl/Channel.pm line 110
>     IO::Socket::INET at C:/Perl/site/lib/Net/SSH/Perl/SSH2.pm line 295
>     IO::String at C:/Perl/site/lib/Net/SSH/Perl/Channel.pm line 110
>
> Ok, I agree despite this message it return the correct result.
> Well, sometime ! - I am going to explain below -
>
> In fact, it returns the correct result only the first or the second
> time you launch it.
> Otherwise, it freezes.
> Behaviour that I do not really want. ;)
>
> So, this is the ouput of this program during its execution but in
> debug mode :
>
>     machinename: Reading configuration data /.ssh/config
>     machinename: Reading configuration data /etc/ssh_config
>     machinename: Connecting to localhost, port 22.
>     machinename: Socket created, turning on blocking...
>     machinename: Remote protocol version 2.0, remote software version
> VShell_2_6_4_4
> 8 VShell
>     machinename: Net::SSH::Perl Version 1.23_01, protocol version 2.0.
>     machinename: No compat match: VShell_2_6_4_448 VShell
>     machinename: Connection established.
>     machinename: Sent key-exchange init (KEXINIT), wait response.
>     machinename: Algorithms, c->s: 3des-cbc hmac-sha1 none
>     machinename: Algorithms, s->c: 3des-cbc hmac-sha1 none
>     machinename: Entering Diffie-Hellman Group 1 key exchange.
>     machinename: Sent DH public key, waiting for reply.
>     machinename: Received host key, type 'ssh-dss'.
>     machinename: Host 'localhost' is known and matches the host key.
>     machinename: Computing shared secret key.
>     machinename: Verifying server signature.
>     machinename: Waiting for NEWKEYS message.
>     machinename: Enabling incoming encryption/MAC/compression.
>     machinename: Send NEWKEYS, enable outgoing encryption/MAC/
> compression.
>     machinename: Sending request for user-authentication service.
>     machinename: Service accepted: ssh-userauth.
>     machinename: Trying empty user-authentication request.
>     machinename: Authentication methods that can continue: password.
>     machinename: Next method to try is password.
>     machinename: Trying password authentication.
>     machinename: Login completed, opening dummy shell channel.
>     machinename: channel 0: new [client-session]
>     machinename: Requesting channel_open for channel 0.
>     machinename: channel 0: open confirm rwindow 32768 rmax 16384
>     machinename: Got channel open confirmation, requesting shell.
>     machinename: Requesting service shell on channel 0.
>     machinename: channel 1: new [client-session]
>     machinename: Requesting channel_open for channel 1.
>     machinename: Entering interactive session.
>     IO::Socket::INET at C:/Perl/site/lib/Net/SSH/Perl/SSH2.pm line 295
>     machinename: Sending command: cluster localhost group /status
>     machinename: Requesting service exec on channel 1.
>     machinename: channel 1: open confirm rwindow 32768 rmax 16384
>     IO::Socket::INET at C:/Perl/site/lib/Net/SSH/Perl/SSH2.pm line 295
>     IO::String at C:/Perl/site/lib/Net/SSH/Perl/Channel.pm line 110
>     IO::Socket::INET at C:/Perl/site/lib/Net/SSH/Perl/SSH2.pm line 295
>     IO::String at C:/Perl/site/lib/Net/SSH/Perl/Channel.pm line 110
>     IO::Socket::INET at C:/Perl/site/lib/Net/SSH/Perl/SSH2.pm line 295
>     IO::String at C:/Perl/site/lib/Net/SSH/Perl/Channel.pm line 110
>     IO::Socket::INET at C:/Perl/site/lib/Net/SSH/Perl/SSH2.pm line 295
>     IO::String at C:/Perl/site/lib/Net/SSH/Perl/Channel.pm line 110
>     IO::Socket::INET at C:/Perl/site/lib/Net/SSH/Perl/SSH2.pm line 295
>     IO::String at C:/Perl/site/lib/Net/SSH/Perl/Channel.pm line 110
>     IO::Socket::INET at C:/Perl/site/lib/Net/SSH/Perl/SSH2.pm line 295
>     IO::String at C:/Perl/site/lib/Net/SSH/Perl/Channel.pm line 110
>     IO::Socket::INET at C:/Perl/site/lib/Net/SSH/Perl/SSH2.pm line 295
>     IO::String at C:/Perl/site/lib/Net/SSH/Perl/Channel.pm line 110
>     IO::String at C:/Perl/site/lib/Net/SSH/Perl/Channel.pm line 118
>     IO::Socket::INET at C:/Perl/site/lib/Net/SSH/Perl/SSH2.pm line 295
>     IO::String at C:/Perl/site/lib/Net/SSH/Perl/Channel.pm line 110
>
> Now, cherry on the cake!
> I have tried to do the same test with an OpenSSH deamon - for the
> server side, I mean -.
> Ok, I always have the error message :
>
>     IO::Socket::INET at C:/Perl/site/lib/Net/SSH/Perl/SSH2.pm line 295
>     IO::String at C:/Perl/site/lib/Net/SSH/Perl/Channel.pm line 110
>     BlaBla...
>
> But in contrary of Vshell the Perl SSH client script does not seem
> stuck.
> it runs every time.
>
> This what I have noticed :
> With Vandyke VShell, the script uses
>
>     machinename: channel 0: open confirm rwindow 32768 rmax 16384
>
> However with OpenSSH, the script uses :
>
>     machinename: channel 1: open confirm rwindow 0 rmax 32768
>
> So I have got five questions :
>
>      - How can I make my little Perl SSH Client script work ?
>      - How can I fix error message during the Perl script execution ?
>      - Why there is difference between Vshell and OpenSsh with the SSH
> packet window size ?
>      - Is there a way to specify the SSH packet window size in Perl?
>      - Could you give me a hand please ?
>
> Thanks a lot in advance.
> BR
> Fred

RE: How can I fix error message during the Perl script execution ?

I meet the same problem those days, and I try to find the solution
from internet.
However, there are few info about this issue. So I decide to dug it by
myself. When I debug the script into Carp.pm (version 1.04). I find
the reason.

in line 271 just replace

sub carp    { warn shortmess @_ }

to

sub carp { }

all strange messages are gone.

Vincent Chen




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

Date: Fri, 09 Mar 2007 15:01:34 +0000
From: Simon Andrews <simon.andrews@bbsrc.ac.uk>
Subject: Re: Net::SMTP connection problems
Message-Id: <esrsse$2tp$1@south.jnrs.ja.net>

Sisyphus wrote:
> 
> "Simon Andrews" <simon.andrews@bbsrc.ac.uk> wrote in message 
> news:esorml$3rr$1@south.jnrs.ja.net...
> .
> .
>>
>> #!perl
>> use warnings;
>> use strict;
>> use Net::SMTP;
>>
>> my $smtp = Net::SMTP->new('smtp',
>>   Timeout => 60,
>>   Debug => 1);
>>
>> print "Result was '$smtp' from ".$Net::SMTP::VERSION;
>>
>>
>> .. which gets me:
>>
>> Result was '' from 2.29 (plus an uninitialised value warning from 
>> trying to print $smtp.  It seems the connection is failing before the 
>> socket is even created.
>>
> 
> Yep - I get exactly the same. On my box, I expect it's because there's 
> no accessible mail host by the name of 'smtp'.
> Does specifying 'smtp' as the mail host normally work for you ? (eg, is 
> that's what specified on the linux boxes where the program *does* work ?)

It's not that.  The name smtp does resolve correctly on this machine and 
the connection fails even if I use the fully qualified name or even the 
IP address.  Also using just smtp works fine if specified in the 
Thunderbird config on this same machine.

My latest suspect for this is the Surf Control system we are forced to 
use here, which has been known to interfere with port 25, although that 
shouldn't produce different results on a per-application basis.

Is there more than one way to make a socket connection (at any level in 
the IP stack) such that Perl and Thunderbird could be doing something 
which appeared different to the receiving server?

Simon.


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

Date: Fri, 9 Mar 2007 15:45:12 +0000
From: prawn <prawnMUNG@prawn.me.uk>
Subject: Re: Net::SMTP connection problems
Message-Id: <81c8c4-h78.ln1@eddie.ryet.co.uk>

On Fri, 09 Mar 2007 15:01:34 +0000, Simon Andrews wrote:

> It's not that.  The name smtp does resolve correctly on this machine and 
> the connection fails even if I use the fully qualified name or even the 
> IP address.  Also using just smtp works fine if specified in the 
> Thunderbird config on this same machine.

Odd, I have run your code on my localhost and it works.  Sooo...

> My latest suspect for this is the Surf Control system we are forced to 
> use here, which has been known to interfere with port 25, although that 
> shouldn't produce different results on a per-application basis. 

Try downloading Wireshark [1] http://wireshark.org and see what happens
when you send mail with your client of choice and compare with your perl
code.

HTH

[1] Formerly Ethereal.
-- 
p BotM#1 LotR#9


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

Date: Fri, 09 Mar 2007 14:58:47 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Posting guidelines work
Message-Id: <rhp2v21o3tpcghfbt8t5mt8f1udenfg8fn@4ax.com>

On Thu, 08 Mar 2007 23:15:49 GMT, "A. Sinan Unur"
<1usa@llenroc.ude.invalid> wrote:

>My post was both a reflection of my elation and re-realization that if I 
>just start preparing a post for this group when I get stuck, I will manage 
>to extricate myself without needing to actually post the question ;-)

Well, to mention a case that occurred to me quite recently, I had a
oneliner I posted to someone else, featuring a lookahed. I can't
remember what it was, exactly, but it may have been something along
the lines of

  perl -lpe 's/\d+(?=bar$)//'

Only, when I layed it down, it was

  perl -lpe 's/\d+(?=bar)$//'

Obviously, the latter didn't work. But however stupid it may sound I
couldn't understand why I had to write it as in the former to make it
work. And I was about to write a post about this "issue" either here
or in PerlMonks -I can't remember- when suddenly I asked myself: and
if it were 'a' instead of '$'? And the answer was clear to me, and I
saved an embarassing post. Only to postpone it up until... NOW!  :-)


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Fri, 09 Mar 2007 16:03:39 +0000
From: Ian Wilson <scobloke2@infotop.co.uk>
Subject: Problems with XML::Parser::Lite
Message-Id: <45f18567$0$2460$db0fefd9@news.zen.co.uk>

Using Perl 5.8.0 on Unix, I am trying to parse some XML using 
XML::Parser::Lite.

I keep running into errors that I find puzzling. The program below works 
fine as written. However in handle_char(), if I uncomment the lines
that use $val_string I get a parsing error or a core dump!

What am I doing wrong?


#!/usr/bin/perl
#
use strict;
use warnings;
use XML::Parser::Lite;

my $xml = <<EndXML;
<Order>
   <OrderHead>
     <Schema>
       <Version>3.09</Version>
     </Schema>
   </OrderHead>
   <OrderLine>
     <LineNumber>1</LineNumber>
     <Product>
       <SupplierProductCode>ABC123</SupplierProductCode>
     </Product>
     <Quantity>
       <Amount>15</Amount>
     </Quantity>
   </OrderLine>
   <OrderLine>
     <LineNumber>2</LineNumber>
     <Product>
       <SupplierProductCode>XYZ900</SupplierProductCode>
     </Product>
     <Quantity>
       <Amount>29</Amount>
     </Quantity>
   </OrderLine>
</Order>
EndXML

my $parser = new XML::Parser::Lite;
$parser->setHandlers(
   Start => \&handle_start,
   Char =>  \&handle_char,
   End =>   \&handle_end
);
$parser->parse($xml);


sub handle_start {
   shift;
   my $element = shift;

   print "Start: '$element'\n";
}


sub handle_char {
   shift;
   my $val_string = shift;

   #$val_string =~ s/\s+/ /;     # Err: not properly closed tag 'Order'
   #if ($val_string =~ m/^[\s\n]*$/) {   # Core dump!
   #  print "Char :    __whitespace__\n";
   #} else {

     print "Char :   '$val_string'\n";
   #}
}


sub handle_end {
   shift;
   my $element = shift;

   print "End..: '$element' \n";
}


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

Date: 9 Mar 2007 06:58:09 -0800
From: "Bob Dubery" <megapode@gmail.com>
Subject: Re: Question about scoping
Message-Id: <1173452289.834407.258600@j27g2000cwj.googlegroups.com>

On Mar 5, 8:57 am, Ben Morrow <b...@morrow.me.uk> wrote:
> Quoth "Bob Dubery" <megap...@gmail.com>:
>
> > John's reply was informative, but it did not address my immediate
> > concern.
>
> > However, I think I may have moved on to a state where I remain
> > confused, but confused at a higher level :-)
>
> > Considering this....
> > eval {new XML::DOM::Parser->parse($headerFile)};
>
> I'm amazed this syntax works at all. It appears to be parsed as
>
>     eval { (new XML::DOM::Parser)->parse($headerFile) };
>
> or
>
>     eval { XML::DOM::Parser->new->parse($headerFile) };
>
> which would be the recommended way to write it. The indirect object
> notation ('new Foo' as opposed to 'Foo->new') is considered to have been
> a bad idea: it confuses the reader, and under the wrong circumstances it
> can confuse Perl.

Well thanks for that. I will try making that change to this program.

>
> > Is it the case that because neither the parser object nor the results
> > of the eval are assigned to any kind of variable that either or both
> > are regarded as barewords?
>
> Err... no. What do you think a 'bareword' is? It's actually an
> expression like XML::DOM::Parser or STDOUT that Perl parses as a string
> even though it isn't quoted: hence 'bare'.
>
> Since you haven't posted a complete program, I can't tell what you are
> trying to achieve; but I would guess that you don't want to throw away
> the result of the parse.

This is a program written by somebody else. It's a "listener". It is
started up and "listens" for messages coming in on a certain port. The
incoming messages each contain two XML documents - one is a routing
header and the second is the actual payload.

I initially thought it had a memory leak as it kept on using more and
more memory until eventually it either fell over or the server just
ran out of resources.

I started trying to figure out why this was happening, and the only
thing that seemed potentially troublesome was the use of the XML
parser.

In fact the results of the parse were NOT being used. The parsing was
only done to check that both XML documents were well-formed. If either
was not well-formed then an error message had to be entered into a
log, and a signal sent back out on the socket indicating a "nack".

My thinking was that by not explicitly assigning the parser objects to
a variable, thus making it impossible to close them, some resources
used by instances of the parser were not being released.

Since I changed the statement that you're commenting on to something
like
my $bodyXML = eval {new XML::DOM::Parser- >parse($bodyFile)};

and going on to perform a $bodyXML->dispose()

the listener has run more reliably and memory usage is reduced. It is
still creeping up with time, but much more slowly.

So I'm going to try the alternate notation that you offer and see if
that brings a further improvement.

Thanks

Bob




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

Date: Fri, 09 Mar 2007 07:26:36 -0500
From: zentara <zentara@highstream.net>
Subject: Re: Tk::DropSite question
Message-Id: <khj2v2tgpdkd2bjp79rsp0s505k19klntr@4ax.com>

On Fri, 9 Mar 2007 01:36:13 -0500, "~greg" <g_m@remove-comcast.net>
wrote:
>
>And that isn't the only problem with Windows security.
>But as far as I'm concerned it's the most annoying one,
>--because it's what makes it totally impossible
>to at the same time both freely, and safely, surf the internet.
>
>And since Vista will, finally, be doing the sand-box thing,
>(like java) - then I can't believe it couldn't have been done sooner.

I've heard that the biggest complaint new Vista users have
is that they get bombarded with so many "do you trust" questions,
that they are forced to turn it off, rendering it useless.

Why not use linux for the internet? :-)

>> But what I meant was that Tk's Drag'n'Drop is hard enough
>> to get going with it's own Tk widgets, and that trying to do
>> a drop from an non-Tk app is pushing the limits, especially
>> on Windows.
>> ( most Perl was written with linux/unix type systems in mind)
>
>
>I think I recall once trying to use it to drag and drop
>between two Tk-widgets, and gave up. But I don't
>remember why.

Probably because the example didn't work. :-)

>Oddly, though, it's working beautifully for me now,
>DND between Windows Explorer and a Tk-widget.
>And it seems to be very robust. I can drag and drop
>a thousand files for example  - which is way past
>the limit that can be "Send to"  (-without a lot of extra
>work) for example. (--it's a windows thing.)
>~greg

It would be nice if you would post it, anonymously if
desired, in the Snippets section at http://perlmonks.org

so others can try it out, and see your technique.
I would be interested, if you can drag in the other direction,
from Tk to Explorer?

For what it's worth, the only example of inter-tk dnd
that I could get working is at
 http://zentara.net/perlplay/tkdnd/tkdnd.tgz

It is based on Lidie's tutorial, but slightly modified to work. :-)

If you run the ztest, you can drag from one window to the other,
but only in one direction. The logic needed to switch from
drag source to drop site, still eludes me.

Just to shoot the breeze, Perl/Gtk2 has DND too, and
I believe it to be better. But Perl/Gtk2 can be a bear
to install on windows.
See:
http://live.gnome.org/GnomeLove/DragNDropTutorial


zentara


-- 
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html


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

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


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