[24667] in Perl-Users-Digest
Perl-Users Digest, Issue: 6831 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Aug 3 15:02:10 2004
Date: Tue, 3 Aug 2004 12:01:43 -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 Tue, 3 Aug 2004 Volume: 10 Number: 6831
Today's topics:
windows based network instant messenger in perl (Vikram)
writing to a pipe on win32 (momena)
WWW::Mechanize work with Javascript .ASP? (nyana)
Re: WWW::Mechanize work with Javascript .ASP? <ceo@nospam.on.net>
Re: WWW::Mechanize work with Javascript .ASP? <j@j.com>
Re: WWW::Mechanize work with Javascript .ASP? <j@j.com>
Re: WWW::Mechanize work with Javascript .ASP? <postmaster@castleamber.com>
Re: WWW::Mechanize work with Javascript .ASP? <ceo@nospam.on.net>
Re: WWW::Mechanize work with Javascript .ASP? <rene.nyffenegger@gmx.ch>
X500::DN::Parser V 1.16 <ron@savage.net.au>
XML::PARSER utf-8 and japanese characters <shah@typhoon.xnet.com>
Re: XML::PARSER utf-8 and japanese characters <usenet@morrow.me.uk>
XML::Xerces Documentation/Tutorial <matrix_calling@yahoo.dot.com>
XP Pro Sec TCP/IP, Services -w- Hash rules (GlowOfSunsetREMOVE@Yahoo.com)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 24 Jul 2004 19:59:43 -0700
From: vikram.dhir@gmail.com (Vikram)
Subject: windows based network instant messenger in perl
Message-Id: <5ebdd446.0407241859.25490aae@posting.google.com>
hello everyone,
I have to duplicate a windows based network instant messenger in perl.
the messenger has been made in visual c++. I am supposed to make a
similar funtioning software in perl which works on the windows
platform. I have ActivePerl 5.8.0 build 804 on my system.
I would like to know a few things ...
1) how should I implement multithreading? should I use the
Win32::Process module or is there a betterway to implement
multithreading in windows?
2) which module is supposed to be used for network communication?
3) for the gui development, would Win32::GUI be sufficient enough to
make a decent interface to the program?
help!
bye
vikram
------------------------------
Date: 26 Jul 2004 11:42:44 -0700
From: momenaa@yahoo.com (momena)
Subject: writing to a pipe on win32
Message-Id: <1aef0da7.0407261042.5ed33493@posting.google.com>
Hi experts,
I need to write a perl script that will be called from a series of
executables chained thru pipes that read from STDIN and writes to
STDOUT. The following code works fine under regular circumstance. But
when there is a error down the pipe in one of the executables, the
pipe closes and then this script just exits. It does not print line
14. The troublesome line is line number 17. If I comment it out, the
script completes. From my very little perl knowledge, I was thinking
that in line 17, when we call "print $_" and the pipe broke due to the
error in another executable, it would generate SIGPIPE, but I get no
signal. Does SIGPIPE work on windows ?
1 sub signalhandler
2 {
3 print STDERR "*Received a SIG$_[0]\n";
4 }
5 my $Tmp_File = "c:/test_dir/testFile";
6 open(IN_FILE, ">$Tmp_File") || die "Open file error: $!";
7 binmode (IN_FILE);
8 while (<STDIN>) {
9 print IN_FILE ;
10 }
11 close(IN_FILE);
12 use sigtrap qw{handler signalhandler normal-signals
error-signals};
13 open(OUT_FILE, "$some_other_executable $Tmp_File |") || die
"Fork error: $!";
14 print STDERR "Opened file OUT_FILE!!\n";
15 binmode (OUT_FILE);
16 while (<OUT_FILE>) {
17 print $_;
18 }
19 unlink ($Tmp_File) || die "Remove file error: $!";
Thanks in advance.
Momena
------------------------------
Date: 31 Jul 2004 20:15:36 -0700
From: johnsonj@gmail.com (nyana)
Subject: WWW::Mechanize work with Javascript .ASP?
Message-Id: <2d47d2d4.0407311915.57522262@posting.google.com>
I am trying to get either WWW::Mechanize or WWW:Mechanize:FormFiller
to fill in a value on an ASP page
(http://www.mlindex.ml.com/GISPublic/bin/SnapShot.asp), click a button
(the only button) and then return the resulting page. The result does
not contain information as if the text was not entered into the field.
In general does anyone know if these modules work with ASPs written in
JavaScript?
Here is the code if anyone is interersted in looking at it.
#! /usr/bin/perl
use strict;
use warnings;
# create a new browser
use WWW::Mechanize;
my $mech = WWW::Mechanize->new();
# tell it to get the main page
$mech->get("http://www.mlindex.ml.com/GISPublic/bin/SnapShot.asp");
# fill in box with static (for now) module name G902
$mech->field("txtSSCUSIP","G9O2");
$mech->click();
print $mech->content;
exit(0);
I also tried using FormFiller inserting the following code into the
above script (I did "use ...::FormFiller" at top of script):
# fill in box with static module name
my $formfiller = WWW::Mechanize::FormFiller->new();
$formfiller->add_filler( 'txtSSCUSIP' => Fixed => 'G9O2' );
$formfiller->fill_form($mech->current_form);
$mech->click();
I am a little iffy on my FormFiller code, never used it before.
Thanks!
------------------------------
Date: Sun, 01 Aug 2004 04:13:04 GMT
From: ChrisO <ceo@nospam.on.net>
Subject: Re: WWW::Mechanize work with Javascript .ASP?
Message-Id: <k5_Oc.1640$Z56.1293@newssvr33.news.prodigy.com>
nyana wrote:
> I am trying to get either WWW::Mechanize or WWW:Mechanize:FormFiller
> to fill in a value on an ASP page
> (http://www.mlindex.ml.com/GISPublic/bin/SnapShot.asp), click a button
> (the only button) and then return the resulting page. The result does
> not contain information as if the text was not entered into the field.
>
> In general does anyone know if these modules work with ASPs written in
> JavaScript?
The server side scripting engine has nothing to do with filling out a
form and submitting it (or clicking a button on it) regardless of
whether you are using a standard browser as a client, or Perl module
Foo::Bar as a client to fill it out and do the submit (or what have you.)
-ceo
------------------------------
Date: Sat, 31 Jul 2004 22:23:09 -0700
From: "nyana" <j@j.com>
Subject: Re: WWW::Mechanize work with Javascript .ASP?
Message-Id: <V6%Oc.26082$mg6.21461@fed1read02>
"ChrisO" <ceo@nospam.on.net> wrote in message
news:k5_Oc.1640$Z56.1293@newssvr33.news.prodigy.com...
> nyana wrote:
> > I am trying to get either WWW::Mechanize or WWW:Mechanize:FormFiller
> > to fill in a value on an ASP page
> > (http://www.mlindex.ml.com/GISPublic/bin/SnapShot.asp), click a button
> > (the only button) and then return the resulting page. The result does
> > not contain information as if the text was not entered into the field.
> >
> > In general does anyone know if these modules work with ASPs written in
> > JavaScript?
>
> The server side scripting engine has nothing to do with filling out a
> form and submitting it (or clicking a button on it) regardless of
> whether you are using a standard browser as a client, or Perl module
> Foo::Bar as a client to fill it out and do the submit (or what have you.)
>
> -ceo
Thanks, I didn't think it did.
I found the problem has to do with passing a header that I thought should be
passed correctly by itself. The form has some hidden fields that usually
contain values which are automatically entered. It also has non-hidden
fields which are pre-filled in, those get passed but the hidden ones don't.
So I manually filled the hidden fields in but there is one problem: the date
gets passed as 7%2F31%2F2004 when doing it through a browser, but when I
enter that in what actually gets passed is
7%252F31%252F2004 ... notice the 52 after the %2.
$formfiller->add_filler( 'hdnDate' => Fixed => "7%2F31%2F2004" );
When HTTP Sniffed is POSTed as: 7%252F31%252F2004
This has me stumped but I'll do some searching, if anyone knows thanks for
sharing.
nyana
------------------------------
Date: Sat, 31 Jul 2004 23:29:52 -0700
From: "nyana" <j@j.com>
Subject: Re: WWW::Mechanize work with Javascript .ASP?
Message-Id: <n50Pc.26484$mg6.5468@fed1read02>
> I found the problem has to do with passing a header that I thought should
be
> passed correctly by itself. The form has some hidden fields that usually
> contain values which are automatically entered. It also has non-hidden
> fields which are pre-filled in, those get passed but the hidden ones
don't.
>
> So I manually filled the hidden fields in but there is one problem: the
date
> gets passed as 7%2F31%2F2004 when doing it through a browser, but when I
> enter that in what actually gets passed is
> 7%252F31%252F2004 ... notice the 52 after the %2.
>
> $formfiller->add_filler( 'hdnDate' => Fixed => "7%2F31%2F2004" );
> When HTTP Sniffed is POSTed as: 7%252F31%252F2004
>
> This has me stumped but I'll do some searching, if anyone knows thanks for
> sharing.
>
> nyana
>
>
I get it!
%2F = /
Anyone know of a resource/way to know what the various %Xs are? For instance
I need to know what %2C represents. Is there a chart available? It's
difficult to search for because google won't search %.
Thanks,
nyana
------------------------------
Date: Sun, 01 Aug 2004 01:40:21 -0500
From: John Bokma <postmaster@castleamber.com>
Subject: Re: WWW::Mechanize work with Javascript .ASP?
Message-Id: <410c9056$0$729$58c7af7e@news.kabelfoon.nl>
nyana wrote:
>>I found the problem has to do with passing a header that I thought should
>
> be
>
>>passed correctly by itself. The form has some hidden fields that usually
>>contain values which are automatically entered. It also has non-hidden
>>fields which are pre-filled in, those get passed but the hidden ones
>
> don't.
>
>>So I manually filled the hidden fields in but there is one problem: the
>
> date
>
>>gets passed as 7%2F31%2F2004 when doing it through a browser, but when I
>>enter that in what actually gets passed is
>>7%252F31%252F2004 ... notice the 52 after the %2.
>>
>>$formfiller->add_filler( 'hdnDate' => Fixed => "7%2F31%2F2004" );
>>When HTTP Sniffed is POSTed as: 7%252F31%252F2004
>>
>>This has me stumped but I'll do some searching, if anyone knows thanks for
>>sharing.
>>
>>nyana
>>
>>
>
>
> I get it!
>
> %2F = /
>
> Anyone know of a resource/way to know what the various %Xs are? For instance
> I need to know what %2C represents. Is there a chart available? It's
> difficult to search for because google won't search %.
Have a look at the URI::Escape module:
uri_unescape($string,...)
Returns a string with all %XX sequences replaced with the actual
byte (octet).
Don't reinvent the wheel.
--
John MexIT: http://johnbokma.com/mexit/
personal page: http://johnbokma.com/
Experienced Perl programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html
------------------------------
Date: Sun, 01 Aug 2004 16:28:46 GMT
From: ChrisO <ceo@nospam.on.net>
Subject: Re: WWW::Mechanize work with Javascript .ASP?
Message-Id: <2T8Pc.3629$C97.1985@newssvr15.news.prodigy.com>
nyana wrote:
>>I found the problem has to do with passing a header that I thought should
>
> be
>
>>passed correctly by itself. The form has some hidden fields that usually
>>contain values which are automatically entered. It also has non-hidden
>>fields which are pre-filled in, those get passed but the hidden ones
>
> don't.
>
>>So I manually filled the hidden fields in but there is one problem: the
>
> date
>
>>gets passed as 7%2F31%2F2004 when doing it through a browser, but when I
>>enter that in what actually gets passed is
>>7%252F31%252F2004 ... notice the 52 after the %2.
>>
>>$formfiller->add_filler( 'hdnDate' => Fixed => "7%2F31%2F2004" );
>>When HTTP Sniffed is POSTed as: 7%252F31%252F2004
>>
>>This has me stumped but I'll do some searching, if anyone knows thanks for
>>sharing.
>>
>>nyana
>>
>>
>
>
> I get it!
>
> %2F = /
>
> Anyone know of a resource/way to know what the various %Xs are? For instance
> I need to know what %2C represents. Is there a chart available? It's
> difficult to search for because google won't search %.
>
The "2F" part is hexidecimal and is the hexidecimal code for that
character commonly found in the ASCII table. So if you can find a good
ASCII table somewhere that has hexidecimal codes in it per character,
then translating these back and forth either direction isn't a huge problem.
I suppose http://www.asciitable.com is as good as place as any to find
these codes. Not to mention the plethora of routines in most coding
frameworks for this sort of thing:
Javascript: escape() and unescape() functions.
Perl: I like Jenda's CGI::enurl and CGI::deurl.
Using Javascript, it's not too hard to construct a client-side only HTML
page that encodes and decodes strings for yourself.
-ceo
------------------------------
Date: 2 Aug 2004 09:26:01 GMT
From: Rene Nyffenegger <rene.nyffenegger@gmx.ch>
Subject: Re: WWW::Mechanize work with Javascript .ASP?
Message-Id: <slrncgs251.3n0.rene.nyffenegger@zhnt60m34.netarchitects.com>
> Anyone know of a resource/way to know what the various %Xs are? For instance
> I need to know what %2C represents. Is there a chart available? It's
> difficult to search for because google won't search %.
>
> Thanks,
> nyana
perl -e "print pack('H2','2c');"
--
Rene Nyffenegger
http://www.adp-gmbh.ch/
------------------------------
Date: Thu, 29 Jul 2004 06:20:16 GMT
From: Ron Savage <ron@savage.net.au>
Subject: X500::DN::Parser V 1.16
Message-Id: <I1qH8D.1q9p@zorch.sf-bay.org>
The pure Perl module X500::DN::Parser V 1.16
is available immediately from CPAN,
and from http://savage.net.au/Perl-modules.html.
On-line docs, and a *.ppd for ActivePerl are also
available from the latter site.
An extract from the docs:
1.16 Tue Jul 20 20:43:00 2004
- Change Makefile.PL to coexist with Module::Build
- Move X500DN.dat into t/
- Add t/pod.t to test all PODs
--
Cheers
Ron Savage, ron@savage.net.au on 29/07/2004
http://savage.net.au/index.html
------------------------------
Date: Wed, 28 Jul 2004 03:37:10 +0000 (UTC)
From: Hemant Shah <shah@typhoon.xnet.com>
Subject: XML::PARSER utf-8 and japanese characters
Message-Id: <ce7715$8kf$1@new7.xnet.com>
Folks,
I am having problem writing Japanese characters.
I am parsing an XML document that is in utf-8, actually it is a
content.xml file from Open Office. It contains Japanese text along
with english text. (english text and it's japanese translation).
I want to write the the english and japanese text into individual
files.
Another process will read these individual files and insert the it
into DB2 database which is also in utf-8.
I am having problem writing japanese text to a file.
I am running perl 5.8.3 on AIX 5.2.
Here are the code fragments from my script:
use Encode;
use encoding utf8, STDOUT => "utf8", STDIN => "utf8";
use XML::Parser;
$ContentParser = new XML::Parser(Handlers => {Start => \&HandleContentStart,
End => \&HandleContentEnd,
Default => \&DefaultContentHandler,
Char => \&HandleContentChar});
$ContentParser->parsefile ("content.xml", ProtocolEncoding => 'UTF-8');
# In HandleContentChar() subroutine
open (TEMPFILE, ">:encoding(utf8)", $TmpFile) ||
die "Cannot open temporary file for write $TmpFile. $!";
# Code to print XML tags
print TEMPFILE "$JapaneseText";
# Code to print XML tags
close(TEMPFILE);
When I look at the Japanese text in content.xml file and $TmpFile (hex dump),
they are different.
Also is there a way to split the Japanese text at unicode character
boundary. I would like to store lines of 100 (single byte) characters or
less per line. I do not have any problem with english and spanish text,
but japanese characters are double byte, so I would like to split the
line at 50 japanese characters.
Thanks in advance.
--
Hemant Shah /"\ ASCII ribbon campaign
E-mail: NoJunkMailshah@xnet.com \ / ---------------------
X against HTML mail
TO REPLY, REMOVE NoJunkMail / \ and postings
FROM MY E-MAIL ADDRESS.
-----------------[DO NOT SEND UNSOLICITED BULK E-MAIL]------------------
I haven't lost my mind, Above opinions are mine only.
it's backed up on tape somewhere. Others can have their own.
------------------------------
Date: Thu, 29 Jul 2004 18:42:13 +0100
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: XML::PARSER utf-8 and japanese characters
Message-Id: <lgpnt1-jt5.ln1@mauzo.dyndns.org>
Quoth NoJunkMailshah@xnet.com:
> I am having problem writing Japanese characters.
>
> I am parsing an XML document that is in utf-8, actually it is a
> content.xml file from Open Office. It contains Japanese text along
> with english text. (english text and it's japanese translation).
>
> I want to write the the english and japanese text into individual
> files.
>
> Another process will read these individual files and insert the it
> into DB2 database which is also in utf-8.
>
> I am having problem writing japanese text to a file.
>
> I am running perl 5.8.3 on AIX 5.2.
That's a good start...
> Here are the code fragments from my script:
>
> use Encode;
> use encoding utf8, STDOUT => "utf8", STDIN => "utf8";
I would have explicitly binmoded the FHs, for clarity, but hey...
> use XML::Parser;
>
>
> $ContentParser = new XML::Parser(Handlers => {Start => \&HandleContentStart,
> End => \&HandleContentEnd,
> Default => \&DefaultContentHandler,
> Char => \&HandleContentChar});
>
> $ContentParser->parsefile ("content.xml", ProtocolEncoding => 'UTF-8');
>
>
>
> # In HandleContentChar() subroutine
> open (TEMPFILE, ">:encoding(utf8)", $TmpFile) ||
Use lexical filehandles.
Use low-precedence operators to avoid brackets.
open my $TEMFILE, '>:encoding(utf8)', $TmpFile or die ...;
> die "Cannot open temporary file for write $TmpFile. $!";
>
> # Code to print XML tags
>
> print TEMPFILE "$JapaneseText";
Don't quote unnecessarily.
> # Code to print XML tags
>
> close(TEMPFILE);
>
> When I look at the Japanese text in content.xml file and $TmpFile (hex dump),
> they are different.
How are they different? Are they equivalent representations of the text
(I don't know if there are any non-canonical representations for
Japanese)? Can you give some examples of input and output text?
> Also is there a way to split the Japanese text at unicode character
> boundary. I would like to store lines of 100 (single byte) characters or
> less per line. I do not have any problem with english and spanish text,
> but japanese characters are double byte,
No they aren't. Most Japanese characters require 3 bytes in the UTF8
encoding, and all accented spanish characters will require at least two.
> so I would like to split the line at 50 japanese characters.
What do you actually mean here? You claim not to mean 100 bytes/line,
but I suspect that might be what you actually want (if this is for some
program with a line-length limitation). Otherwise, do you mean 100
Unicode codepoints (100 complete utf8 sequences), 100 graphemes
(sequences like {LATIN SMALL LETTER A}{COMBINING ACUTE ACCENT}
which, while two Unicode codepoints, display as one character) or 100
(displayed) columns? These can by done by:
$string =~ s/(.{100})/$1\n/g; # CHARS (CODEPOINTS)
$string =~ s/(\X{100})/$1\n/g; # GRAPHEMES (COMBINING SEQUENCES)
; 'bytes' and 'columns' are slightly harder, and I can't see an easy way
to do them with a regex:
# BYTES
{
my $newstring = '';
my $width = 0;
for (split //, $string) {
$width += do { use bytes; length };
$width > 100 and $newstring .= "\n", $width -= 100;
$newstring .= $_;
}
$string = $newstring;
}
# COLUMNS (taking CJK full-width forms into account)
use Unicode::EastAsianWidth; # install from CPAN
{
my $newstring = '';
my $width = 0;
for (split //, $string) {
/\p{IsPrint}/ and $width += /\p{InFullwidth}/ ? 2 : 1;
# There is a bug here: it doesn't deal correctly with
# printing-but-not-spacing characters (like combining accents).
$width > 100 and $newstring .= "\n", $width -= 100;
$newstring .= $_;
}
$string = $newstring;
}
<none of the above tested>. You will need to read the docs for
Unicode::EastAsianWidth if you use it: I don't fully understand what it
says about 'ambiguous width' characters, knowing very little about CJK
writing.
Ben
--
If you put all the prophets, | You'd have so much more reason
Mystics and saints | Than ever was born
In one room together, | Out of all of the conflicts of time.
ben@morrow.me.uk The Levellers, 'Believers'
------------------------------
Date: Wed, 28 Jul 2004 16:09:10 +0530
From: Abhinav <matrix_calling@yahoo.dot.com>
Subject: XML::Xerces Documentation/Tutorial
Message-Id: <euLNc.13$tg.113@news.oracle.com>
Hi,
Is there any documentation for the XML::Xerces module apart from the
Xerces-C C++ API docs, and the sample Perl scripts?
Any reference/Tutorial would be highly appreciated
TIA
--
Abhinav
------------------------------
Date: 28 Jul 2004 12:02:53 -0700
From: GlowOfSunset@yahoo.com (GlowOfSunsetREMOVE@Yahoo.com)
Subject: XP Pro Sec TCP/IP, Services -w- Hash rules
Message-Id: <204e9a2d.0407281102.34b89782@posting.google.com>
Really need some help here and I am interested in the field.
These questions are in regard to a standalone system. There is no MS
Windows Server 2003(etc) domain controller only a standalone Win XP
Pro system. I am trying to develop or find scripts that make possible
the rollout of a standalone system more rapidly and still have a very
secure system. Repeated installation of the same OS, wherein I am
clicking my way to security is driving me nuts.
(1) Does anyone know of a few good sites showing scripts using either
WSH or Perl to control the full range IP ports on a standalone system?
I would prefer Perl because I know a bit of Perl but will learn/use
WSH to get the job done.
In the Microsoft server realm you can easily block off a range of IP
ports but on a standalone system, which is what I have the same
functionality does not seem to be available. What I have found is
that you have to close one port per protocol family(TCP & UDP) at a
time hence having to create 2*65535 rules - the ports that you want
open for communications. If I have made an incorrect assumption here,
which is possible just direct me to the scripts and/or documentation
revealing that and how to go about implementing the functionality
desired using a script.
(2) I would like to control the instantiation of most applications on
the system with hash rules as a security measure, and others such as
browsers and antivirus as services as an authenticated user -w- hash
rules. Any scripts regarding this? There must be several hundred
applications that come with the OS that have to be tied down,
everything onboard is being accessed through firewalls despite having
done my best...has anyone made a script available to the public or do
I have to roll my own? Any great on-line documentation?
Thanks!
------------------------------
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 6831
***************************************