[24927] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7177 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Sep 25 18:06:46 2004

Date: Sat, 25 Sep 2004 15:05: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           Sat, 25 Sep 2004     Volume: 10 Number: 7177

Today's topics:
    Re: [newbie] decode the form information <tadmc@augustmail.com>
    Re: few question about array <see@sig.invalid>
    Re: few question about array <tadmc@augustmail.com>
    Re: few question about array <nobull@mail.com>
    Re: Help with my brute force method <tadmc@augustmail.com>
    Re: Help with my brute force method <tadmc@augustmail.com>
    Re: Help with my brute force method (Anno Siegel)
    Re: Printing regex match <me@home.net>
    Re: Untainting a filehandle <nobull@mail.com>
    Re: Untainting a filehandle <nobull@mail.com>
    Re: Untainting a filehandle (Anno Siegel)
    Re: what's wrong in this Perl Regex expression? <end@dream.life>
    Re: what's wrong in this Perl Regex expression? <tadmc@augustmail.com>
    Re: what's wrong in this Perl Regex expression? <tadmc@augustmail.com>
    Re: what's wrong in this Perl Regex expression? <daveandniki@ntlworld.com>
    Re: what's wrong in this Perl Regex expression? (Mr. M.J. Lush)
        Win32::CtrlGUI <mikeflan@earthlink.net>
    Re: Win32::CtrlGUI <1usa@llenroc.ude.invalid>
        XML::Twig <pam4prezNOSPAM@hotmail.com>
    Re: XML::Twig <nobull@mail.com>
    Re: XML::Twig <tadmc@augustmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sat, 25 Sep 2004 12:08:55 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: [newbie] decode the form information
Message-Id: <slrnclb9h7.qpk.tadmc@magna.augustmail.com>

Larry <dontmesswithme@got.it> wrote:

> (please don't reply telling me to use CGI.pm because i need to get this 
> code working)


It will take *less* time to get CGI.pm working than to repair
your broken code.

If you a truly in a hurry, then give up on what you have and
replace it with a proper module.


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


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

Date: Sat, 25 Sep 2004 11:11:38 -0400
From: Bob Walton <see@sig.invalid>
Subject: Re: few question about array
Message-Id: <415588cf$1_5@127.0.0.1>

Andrea Spitaleri wrote:
> Hi I have few quick question about array:
> 1. reading a file as array, that below code works but I want be sure
> that it is correct that portion
> I am in doubt about the $numb[$countmol].

use strict;
use warnings;
#let Perl help you

> open (IN,"in") || die "$!";
> @in=<IN>;
> clode IN;
s----^
Please show us your copy/pasted real code; don't re-type

> my $i;
> for ($i=0;$i<$#in;++$i){
>     chomp $i;
Why are you chomp()ing a numeric value??  Perhaps you meant chomp(@in); 
earlier??

>     my $countmol=0;
>      if($in[$i]=~ /^@<TRIPOS>ATOM/){
>         $initial=$i;
>         $endmol=$number_atoms + $i;
>         for($k=$initial;$k<$endmol;++$k){
>             @coord=split(/ +/,$inmol[$k+1]);
> #that is it correct?? $numb[$countmol] is different from $numb[$i].
Probably not, since you never reference @inmol anywhere else, as Perl 
would have told you if you use warnings;use strict;
>             $numb[$countmol]=$coord[1];
>             $atom[$countmol]=$coord[2];
>            $x[$countmol]=$coord[3];
>            $y[$countmol]=$coord[4];
>            $z[$countmol]=$coord[5];
>            $atype[$countmol]=$coord[6];
>            $atype[$countmol]=$coord[6];
>             $charge[$countmol]=$coord[9];
>             ++$countmol;
>         }
>     }
> }
> 2. If I want create an output like that:
> 1 2 3
> 4 5 6
> 7 8 9
> ........
> how is the code?

Um, try using the print() function to get output.  See:

    perldoc -f print

 ...
-- 
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl


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

Date: Sat, 25 Sep 2004 12:03:10 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: few question about array
Message-Id: <slrnclb96e.qpk.tadmc@magna.augustmail.com>

Andrea Spitaleri <spiritelllo@interfree.it> wrote:

> clode IN;


Please be more respectful of the thousands of people that
you are writing to.

Post your _real_ Perl code please.


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


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

Date: Sat, 25 Sep 2004 20:00:43 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: few question about array
Message-Id: <cj4f8v$9ch$1@slavica.ukpost.com>



