[23009] in Perl-Users-Digest
Perl-Users Digest, Issue: 5229 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jul 16 14:07:21 2003
Date: Wed, 16 Jul 2003 11:05:08 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 16 Jul 2003 Volume: 10 Number: 5229
Today's topics:
Re: A perl prayer <tassilo.parseval@rwth-aachen.de>
Re: A perl prayer <andrew_harton@agilent.com>
Re: A perl prayer <tony_curtis32@yahoo.com>
Re: building C DLL for calling from Perl using (*.XS) <tassilo.parseval@rwth-aachen.de>
Re: Curses compile problems (tjchamp)
Help needed badly! VIZBOOK date file path? (Andy)
Re: macros in perl <usenet@dwall.fastmail.fm>
Re: macros in perl <asu1@c-o-r-n-e-l-l.edu>
Re: macros in perl <marc0@autistici.org>
Re: macros in perl <jurgenex@hotmail.com>
Re: macros in perl <marc0@autistici.org>
Re: macros in perl <marc0@autistici.org>
Re: Newbie can't get CgiComments to name files correctl <infinite.possibilities@NOSPAMatt.net>
Opening a socket connection on a serial port (John Ramsden)
PDF Outlines / Bookmarks (im lost) <peter_wilson@mail.com>
Re: PDF Outlines / Bookmarks (im lost) <peter_wilson@mail.com>
regexp problem with UTF8 <risto.vaarandi@eyp.ee>
Re: shorten expression <pinyaj@rpi.edu>
Re: TELNET and waitfor problems <jay@rgrs.com>
UTF8 where no UTF8 should be in combination with XML::S (Erik Wasser)
what exactly do you need to escape? (I can never get th <me@home.com>
Re: Why is 'last' not allowed here <bart.lateur@pandora.be>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 16 Jul 2003 13:20:46 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: A perl prayer
Message-Id: <bf3jfe$p2u$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Ingvar Hagelund:
> #!/usr/bin/perl
>
> PRAYER:
You should always enable warnings and strictures when developing Perl
prayers. :-)
Apart from that, nice work! I have the highest admiration for those who
can make the Perl parser contort to its outer limits without actually
making him croak.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: Wed, 16 Jul 2003 16:36:28 +0100
From: "Andrew Harton" <andrew_harton@agilent.com>
Subject: Re: A perl prayer
Message-Id: <1058369724.883339@cswreg.cos.agilent.com>
Tassilo v. Parseval wrote:
> Also sprach Ingvar Hagelund:
>
>> #!/usr/bin/perl
>>
>> PRAYER:
>
> You should always enable warnings and strictures when developing Perl
> prayers. :-)
...but then where's the display of faith??
Andrew
--
$_="8fe403bc47120d12a0635912";$#=" eratcHhJklnoPsu";
split//;for(0..$#_){print substr($#,hex $_[$_],1);}
------------------------------
Date: Wed, 16 Jul 2003 10:40:06 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: A perl prayer
Message-Id: <87k7aiv5t5.fsf@limey.hpcc.uh.edu>
>> On Wed, 16 Jul 2003 16:36:28 +0100,
>> "Andrew Harton" <andrew_harton@agilent.com> said:
> Tassilo v. Parseval wrote:
>> Also sprach Ingvar Hagelund:
>>
>> #!/usr/bin/perl
>>>
>> PRAYER:
>> You should always enable warnings and strictures when
>> developing Perl prayers. :-)
> ...but then where's the display of faith??
You'd need Tk for that.
------------------------------
Date: 16 Jul 2003 13:16:42 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: building C DLL for calling from Perl using (*.XS)
Message-Id: <bf3j7q$oq3$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Ilya Zakharevich:
><tassilo.parseval@post.rwth-aachen.de>], who wrote in article <bev8kd$kij$1@nets3.rz.RWTH-Aachen.DE>:
>> In case of XS code, you shouldn't be using your libc's malloc anyways.
>> Instead use the macros provided by perl.h: safemalloc, safefree,
>> saferealloc etc. They aren't listed in perlapi.pod, though. I wonder
>> why not.
>
> Because they are not a part of the API? New(), Safefree() and Renew() are.
That would explain it. :-) I wasn't aware of it and never yet stumbled
over these entries (even though I use perlapi.pod a lot). Have to change
that throughout my XS code then, too.
Anyway, not being documented in perlapi.pod isn't a particularly strong
indication that it's not part of the API. sv_2io() for instance is
documented, but nothing is said about how to turn this IO* into a
PerlIO* (that is: something useful). It's actually done via the IoIFP()
macro which is neither mentioned in perlapi.pod nor perlapio.pod (where
it would probably belong).
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: 16 Jul 2003 10:21:23 -0700
From: todd.champ@honeywell.com (tjchamp)
Subject: Re: Curses compile problems
Message-Id: <cc05db28.0307160921.3bb7eb37@posting.google.com>
todd.champ@honeywell.com (tjchamp) wrote in message news:<cc05db28.0307080609.4e5a8bee@posting.google.com>...
> newbie needs help with Curses. I used source code to compile my own
> Perl 5.8 using gcc compiler. I need to get Curses working but get the
> following errors when doing my make:
>
> gcc -c -D_ALL_SOURCE -D_ANSI_C_SOURCE -D_POSIX_SOURCE
> -DUSE_NATIVE_DLOPEN -fno-strict-aliasing -D_LARGE_FILES -O
> -DVERSION=\"1.06\" -DXS_VERSION=\"1.06\"
> "-I/usr/local/lib/perl5/5.8.0/aix/CORE" Curses.c
> In file included from
> /usr/local/lib/perl5/5.8.0/aix/CORE/iperlsys.h:51,
> from /usr/local/lib/perl5/5.8.0/aix/CORE/perl.h:2200,
> from Curses.c:14:
> /usr/local/lib/perl5/5.8.0/aix/CORE/perlio.h:104: parse error before
> `->'
> /usr/local/lib/perl5/5.8.0/aix/CORE/perlio.h:107: parse error before
> `->'
> In file included from Curses.c:344:
> CursesFun.c: In function `XS_Curses_newterm':
> CursesFun.c:1279: warning: initialization from incompatible pointer
> type
> CursesFun.c:1280: warning: initialization from incompatible pointer
> type
> CursesFun.c: In function `XS_Curses_putwin':
> CursesFun.c:3453: warning: initialization from incompatible pointer
> type
> CursesFun.c: In function `XS_Curses_getwin':
> CursesFun.c:3472: warning: initialization from incompatible pointer
> type
> make: 1254-004 The error code from the last command is 1.
>
>
> Stop.
>
>
> This is on an AIX 5.1 box. Any help/directions on how to proceed will
> be appreciated.
Needed to "#undef tab" in the c-config.h file. After that, compiled just fine.
------------------------------
Date: 16 Jul 2003 06:07:35 -0700
From: warmesfeuer@web.de (Andy)
Subject: Help needed badly! VIZBOOK date file path?
Message-Id: <271faeeb.0307160507.77eaea8b@posting.google.com>
Help needed!
I tried to install Vizbook on my hoempage today, created all dirs
manually via FTP (makedir.cgi somehow didn't work: "can't create file
/vizbook/index.htm" etc., testbin.cgi ran ok) and uploaded the files.
I think (I am a perl newbie, so I can't be sure, can I?) I set all
chmod attributes correctly and used the right ftp transfer modes
(binary, ascii) for the respective files.
My problem: When I try to call vizadmin.cgi for first-time setup, I
recieve an error message:
Missing/Bad Path to Config file
The vizadmin.cgi header seems to print this when the path to the file
is incorrect or missing (actual path: rootdir/cgi-bin/sets/gmtset.pl,
default in file: "sets/gmtset.pl"). I did not change any default
locations of the dirs - this is a possible explanation from the readme
file.
What can I do?
Thanks so much in advance for your help!
Andy
------------------------------
Date: Wed, 16 Jul 2003 13:46:27 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: macros in perl
Message-Id: <Xns93BA636D65279dkwwashere@216.168.3.30>
marc0 <marc0@autistici.org> wrote:
> In the Perl script I'm working on I would use it to write something
> like
>
> #define walk_file(FILE) for ($walk_file_line = <FILE>)
>
> walk_file (FILE) {
> ...
>}
>
> and alike.
>
> That's not necessary but IMHO it helps to make the code more clear.
What's wrong with
while (<FILE>) {
# do stuff with $_ instead of $walk_file_line
}
? It's the usual idiom; using something else seems like obfuscation
to me.
--
David Wall
------------------------------
Date: 16 Jul 2003 14:07:58 GMT
From: "A. Sinan Unur" <asu1@c-o-r-n-e-l-l.edu>
Subject: Re: macros in perl
Message-Id: <Xns93BA671455189asu1cornelledu@132.236.56.8>
marc0 <marc0@autistici.org> wrote in news:87n0fek5p7.fsf@autistici.org:
> -----BEGIN xxx SIGNED MESSAGE-----
> Hash: SHA1
>
> Stephane G. Titard on Wed, 16 Jul 2003 12:48:08 +0200 writes:
>
>> marc0 wrote:
>>> How it's possible to write macros in perl?
>>> C-like macros would be OK.
>> Well, most of the time you don't need them.
>> you should ask yourself where you want them?
>
> I desire them because I desire to modify the syntax where IMHO makes
> sense, for example something like:
>
> #include <stdio.h>
>
> #define loop(n) for (i = 0; i < n; i++)
>
> int main ()
> {
> unsigned int i;
>
> loop (10)
> do_something ();
>
> return 0;
> }
Frankly, I would not want the job of reading and trying to understand
your code if you stuff like that. Obscuring standard language elements
with home-grown substitutes is not a good idea. I know what 'for' is, I
do not know what 'loop' stands for. See also
http://www.eskimo.com/~scs/C-faq/q10.2.html
> In the Perl script I'm working on I would use it to write something
> like
>
> #define walk_file(FILE) for ($walk_file_line = <FILE>)
>
> walk_file (FILE) {
> ...
> }
>
> and alike.
>
> That's not necessary but IMHO it helps to make the code more clear.
Same comments apply to this. Perl programmers know Perl, but they do not
know your language. If you want a different language then you should
probably use a different language.
Sinan.
--
A. Sinan Unur
asu1@c-o-r-n-e-l-l.edu
Remove dashes for address
Spam bait: mailto:uce@ftc.gov
------------------------------
Date: Wed, 16 Jul 2003 14:12:48 GMT
From: marc0 <marc0@autistici.org>
Subject: Re: macros in perl
Message-Id: <87brvuk1gu.fsf@autistici.org>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
David K. Wall on Wed, 16 Jul 2003 13:46:27 -0000 writes:
> marc0 <marc0@autistici.org> wrote:
>> In the Perl script I'm working on I would use it to write something
>> like
>>
>> #define walk_file(FILE) for ($walk_file_line = <FILE>)
>>
>> walk_file (FILE) {
>> ...
>>}
>>
>> and alike.
>>
>> That's not necessary but IMHO it helps to make the code more clear.
>
> What's wrong with
>
> while (<FILE>) {
> # do stuff with $_ instead of $walk_file_line
> }
>
> ? It's the usual idiom; using something else seems like obfuscation
> to me.
I was not aware that $_ works with other things than subroutines, good
to know, that's fine, thank you.
IMHO the point in using long and specific names instead of the general
purpose ones is that you can guess what the variable/piece-of-code
contains/does more easily, the code becomes almost self-documenting,
and the code looks better too (but this last is a matter of taste).
- --
marc0@autistici.org http://www.autistici.org/marc0
(rot13-string "znep0@pelcgberoryf.arg")
2143 9E77 D5E6 115A 48AD A170 D0EE F736 4E88 99C2
-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)
iD8DBQE/FVw60O73Nk6ImcIRAh+DAKCGf6ScoFVSmSCU/kaM8XVSdBkTfgCfcftz
P3XMG/UOGnhxfm1Wji/kERg=
=U56N
-----END PGP SIGNATURE-----
------------------------------
Date: Wed, 16 Jul 2003 14:37:01 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: macros in perl
Message-Id: <hqdRa.6095$EZ2.777@nwrddc01.gnilink.net>
marc0 wrote:
> I desire them because I desire to modify the syntax where IMHO makes
> sense, for example something like:
>
> #include <stdio.h>
>
> #define loop(n) for (i = 0; i < n; i++)
>
> int main ()
> {
> unsigned int i;
>
> loop (10)
> do_something ();
>
> return 0;
> }
Is there anything wrong with the even shorter and more concise existing
form:
for (0..10) {
do_something();
}
> In the Perl script I'm working on I would use it to write something
> like
>
> #define walk_file(FILE) for ($walk_file_line = <FILE>)
>
> walk_file (FILE) {
> ...
> }
Anything wrong with the idiom
while (<FILE>) {
do_something_with_current_line;
}
>
> and alike.
>
> That's not necessary but IMHO it helps to make the code more clear.
Actually now. It obfuscates your code if you replace well-established idioms
with your own home-cooked solutions.
jue
------------------------------
Date: Wed, 16 Jul 2003 14:42:23 GMT
From: marc0 <marc0@autistici.org>
Subject: Re: macros in perl
Message-Id: <877k6ik03j.fsf@autistici.org>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
A. Sinan Unur on 16 Jul 2003 14:07:58 GMT writes:
[snip]
> Frankly, I would not want the job of reading and trying to understand
> your code if you stuff like that. Obscuring standard language elements
> with home-grown substitutes is not a good idea. I know what 'for' is, I
> do not know what 'loop' stands for. See also
>
> http://www.eskimo.com/~scs/C-faq/q10.2.html
Adding syntax seems like adding functions to me. The definition of the
additional syntax would be avaiable, like how happens for functions.
[snip]
> Same comments apply to this. Perl programmers know Perl, but they do not
> know your language. If you want a different language then you should
> probably use a different language.
I think of this different language simply as a language specific to
the problem and written on top of Perl, so that Perl programmers have
no problems with the problem-specific language, as it's an extension
of Perl written in Perl. That's already being done with functions.
Naturally IMHO.
- --
marc0@autistici.org http://www.autistici.org/marc0
(rot13-string "znep0@pelcgberoryf.arg")
2143 9E77 D5E6 115A 48AD A170 D0EE F736 4E88 99C2
-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)
iD8DBQE/FWNL0O73Nk6ImcIRAiobAKCN/j0jYSBnFnnm2KwfGGmb7Gc0gQCgwtdu
9e3TBNRyzKcjfhXLtuNiHSI=
=0Ye7
-----END PGP SIGNATURE-----
------------------------------
Date: Wed, 16 Jul 2003 14:56:19 GMT
From: marc0 <marc0@autistici.org>
Subject: Re: macros in perl
Message-Id: <873ch6jzgb.fsf@autistici.org>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
Jürgen Exner on Wed, 16 Jul 2003 14:37:01 GMT writes:
> marc0 wrote:
>> I desire them because I desire to modify the syntax where IMHO makes
>> sense, for example something like:
>>
>> #include <stdio.h>
>>
>> #define loop(n) for (i = 0; i < n; i++)
>>
>> int main ()
>> {
>> unsigned int i;
>>
>> loop (10)
>> do_something ();
>>
>> return 0;
>> }
>
>
> Is there anything wrong with the even shorter and more concise existing
> form:
>
> for (0..10) {
> do_something();
> }
But that was in C. :) Its purpose is to show a correct example.
>> In the Perl script I'm working on I would use it to write something
>> like
>>
>> #define walk_file(FILE) for ($walk_file_line = <FILE>)
>>
>> walk_file (FILE) {
>> ...
>> }
>
> Anything wrong with the idiom
>
> while (<FILE>) {
> do_something_with_current_line;
> }
No. Please see the my replies to David K. Wall and A. Sinan Unur.
>> and alike.
>>
>> That's not necessary but IMHO it helps to make the code more clear.
>
> Actually now. It obfuscates your code if you replace well-established idioms
> with your own home-cooked solutions.
This seems the usual opinion. I'm not very persuaded, but I think that
you peoples are right, I simply think that I was not clear: I want not
to replace every single idiom, I want only where this makes things
more explicit, and this would happen every N lines of code, not N
times per line.
- --
marc0@autistici.org http://www.autistici.org/marc0
(rot13-string "znep0@pelcgberoryf.arg")
2143 9E77 D5E6 115A 48AD A170 D0EE F736 4E88 99C2
-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)
iD8DBQE/FWaf0O73Nk6ImcIRAvicAKCIQGWCcBm9fF3l3Vj3FfJnWk1C5ACfUMFF
KOv2HocJkgFPR+BedCdg2fU=
=ZAyY
-----END PGP SIGNATURE-----
------------------------------
Date: Wed, 16 Jul 2003 08:30:02 -0500
From: kaeli <infinite.possibilities@NOSPAMatt.net>
Subject: Re: Newbie can't get CgiComments to name files correctly, and begs for help
Message-Id: <MPG.197f0f52d4ec273698971f@nntp.lucent.com>
In article <bf3802$alprk$1@ID-168665.news.uni-berlin.de>, me@privacy.net
enlightened us with...
> Hi,
> I'm a complete novice at this and I've been banging my head against a brick
> wall. I apologise if this is not an appropriate place to ask this question,
> and appreciate any help anyone can give me.
>
<snip>
This is a Perl script issue. I bet you'd get some helpful answers in
comp.lang.perl.
-------------------------------------------------
~kaeli~
There is no justification or rationalization
for mutilation. Ban declawing as inhumane.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace
-------------------------------------------------
------------------------------
Date: 16 Jul 2003 09:37:49 -0700
From: john_ramsden@sagitta-ps.com (John Ramsden)
Subject: Opening a socket connection on a serial port
Message-Id: <d27434e.0307160837.414a49d5@posting.google.com>
I have a perl script that needs to control connects and
disconnects of a dialup connection, and transfer data via
a TCP socket stream opened on it. This must work on Windows
and Unix.
After poking about on CPAN and elsewhere, I concluded that
for the basic modem control I need the Devel::SerialPort
module.
(Question in passing: Does Devel::SerialPort work on Windows
as well as Unix? The documentation says it was derived for
POSIX from Win32::SerialPort.)
But I'm not sure how to identify or map (?) this so that
my script can use it for a TCP socket connection.
Any advice, and/or pointers to code samples would be greatly
appreciated.
To put things in context, this requirement is for a security
hyperaware customer, who insists that the system on which my
monitoring package will runs must have no network link to the
outside world.
But as it may be linked to a local LAN, I can't assume the
modem will be the _only_ possibility for a socket connection
to use. Hence the need to somehow tie the socket open request
explicitly to the modem.
Thanks in advance.
Cheers
John Ramsden (john_ramsden@sagitta-ps.com)
------------------------------
Date: Wed, 16 Jul 2003 13:26:34 +0000 (UTC)
From: "Peter Wilson" <peter_wilson@mail.com>
Subject: PDF Outlines / Bookmarks (im lost)
Message-Id: <bf3jqa$kqu$1@titan.btinternet.com>
Hi
I am having some problems modifying a pdf created by "Acrobat PDFWriter"
from word 2000 in perl using the PDF::API2 module.
When I create the document it looks fine and every thing is on the correct
page, after creation I then would like to add Bookmarks (outlines) to the
document, I have opened other documents (not created by word created by
myself via the PDF::API2 module) and the code below works anyone got any
ideas?
Error:
Can't locate object method "outline" via package "PDF::API2::PDF::Objind" at
bookmark.pl line 10.
Code:
use PDF::API2;
$pdf = PDF::API2->open('Document2.pdf');
$page = $pdf->openpage(9);
$otls = $pdf->outlines;
$otl=$otls->outline();
$otl->title('ERL');
$otl->dest($page,-fit=>1);
$subotl=$otl->outline();
$subotl->title('sometext');
$subotl->dest($page,-fit=>1);
$pdf->saveas('Document99.pdf');
Im a bit lost
Thanks
Peter
------------------------------
Date: Wed, 16 Jul 2003 13:48:39 +0000 (UTC)
From: "Peter Wilson" <peter_wilson@mail.com>
Subject: Re: PDF Outlines / Bookmarks (im lost)
Message-Id: <bf3l3n$mh1$1@titan.btinternet.com>
"Peter Wilson" <peter_wilson@mail.com> wrote in message
news:bf3jqa$kqu$1@titan.btinternet.com...
> Hi
>
> I am having some problems modifying a pdf created by "Acrobat PDFWriter"
> from word 2000 in perl using the PDF::API2 module.
>
> When I create the document it looks fine and every thing is on the correct
> page, after creation I then would like to add Bookmarks (outlines) to the
> document, I have opened other documents (not created by word created by
> myself via the PDF::API2 module) and the code below works anyone got any
> ideas?
>
> Error:
>
> Can't locate object method "outline" via package "PDF::API2::PDF::Objind"
at
> bookmark.pl line 10.
>
> Code:
>
> use PDF::API2;
> $pdf = PDF::API2->open('Document2.pdf');
> $page = $pdf->openpage(9);
> $otls = $pdf->outlines;
> $otl=$otls->outline();
> $otl->title('ERL');
> $otl->dest($page,-fit=>1);
> $subotl=$otl->outline();
> $subotl->title('sometext');
> $subotl->dest($page,-fit=>1);
> $pdf->saveas('Document99.pdf');
>
> Im a bit lost
>
> Thanks
>
> Peter
>
>
Found the answer from the mailing group, sorry.
I simply needed a new version.
Peter
------------------------------
Date: Wed, 16 Jul 2003 18:03:10 +0300
From: Risto Vaarandi <risto.vaarandi@eyp.ee>
Subject: regexp problem with UTF8
Message-Id: <3F15692E.4070901@eyp.ee>
hi,
I have a perl program that has worked for 2 years on redhat and solaris
nodes without problems. Recently I moved it to a redhat9 node (which has
utf8 as default system character set), and discovered that the following
regular expression inside the program does not work:
if ($line =~ /^\s*([^=\s]+)\s*=\s*(.*\S)/) {
$keyword = $1;
$value = $2;
}
When the regexp is written as /^\s*(\w+)\s*=\s*(.*\S)/, or as
/^\s*([^=]+)\s*=\s*(.*\S)/ , everything works fine. What could be the
problem here? (When I change the system charset from UTF8 to iso8859-1,
it works.)
br,
risto
------------------------------
Date: Wed, 16 Jul 2003 13:46:01 -0400
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
Subject: Re: shorten expression
Message-Id: <Pine.SGI.3.96.1030716134539.41374A-100000@vcmr-64.server.rpi.edu>
On 16 Jul 2003, Abigail wrote:
>Jeff 'japhy' Pinyan (pinyaj@rpi.edu) wrote on MMMDCV September MCMXCIII
>in <URL:news:Pine.SGI.3.96.1030715112248.17707C-100000@vcmr-64.server.rpi.edu>:
>)) On Tue, 15 Jul 2003, ZZT wrote:
>))
>)) >is there a way to shorten this expression?
>)) >
>)) >$host=~/^(\S*)\s*/; $host=$1;
>))
>)) Well, as it stands, even if the regex FAILS, $host will be set to whatever
>)) $1 was before the regex.
>
>But the only string on which the regexp can fail is a string that
>doesn't have a beginning. Now, in perl6, with lazy evaluation, we
>might be able to construct strings without an end.
>
>But how do I make a string without a beginning?
I realized that, later. A silly thing to have said.
--
Jeff Pinyan RPI Acacia Brother #734 2003 Rush Chairman
"And I vos head of Gestapo for ten | Michael Palin (as Heinrich Bimmler)
years. Ah! Five years! Nein! No! | in: The North Minehead Bye-Election
Oh. Was NOT head of Gestapo AT ALL!" | (Monty Python's Flying Circus)
------------------------------
Date: 16 Jul 2003 11:41:01 -0400
From: Jay Rogers <jay@rgrs.com>
To: <gshears@eastlink.ca>
Subject: Re: TELNET and waitfor problems
Message-Id: <kwpsmp6scmq.fsf@panix5.panix.com>
<gshears@eastlink.ca> writes:
> I am using perl's telnet to collect data on a TL1 connection, the waitfor
> option doesn't seem to work:
>
> $telnet->print('ACT-USER:AAACSV_5000:TEST:A1::TEST1;');
> $telnet->waitfor('/;/');
This is likely matching the semi-colon in your echo'd back
command, not the semi-colon ending command output. Perhaps this
would work better:
($lines) = $self->waitfor('/\n;/');
TL1 is a poorly designed interface. Also remember that in TL1,
autonomous messages can spew at anytime and that command output
over a certain size is broken up into continuation messages.
--
Jay Rogers
jay@rgrs.com
------------------------------
Date: Wed, 16 Jul 2003 17:29:14 +0200
From: fuzz@uni-paderborn.de (Erik Wasser)
Subject: UTF8 where no UTF8 should be in combination with XML::Simple
Message-Id: <aj7gu-pmh.ln1@wasser-7359.user.cis.dfn.de>
Keywords: UTF8,perl,XML::Simple
Sorry for the long posting, but you need a data file and a little perl
script for demonstrating the bug/behavior/feature. So please be patient.
B-)
Imagine the following data file:
--- foobar.xml -------------------------------------------------
<?xml version='1.0' encoding='ISO-8859-1'?>
<ticket id="1">
</ticket>
--- end of foobar.xml ------------------------------------------
and the following script (as short as possible):
--- foo.pl -----------------------------------------------------
#!/usr/bin/perl
use strict;
use diagnostics;
use warnings;
use Data::Dumper;
use XML::Simple;
my $token = XML::Simple::XMLin(join('', <STDIN>)); # Footnote [1],[3]
$token->{token}->{work} = [ 'ÄÖÜäöüß','ÄÖÜäöüß'];
print map { "$_\n" } # Footnote [2]
XML::Simple::XMLout(
$token,
rootname => 'ticket',
XMLDecl => "<?xml version='1.0' encoding='ISO-8859-1'?>",
),
XML::Simple::XMLout(
$token,
rootname => 'ticket',
XMLDecl => "<?xml version='1.0' encoding='ISO-8859-1'?>",
);
--- end of foo.pl ----------------------------------------------
If you do a "perl foo.pl <foobar.xml" everything is fine and you got the
following output 2(!) times:
<?xml version='1.0' encoding='ISO-8859-1'?>
> <ticket id="1">
> <token>
> <work>ÄÖÜäöüß</work>
> <work>ÄÖÜäöüß</work>
> </token>
> </ticket>
Correct encoded in ISO-8859-1.
If you do a "perl -T foo.pl <foobar.xml" you got:
- one times the output from above and one time:
> <?xml version='1.0' encoding='ISO-8859-1'?>
> <ticket id="1">
> <token>
> <work>ÃÃÃäöüÃ</work>
> <work>ÃÃÃäöüÃ</work>
> </token>
> </ticket>
The first time is correct encoded in ISO-8859-1 but the second time is
encoded in UTF-8. Why that? And why the second time only and not both?
I'm very clueless.
Have anybody some explanations for this? I contacted the author of
XML::Simple, but he think it's not his problem. I would agree to this
(so I didn't post this to comp.lang.perl.modules). I think the
conversion from the file STDIN to the internal perl string format is
broken.
Footnote [1]
If you create the XML::Simple object with a HERE document everything is
fine.
Footnote [2]
If you delete the "map { ... }" statement everything is fine too.
Footnote [3]
If you untaint STDIN with the following construct:
> my $s = join('', <STDIN>);
> $s = $1 if ($s =~ /^(.*)$/);
> my $token = XML::Simple::XMLin($s);
the bug is already there.
Any explanations? Any ideas?
P.S: I'm using XML-Simple-2.08, "perl, v5.8.0 built for
i386-linux-thread-multi" and Redhat 9.
--
So long... Fuzz
------------------------------
Date: Wed, 16 Jul 2003 14:04:32 -0700
From: Steve <me@home.com>
Subject: what exactly do you need to escape? (I can never get this straight)
Message-Id: <d9fbhvkuo8fppd82tp7tn63gtoue2hv8dq@4ax.com>
Hi all,
As the topic says, what exactly do you need to escape? I can never get
this straight. For instance, I see this line of code when reading
through the newsgroups:
unlink glob "$jukebox[$i]/$date/*" or die "Cannot unlink files: $!";
but I am always escaping the forward slash as \/.
Thanks in advance,
Steve
------------------------------
Date: Wed, 16 Jul 2003 15:24:45 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Why is 'last' not allowed here
Message-Id: <9grahvsea94q6gdg556v4sfdd9ac7h26kc@4ax.com>
Tassilo v. Parseval wrote:
>Looks odd, but works as
>expected:
>
> if (1) {{
> last; # 'next' is actually equivalent in these cases
> }}
I'd prefer it the other way around:
{
if (1) {
last; # 'next' is actually equivalent in these cases
}
}
--
Bart.
------------------------------
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.
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 5229
***************************************