Andrea Spitaleri wrote:

 > open (IN,"in") || die "$!";
 > @in=<IN>;
 > clode IN;
 > my $i;
 > for ($i=0;$i<$#in;++$i){
 >     chomp $i;
 >     my $countmol=0;
 >      if($in[$i]=~ /^@<TRIPOS>ATOM/){
 >         $initial=$i;
 >         $endmol=$number_atoms + $i;
 >         for($k=$initial;$k<$endmol;++$k){
 >             @coord=split(/ +/,$inmol[$k+1]);
 > #that is it correct?? $numb[$countmol] is different from $numb[$i].
 >             $numb[$countmol]=$coord[1];
 >             $atom[$countmol]=$coord[2];
 >            $x[$countmol]=$coord[3];
 >            $y[$countmol]=$coord[4];
 >            $z[$countmol]=$coord[5];
 >            $atype[$countmol]=$coord[6];
 >            $atype[$countmol]=$coord[6];
 >             $charge[$countmol]=$coord[9];
 >             ++$countmol;
 >         }
 >     }
 > }

> how is the code?

Well, as you ask, awful.

You should always decalare all variables in the smallest applicable 
context unless you have a positive reason to do otherwise.

You should not use C-style fors in Perl unless you have a reason to do so.

When programing, you should always ask the machine for as much help as 
possible.  In the case of Perl you should

   use strict;
   use warnings;

(Strict disables 3 features of Perl you don't want to use without 
knowing what you are doing).

You have a chomp() in your code that makes no sense at all.

Whitespace is not a scarce resource - feel free to use as much as you 
like to make your code readable.

It is trivial in Perl to get the length of an array.  There is no point 
to maintain a separate scalar variable ($countmol) that merely contains 
the length of an array.  And anyhow there is a special function in Perl, 
push(), that appends one or more elements to the end on an array.

It is usually a bad idea to have a data structure that is made up of 
many parallel arrays.

It is usually a bad idea to have a data structure that is made up of 
many separate named variables.

Rather than writing lots of separate scalar assignments to successive 
elements of an array (@coord) it is more ideomatic to use a list assignment.

You should not slurp if you are only going to process the data once, a 
line at a time.



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

Date: Sat, 25 Sep 2004 11:45:27 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Help with my brute force method
Message-Id: <slrnclb857.qpk.tadmc@magna.augustmail.com>

Larry Felton Johnson <larryj@gsu.edu> wrote:

> open INFILE, "$infile" or die "Can't open $infile: $!\n";
               ^^^^^^^^^
               ^^^^^^^^^

   perldoc -q vars


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


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

Date: Sat, 25 Sep 2004 11:58:18 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Help with my brute force method
Message-Id: <slrnclb8ta.qpk.tadmc@magna.augustmail.com>

Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
> krakle <krakle@visto.com> wrote in comp.lang.perl.misc:


>> close the opened file when you are done.. :)
> 
> Why?


I can't think of a compelling reason in the context of a file 
opened for _input_, as in this thread.

But I _always_ have an explicit close() because it cost me
six and a half hours of debugging once.  [1]

The short version of the story: open()ed temp file for write, 
chose OUT as the filehandle, days later, hundreds of lines of code later,
open()ed temp file for read, chose IN as the filehandle.

Bug: missing some output data near the end

Solution: add "close OUT" after writing temp file (flush buffer).



Just because Perl will do the Right Thing with an already-opened
filehandle does not mean that the Perl _programmer_ will do the
right thing!

It was a fixed-price job, I worked a whole day for nothing. 

I found I didn't like that much.  ;-)

Once bitten, twice shy, so:

   1) I always use an explicit close()

   2) I try to choose more descriptive filehandle names






[1] Which seems like a lot for somthing as simple as buffering, but
    this was one of several thousand-line Perl programs run under
    the control of a custom work flow manager. Much of the time
    was just finding out _which_ Perl program had the bug.

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


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

Date: 25 Sep 2004 17:47:22 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Help with my brute force method
Message-Id: <cj4ava$a4t$1@mamenchi.zrz.TU-Berlin.DE>

Tad McClellan  <tadmc@augustmail.com> wrote in comp.lang.perl.misc:
> Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
> > krakle <krakle@visto.com> wrote in comp.lang.perl.misc:
> 
> 
> >> close the opened file when you are done.. :)
> > 
> > Why?
> 
> 
> I can't think of a compelling reason in the context of a file 
> opened for _input_, as in this thread.
> 
> But I _always_ have an explicit close() because it cost me
> six and a half hours of debugging once.  [1]
> 
> The short version of the story: open()ed temp file for write, 
> chose OUT as the filehandle, days later, hundreds of lines of code later,
> open()ed temp file for read, chose IN as the filehandle.
> 
> Bug: missing some output data near the end
> 
> Solution: add "close OUT" after writing temp file (flush buffer).


[horror snipped]

Ah, you're right.  When dealing with named file handles open for
writing you do have a point.  Those are program-wide, and who
knows what might happen.  I might even close a global read-handle.

Otherwise, lexical file handles close themselves when they go out of
scope. Together with the rule of making scopes as small as possible,
that takes care of it most of the time.

Anno


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

Date: Sat, 25 Sep 2004 20:10:00 GMT
From: Dave <me@home.net>
Subject: Re: Printing regex match
Message-Id: <MPG.1bbf70c5326086739896bf@news.easynews.com>

In <cj3qja$qhi$1@mamenchi.zrz.TU-Berlin.DE>, anno4000@lublin.zrz.tu-
berlin.de wrote
> Dave  <dave@home.net> wrote in comp.lang.perl.misc:
> > [...]

First, my thanks to Anno, Eric and Gunnar for the replies.  It seems I 
made the near-fatal mistake of typing off the top of my head without 
considering the extacting nature of criticism to which I'd be subjected 
for any mistakes I'd make. Seriously, I'm sure everyone who posts 
questions here appreciates the effort made to educate us dolts. ;-)

Hopefully this abbreviated excerpt will meet with greater approval.

#!/usr/bin/perl
# remove extraneous, incorrectly-formatted and banner-style 
# signatures from mailing list emails
use strict;
use warnings;

my $string =
"--
Unsubscribe info:      http://somewebsite.com/ml/#unsubscribe-simple
Problem reports:       http://somewebsite.com/problems.html
Documentation:         http://somewebsite.com/docs.html
FAQ:                   http://somewebsite.com/faq/
";

my $pattern = 
"^[> \t]*--\\s?\n[> \t]*Unsubscribe info.*somewebsite\.com\/faq\/\$";

if ( my ( @match ) = $string =~ /$pattern/smg ) {
    print "Unsubscribe footer matches! The match is:\n";
    print "-----------------------------------------\n";
    print "@match\n\n";
} else {
   print "No match for 'unsubscribe footer' found.\n\n";
}





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

Date: Sat, 25 Sep 2004 17:44:14 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: Untainting a filehandle
Message-Id: <cj479r$v56$1@slavica.ukpost.com>

Anno Siegel wrote:

>     my $dh = \ do { local *DH };
>     open( $dh, $somedir);

Unless backard compatability with older versions of Perl (pre 5.6.1 
IIRC) then this is more simply written:

     open( my $dh, $somedir);

BTW: the OP wanted opendir() not open().

BTW2: You should always check the return from open()/opendir().



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

Date: Sat, 25 Sep 2004 17:58:02 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: Untainting a filehandle
Message-Id: <cj482r$v5t$1@slavica.ukpost.com>



Greg Bacon wrote:
> In article <10l5hjnb9579i8f@corp.supernews.com>,
>     Greg Bacon <gbacon@hiwaay.net> wrote:
> 
> : I realize you "know" the filenames will always be safe, but please,
> : please, PLEASE apply the wisdom in the passage above rather than blindly
> : untainting the dirhandle.
> 
> Hmm.. rereading Dan's post, I think I may have been too harsh: maybe
> he knows that he needs to untaint data but doesn't know a good way to
> do it.

There is no need to worry about metacharacters in filenames so long as 
you are only using them as filenames - i.e. in 3-arg open or sysopen.

 > Say you expect filenames to begin with four lowercase, unaccented
 > letters; followed by a dash; and end with three digits.

If you are simply trying to access all files in a diectory it would be 
incorrect to come in with preconceptions about what filenames are valid.



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

Date: 25 Sep 2004 17:25:07 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Untainting a filehandle
Message-Id: <cj49lj$9cm$1@mamenchi.zrz.TU-Berlin.DE>

Brian McCauley  <nobull@mail.com> wrote in comp.lang.perl.misc:
> Anno Siegel wrote:
> 
> >     my $dh = \ do { local *DH };
> >     open( $dh, $somedir);
> 
> Unless backard compatability with older versions of Perl (pre 5.6.1 
> IIRC) then this is more simply written:
> 
>      open( my $dh, $somedir);

I was assuming the OP wanted to use object methods and have that affect
a particular named file... err, directory handle.  As I'm looking
again, I notice that local() prevents it from doing that, so yes,
presetting $dh isn't necessary.  "$dh = \ *DH" would make a difference.

> BTW: the OP wanted opendir() not open().

Yes.  Sloppy, but fortunately it doesn't matter much.

> BTW2: You should always check the return from open()/opendir().

I could claim it was pseudo-code, whose purpose wasn't to be copied
and run, but to show how the other line meshes with open(), but
you're right.  In a Usenet posting, always...

Anno


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

Date: Sat, 25 Sep 2004 23:15:32 +0800
From: Alont <end@dream.life>
Subject: Re: what's wrong in this Perl Regex expression?
Message-Id: <415d8ab9.183380093@130.133.1.4>

mlush@hgmp.mrc.ac.uk (Mr. M.J. Lush)Wrote at Sat, 25 Sep 2004 14:23:28
+0000 (UTC):
>The unexpected character you are looking for is newline (aka \n)
>the . in .* matches every character _except_ newline.
>
>try this
>
>my ($content) = $body =~ /($text_start.*$text_end)/s;
>
>The reason why is in <http://www.perldoc.com/perl5.8.0/pod/perlretut.html>
>-- 

you are right!y
If haven't your help, I'll waste more time on this problem, really
thank you :-)
-- 
      Your fault as a Government is My failure as a Citizen.


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

Date: Sat, 25 Sep 2004 11:32:53 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: what's wrong in this Perl Regex expression?
Message-Id: <slrnclb7dl.qpk.tadmc@magna.augustmail.com>

Alont <end@dream.life> wrote:

> and compiler don't give me error information, 
> I've tried this:
  ^^^^^^^^^^^^^^^
> $text_start = "<div id="boxtitle">";


I don't believe you.

Either you did not try that, or you did get some error information...

If you don't give the correct symptoms, we can't give the correct cure.

Please post your real code (use copy/paste, don't re-type it).


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


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

Date: Sat, 25 Sep 2004 11:36:59 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: what's wrong in this Perl Regex expression?
Message-Id: <slrnclb7lb.qpk.tadmc@magna.augustmail.com>

Alont <end@dream.life> wrote:
> mlush@hgmp.mrc.ac.uk (Mr. M.J. Lush)Wrote at Sat, 25 Sep 2004 14:23:28
> +0000 (UTC):
>>The unexpected character you are looking for is newline (aka \n)
>>the . in .* matches every character _except_ newline.
>>
>>try this
>>
>>my ($content) = $body =~ /($text_start.*$text_end)/s;
                                        ^^
                                        ^^
>>The reason why is in <http://www.perldoc.com/perl5.8.0/pod/perlretut.html>


If the start/end sequence might occur more than one time, then
you had better also check the answer to this Perl FAQ:

   perldoc -q regex

      What does it mean that regexes are greedy?  How can I get around it?


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


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

Date: Sat, 25 Sep 2004 19:00:17 GMT
From: "Dave" <daveandniki@ntlworld.com>
Subject: Re: what's wrong in this Perl Regex expression?
Message-Id: <5fj5d.1439$Zy3.479@newsfe5-win.ntli.net>


"Mr. M.J. Lush" <mlush@hgmp.mrc.ac.uk> wrote in message
news:cj3fho$ea6$1@helium.hgmp.mrc.ac.uk...
> In article <4159373d.162008078@130.133.1.4>, Alont  <end@dream.com> wrote:
> >Tore Aursand <tore@aursand.no>Wrote at Sat, 25 Sep 2004 08:53:28
> >+0200:
> >>$body =~ /(<!--head-->.*<!--bottom-->)/
> >
> >this expression always don't work in my Perl compiler,
> >and compiler don't give me error information,
> >I've tried this:
> >$text_start = "<div id="boxtitle">";
> >$text_end = "<div id="bottom">";
> >my $content =~ $body =~ /($text_start.*$text_end)/;
> >this also no result.
>
> Converting to a proper program I get:-
>
> #!/usr/bin/perl -w
> use strict;
>
> my $body = '<div id="boxtitle">wibblewibblewibble<div id="bottom">';
>
> my $text_start = "<div id="boxtitle">";
> my $text_end = "<div id="bottom">";
> my $content =~ $body =~ /($text_start.*$text_end)/;
> print $content;
>
> Which produces errors, if it does not,  there is something wrong with
> your computer!
>
> To kick off you need to single quote the $text_start $text_end
> so the quote marks in the string are not interpolated
> and remove the ~ between $content and $body
>
> #!/usr/bin/perl -w
> use strict;
>
> my $body = '<div id="boxtitle">wibblewibblewibble<div id="bottom">';
> my $text_start = '<div id="boxtitle">';
> my $text_end = '<div id="bottom">';
> my $content = $body =~ /($text_start.*$text_end)/;
> print $content;
>
> the program now runs but prints '1' this is because
> $body =~ /($text_start.*$text_end)/; returns an list of
> matches found in between the brackets.
>
> my $content =
>
> puts the expression in a scalar context,  when an list is treated
> in a scalar context,  perl returns the number of elements in the list
> and puts that into the scalar. Since $body =~ /($text_start.*$text_end)/;
> can only make a single match $content gets the number 1.
>
> To force perl to look at $content in a list context put brackets round
> it.  In the same way you can declare an array @array = ("a", "b", "c");
>
> #!/usr/bin/perl -w
> use strict;
>
> my $body = '<div id="boxtitle">wibblewibblewibble<div id="bottom">';
>
> my $text_start = '<div id="boxtitle">';
> my $text_end = '<div id="bottom">';
> my ($content) = $body =~ /($text_start.*$text_end)/;
> print $content;
>
> for bounus points if you make the match global and replace $content
> with an array.
>
> my @content = $body =~ /($text_start.*$text_end)/g;
>
> 5~@content gets _all_ instances of <div id="boxtitle">.*<div id="bottom">
> in $body.
>
> Hope this helps.
>
>
> --
> Michael
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> NPC rights activist  |  Nameless Abominations are people too.



?my @content = $body =~ /($text_start.*$text_end)/g;
?
?@content gets _all_ instances of <div id="boxtitle">.*<div id="bottom">
?in $body.

Surely:
my @content = $body =~ /($text_start.*?$text_end)/g;

otherwise you get everything between the first start tag and the last end
tag into the first element of the array.








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

Date: Sat, 25 Sep 2004 20:08:56 +0000 (UTC)
From: mlush@hgmp.mrc.ac.uk (Mr. M.J. Lush)
Subject: Re: what's wrong in this Perl Regex expression?
Message-Id: <cj4j8o$mq2$1@helium.hgmp.mrc.ac.uk>

In article <5fj5d.1439$Zy3.479@newsfe5-win.ntli.net>,
Dave <daveandniki@ntlworld.com> wrote:
>
>"Mr. M.J. Lush" <mlush@hgmp.mrc.ac.uk> wrote in message
>news:cj3fho$ea6$1@helium.hgmp.mrc.ac.uk...
>> In article <4159373d.162008078@130.133.1.4>, Alont  <end@dream.com> wrote:
>
>?my @content = $body =~ /($text_start.*$text_end)/g;
>?
>?@content gets _all_ instances of <div id="boxtitle">.*<div id="bottom">
>?in $body.
>
>Surely:
>my @content = $body =~ /($text_start.*?$text_end)/g;
>
>otherwise you get everything between the first start tag and the last end
>tag into the first element of the array.

True,  but it does do exactly what it says on the tin.  All instances of 
the patten do get put in the array.....
 .
Trys
 .
to 
 .
keep 
 .
straight 
 .
face
 .
OK its a fair cop guvnor, my bad.
-- 
Michael
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
NPC rights activist  |  Nameless Abominations are people too.


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

Date: Sat, 25 Sep 2004 20:47:49 GMT
From: Mike Flannigan <mikeflan@earthlink.net>
Subject: Win32::CtrlGUI
Message-Id: <4155D9B7.CC05EF2C@earthlink.net>


I would like to do some very simple data entry with Perl.
I simply want to enter a number and hit the enter key,
the continue that for 5 or 10 numbers.  An extra bonus
that is not absolutely needed to to activate an existing
window before the data is entered.

I thought I would use Win32::CtrlGUI to do this, but
surprisingly can't find it on ActiveState via ppm.

Has Win32::CtrlGUI been supplanted by something
else, or perhaps never incorporated on ActiveState?


Mike Flannigan




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

Date: 25 Sep 2004 21:32:56 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Win32::CtrlGUI
Message-Id: <Xns956FB283FBB3Aasu1cornelledu@132.236.56.8>

Mike Flannigan <mikeflan@earthlink.net> wrote in 
news:4155D9B7.CC05EF2C@earthlink.net:

> I would like to do some very simple data entry with Perl.
> I simply want to enter a number and hit the enter key,
> the continue that for 5 or 10 numbers.  An extra bonus
> that is not absolutely needed to to activate an existing
> window before the data is entered.
> 
> I thought I would use Win32::CtrlGUI to do this, but
> surprisingly can't find it on ActiveState via ppm.

Googling did not help either. Hmmm ... I guess you could try compiling it 
yourself using the free VC7 compiler and the platform SDK. It worked like a 
charm in my case. 
 
> Has Win32::CtrlGUI been supplanted by something
> else, or perhaps never incorporated on ActiveState?

You could also give GuiTest a shot:

use Win32::GuiTest qw(FindWindowLike SetForegroundWindow SendKeys);

system('start notepad test.txt') == 0
    or die "system failed: $?";

sleep 1;

my $w = shift @{[ FindWindowLike(undef, '^test.txt - Notepad$') ]};

SetForegroundWindow($w);
SendKeys("$_~") for (1 .. 10);

__END__


-- 
A. Sinan Unur
1usa@llenroc.ude.invalid 
(remove '.invalid' and reverse each component for email address)



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

Date: Sat, 25 Sep 2004 16:02:50 GMT
From: c0rk <pam4prezNOSPAM@hotmail.com>
Subject: XML::Twig
Message-Id: <Xns956F7A8FE8D1Epam4prezNOSPAMhotmai@68.12.19.6>

OK. I am now desperate. I have written a sub routine to slipt up large 
(~2-3MB) XML documents into seperate documents. When I use $twig->
parsefile I get the following error:

"not well-formed (invalid token) at line 27072, column 1934, byte 878399 
at C:/Perl/site/lib/XML/Parser.pm line 187"

When I change to $twig->safe_parsefile I can parse the document, but it 
only gets a portion of the document (~38 of 83 elements). 

I am the first to admit that I am not a Perl hack by trade, so please 
don't rape me for my code sample. I should also mention that this code 
worked great on smaller files ( <300k ).

Any help/suggestions would be greatly appreciated.

Brendan


sub splitFiles {
  my  $fPath = $_[0];
  my $twig= new XML::Twig;
  &logMessage("DEBUG - Build the Twig for " . $fPath);
  $twig->safe_parsefile($fPath);    # build the twig
  &logMessage("DEBUG - I can parse the file");
  my $root = $twig->root;          # get the root of the twig 
(vdf_metadata_list)
  &logMessage("DEBUG - Videos: ". $root->children_count);
  my @videos = $root->children;    # put the vdf_metadata elements into 
an array
  if (scalar @videos > 0 ) {
    &logMessage("DEBUG - Number of videos is " . scalar @videos);
    my $i = 0;
    foreach my $video (@videos) {
      $i++;
      my $timeStamp = gettimeofday;
      my $tmpPath = "$tmpDir".$timeStamp.$i;
      my $FH;
      open($FH, ">$tmpPath") || die("cannot open file: " . $!);
      $video->print($FH);
      close (FH);
    }
  } else {
    &logMessage("DEBUG - Skipping file " . $fPath);
  }
}


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

Date: Sat, 25 Sep 2004 17:31:12 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: XML::Twig
Message-Id: <cj46h1$v2m$1@slavica.ukpost.com>



c0rk wrote:
> OK. I am now desperate. I have written a sub routine to slipt up large 
> (~2-3MB) XML documents into seperate documents. When I use $twig->
> parsefile I get the following error:
> 
> "not well-formed (invalid token) at line 27072, column 1934, byte 878399 
> at C:/Perl/site/lib/XML/Parser.pm line 187"

Well, in the absense of any evidence to the contrary I'm be inclined to 
accept that at face value.

Do you have a reason to disbelive it?



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

Date: Sat, 25 Sep 2004 12:01:39 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: XML::Twig
Message-Id: <slrnclb93j.qpk.tadmc@magna.augustmail.com>

c0rk <pam4prezNOSPAM@hotmail.com> wrote:

> When I use $twig->
> parsefile I get the following error:
> 
> "not well-formed (invalid token) at line 27072, column 1934, byte 878399 
> at C:/Perl/site/lib/XML/Parser.pm line 187"


This message means that there is something wrong with the _data_
rather than with the code.

Open the data file to the 1934th character on the 27072nd line
and see what it is that makes it invalid XML.



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


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 7177
***************************************


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