[21737] in Perl-Users-Digest
Perl-Users Digest, Issue: 3941 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Oct 9 18:06:47 2002
Date: Wed, 9 Oct 2002 15:05:15 -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, 9 Oct 2002 Volume: 10 Number: 3941
Today's topics:
'Malformed header' using CGI with IO::Handle <philip@paeps.cx>
Re: 96-column punched-card data <Use-Author-Supplied-Address-Header@[127.1]>
Accessing Oracle Database from Unix using Perl <shivag@wanadoo.nl>
An RE to encode XML entities <cpryce@pryce.net>
Re: An RE to encode XML entities <flavell@mail.cern.ch>
Re: An RE to encode XML entities <cpryce@pryce.net>
Re: An RE to encode XML entities (Tad McClellan)
Re: An RE to encode XML entities <flavell@mail.cern.ch>
Re: Anyone who uses Perl on VAX (Ph3arnot)
Re: Anyone who uses Perl on VAX <goldbb2@earthlink.net>
Re: Anyone who uses Perl on VAX (Malcolm Dew-Jones)
Attend LISA '02, the 16th Systems Administration Confer <alex@usenix.org>
Can anyone tell me how to get GD (& GD::Graph) working <me@home.com>
cgi.pm code <todd@mrnoitall.com>
Re: cgi.pm code <camerond@mail.uca.edu>
Fast Stat <demetros@vnet.ibm.com>
GMT Windows vs Linux <nospam@fakedomain.com>
Re: GMT Windows vs Linux <ddunham@redwood.taos.com>
Re: GMT Windows vs Linux <nospam@fakedomain.com>
Re: Help me understand *foo = \... <goldbb2@earthlink.net>
How can I tell what version a module is? <du_bing@hotmail.com>
Re: ithreads, perl 5.8 and shared objects <goldbb2@earthlink.net>
modification of read-only value error in format <what_do_i_do@nothotmail.org>
Re: modification of read-only value error in format <what_do_i_do@nothotmail.org>
Re: modification of read-only value error in format (Tad McClellan)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 09 Oct 2002 22:00:52 GMT
From: Philip Paeps <philip@paeps.cx>
Subject: 'Malformed header' using CGI with IO::Handle
Message-Id: <oG1p9.154508$8o4.24115@afrodite.telenet-ops.be>
Apologies in advance if this has been asked a thousand times. Google didn't
have an answer for me, perhaps I asked the wrong question?
When I use CGI together with a module which prints to STDOUT in using
IO::Handle (such as XML::Writer, for example) I always get 'Malformed Header'
in my Apache logs.
Little code fragments, where $q is a CGI object and $writer an XML::Writer
object. The objects have only just been created.
Works:
------
print $q->header(-type => 'text/xml');
print "<?xml version=\"1.0\"?>\n"
(I just get Mozilla complaining at me about invalid XML)
Doesn't work:
-------------
print $q->header(-type => 'text/xml');
$writer->xmlDecl("utf-8");
(Internal Server Error, and 'Malformed Header' in the logs)
Running both on the command line produce identical results. There is a \n\n
after the Content-Type header in both cases, so It Should Just Work too. It
doesn't though. Perl -wcT shows no syntax errors either.
I did some testing, and it appears as though CGI doesn't like IO::Handle very
much.
Something like below also produces a malformed header:
print $q->header(-type => 'text/xml');
my $io = new IO::Handle;
if ($io->fdopen(fileno(STDOUT),"w"))
{
$io->print("Some text\n");
}
else
{
die "Whoops!\n";
}
Any thoughts, anyone? Anything obvious I've overlooked?
Thanks in advance!
- Philip
--
Philip Paeps philip@paeps.cx
Program design philosophy:
Start at the beginning and continue until the end,
then stop.
-- Lewis Carroll
------------------------------
Date: Wed, 9 Oct 2002 15:10:39 -0500 (CDT)
From: Robert Brooks <Use-Author-Supplied-Address-Header@[127.1]>
Subject: Re: 96-column punched-card data
Message-Id: <200210092010.g99KAdro092667@cryptofortress.com>
Thanks to all the solution providers! Sorry for the
delay in responding to your posts.
You have given me a whole to study and learn from
about Perl. I see that split and use constant
are two areas to start on first.
The Perl community is such a great resource, I'm
really glad I asked about the 96-column card
problem. It's the real-world way to learn how
to write good Perl code.
Thanks again!
------------------------------
Date: Wed, 09 Oct 2002 18:23:34 GMT
From: "Shivakumar Gopalakrishnan" <shivag@wanadoo.nl>
Subject: Accessing Oracle Database from Unix using Perl
Message-Id: <Gu_o9.28551$PO2.489952@castor.casema.net>
Hello everyone,
I need some help. There is a non-profit helping organization which is having
a small database in Access. I am trying to help them to migrate to Oracle
under Linux(Which they are trying to get it for free). I would like to
convert their interfaces to be html based using Perl (If it is not that
complicated).
It will be nice if someone points me to some examples which will help me in
the process.
Thanks in advance...
- Shiva
------------------------------
Date: Wed, 09 Oct 2002 14:09:54 -0500
From: cp <cpryce@pryce.net>
Subject: An RE to encode XML entities
Message-Id: <B9C9E932.FEBE%cpryce@pryce.net>
I need help writing a RE to take care of character encodings in XML.
Obviously, I can write :
$str =~ s/&/$amp;/g;
But what if the character is already Encoded properly?
I want to encode :
$str = 'This is good & plenty';
$str = 'curiouser&courioser';
But ignore each of:
$str = 'This is good & plenty';
$str = 'This is < that';
I was thinking :
$str =~ s/\b&\b/&/gs;
Which seems to work for most instances. Is there a better one? Is there a
module that covers this?
Thanks
cp
------------------------------
Date: Wed, 9 Oct 2002 22:10:13 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: An RE to encode XML entities
Message-Id: <Pine.LNX.4.40.0210092201080.5668-100000@lxplus076.cern.ch>
On Oct 9, cp inscribed on the eternal scroll:
> I need help writing a RE to take care of character encodings in XML.
>
> Obviously, I can write :
>
> $str =~ s/&/$amp;/g;
[something like that, anyhow, but...]
> But what if the character is already Encoded properly?
Then you would seem to be confused about the nature of the material
that you are getting as input.
> I want to encode :
>
> $str = 'This is good & plenty';
> $str = 'curiouser&courioser';
>
> But ignore each of:
> $str = 'This is good & plenty';
> $str = 'This is < that';
Why? This doesn't seem to be a well-formed problem. Either you are
presented with XML, or you are presented with something that isn't
XML. They would seem to call for different processing, in a global
sense; you can't just go fiddling with stuff locally and hope to
produce something meaningful, it seems to me.
Suppose your text was a document explaining something about XML.
So it might say "remember to express & as &"
You would apparently want to make that say:
"remember to express & as &"
which is nonsense - when you really should make it say:
"remember to express & as &amp;"
Just to take a simple case to exhibit your problem.
------------------------------
Date: Wed, 09 Oct 2002 15:31:40 -0500
From: cp <cpryce@pryce.net>
Subject: Re: An RE to encode XML entities
Message-Id: <B9C9FC5C.FEE0%cpryce@pryce.net>
in article Pine.LNX.4.40.0210092201080.5668-100000@lxplus076.cern.ch, Alan
J. Flavell at flavell@mail.cern.ch wrote on 10/9/02 3:10 PM:
>
> Then you would seem to be confused about the nature of the material
> that you are getting as input.
>
>> I want to encode :
>>
>> $str = 'This is good & plenty';
>> $str = 'curiouser&courioser';
>>
>> But ignore each of:
>> $str = 'This is good & plenty';
>> $str = 'This is < that';
>
> Why? This doesn't seem to be a well-formed problem. Either you are
> presented with XML, or you are presented with something that isn't
> XML. They would seem to call for different processing, in a global
> sense; you can't just go fiddling with stuff locally and hope to
> produce something meaningful, it seems to me.
Yes. The problem is that I am working with several editors (some are
technologically-challenged writers). Some will present well-formed text.
Some will not. None of it is XML, but it must be parsed into XML.
>
> Suppose your text was a document explaining something about XML.
> So it might say "remember to express & as &"
>
> You would apparently want to make that say:
> "remember to express & as &"
>
> which is nonsense - when you really should make it say:
> "remember to express & as &amp;"
>
> Just to take a simple case to exhibit your problem.
A good case to keep in mind, thank you. My immediate problem was that one
editor turned in '"Final Plans & Specs" and another presented "Final P, S
& E", having converted MS word to html before submitting. It is often
not consistent, but it will either be valid XHTL or plain ASCII with illegal
characters. Obviously investing in XML editors would save me some time, but
I don't have any control over that (yet).
I was experimenting with this:
#!/usr/local/bin/perl -w
use strict;
my $str = <<HERE;
'"this" & “this“ remain unchanged.
This&this gets encoded & >> this gets encoded. So does this <<. '
HERE
# for special characters that MS Word embeds. Others may follow
$str =~ s/í/'/gs;
$str =~ s/­/-/sg;
$str =~ s/‚/-/sg;
$str =~ s/["ìî]/"/sg;
# generic xml entities removed
$str =~ s/</</sg;
$str =~ s/>/>/sg;
# change ampersand UNLESS they're part of an already encoded entity
$str =~ s/&(?![\#\d;|\w+;])/&/go;
print $str;
__END__
$perl re.pl
'"this" & “this“ remain unchanged.
This&this gets encoded & >> this gets encoded. So does this
<<. '
------------------------------
Date: Wed, 9 Oct 2002 16:08:35 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: An RE to encode XML entities
Message-Id: <slrnaq96mj.3au.tadmc@magna.augustmail.com>
cp <cpryce@pryce.net> wrote:
> I need help writing a RE to take care of character encodings in XML.
>
> Obviously, I can write :
>
> $str =~ s/&/$amp;/g;
>
> But what if the character is already Encoded properly?
> I was thinking :
> $str =~ s/\b&\b/&/gs;
^
^
The s///s option is not needed for that pattern.
> Which seems to work for most instances. Is there a better one?
$str =~ s/&(?!\w+;)/&/g;
Need [\w:.-] instead of just \w to catch all chars allowed in an XML "name":
$str =~ s/&(?![\w:.-]+;)/&/g;
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 9 Oct 2002 23:15:53 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: An RE to encode XML entities
Message-Id: <Pine.LNX.4.40.0210092310240.5668-100000@lxplus076.cern.ch>
On Oct 9, cp inscribed on the eternal scroll:
> Yes. The problem is that I am working with several editors (some are
> technologically-challenged writers). Some will present well-formed text.
> Some will not.
[...]
> A good case to keep in mind, thank you. My immediate problem was that one
> editor turned in '"Final Plans & Specs" and another presented "Final P, S
> & E", having converted MS word to html before submitting. It is often
> not consistent, but it will either be valid XHTL or plain ASCII with illegal
> characters.
Then IMHO you'll probably want a preliminary sniff at each piece you
got, and set a flag as to whether it's HTML-flavoured or
plaintext-like, and let subsequent processing be dependent on that.
Btw, remember for proper results if you're getting those bogus
&#number; references from MS where 'number' is in the range 128-159
decimal, you'll need a lookup table of unicode values, since XML rules
out 128-159 as illegal. (In HTML they were technically "undefined",
rather than actually illegal...).
> Obviously investing in XML editors would save me some time, but
> I don't have any control over that (yet).
I can certainly sympathise with that.
Good luck
------------------------------
Date: 9 Oct 2002 11:48:53 -0700
From: ph3arnot@hotmail.com (Ph3arnot)
Subject: Re: Anyone who uses Perl on VAX
Message-Id: <32b689fe.0210091048.250d0c2f@posting.google.com>
Jim Agnew <jpagnew@vcu.edu> wrote in message news:<3DA2EDE3.6C5B4B06@vcu.edu>...
> "Alan J. Flavell" wrote:
> >
> > On Oct 7, pkent inscribed on the eternal scroll:
> >
> > > A Vax is the hardware platform, and it runs the operating system
> > > OpenVMS. I don't think Vaxen run Digital UNIX.
> >
> > Sort-of. VAX is a (now obsolete) hardware platform, which usually ran
> > VAX/VMS - what has now become OpenVMS.
> >
> > However, the VAX hardware could run some kind of unix. But anyone who
> > was doing that would say so up front - if you're told nothing more
> > than that it's a VAX, it's a near certainty that the OS is VMS, I
> > would say.
> >
> > > > What is it similar to - UNIX? MPEIX? Dos?
> > >
> > > I'd say it's different from all of them, in various ways :-)
> >
> > Indeed ;-)
> >
> > Its habit of keeping multiple versions of the same file would be quite
> > welcome - now that disk space has become so cheap. Back then we were
> > forever purging old versions to retrieve some of the precious disk
> > space.
>
> I agree, there is Ultrix, bsd, and maybe another one or two.. but if
> they call it a vax, chances are it's VMS (ok, excuse me, OpenVMS)...
> ;-)
Quite interesting, the OpenVMS manuals are now emblazened with the HP
logo. I thought it was weird to see these things coming in with
Compaq splattered on them, but the "HP" really makes me cringe... :)
An interesting note, the version of perl that is running on our
VAX/Alpha cluster DOESN'T have a "chomp" command. I haven't even
looked at the version since I don't use it very often on this
platform, as most of my work is low level coding done either in C or
PL/1 (Eeeeek) - but I did find that to be somewhat interesting...
One other thing that didn't work well was socket programming. Since
VMS didn't really have support for such things built into the OS (at
least with the 6.X versions, not sure about 7.X), TCP/IP type
connections were usually handled by some other software - Multinet
comes to mind. And, hooking into the functions of these other
packages isn't necessarily a trivial matter, if it can be done at all.
------------------------------
Date: Wed, 09 Oct 2002 15:22:24 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Anyone who uses Perl on VAX
Message-Id: <3DA481F0.E89E0FC3@earthlink.net>
Ph3arnot wrote:
[snip]
> One other thing that didn't work well was socket programming. Since
> VMS didn't really have support for such things built into the OS (at
> least with the 6.X versions, not sure about 7.X), TCP/IP type
> connections were usually handled by some other software - Multinet
> comes to mind. And, hooking into the functions of these other
> packages isn't necessarily a trivial matter, if it can be done at all.
Assuming that IPC::Open2 works on VMS, you could always do:
use IPC::Open2;
my $multinet_process_id = open2(
my( $read_from_socket, $write_to_socket,
"multinet <args to specify remote host>" # or whatever.
);
Then that external program opens the socket, you read and write from
your connections to it, and it reads from and writes to the socket.
PS: Perl without chomp is *old* ... see if you can install a newer perl,
either 5.6.1 or 5.8.0. It's possible (I dunno, not having looked at the
docs) that newer perls natively have support for sockets on VMS.
--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]
------------------------------
Date: 9 Oct 2002 12:33:51 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: Anyone who uses Perl on VAX
Message-Id: <3da4849f@news.victoria.tc.ca>
Ph3arnot (ph3arnot@hotmail.com) wrote:
: One other thing that didn't work well was socket programming. Since
: VMS didn't really have support for such things built into the OS (at
: least with the 6.X versions, not sure about 7.X), TCP/IP type
: connections were usually handled by some other software - Multinet
: comes to mind. And, hooking into the functions of these other
: packages isn't necessarily a trivial matter, if it can be done at all.
To whomsoever it may concern, I would just like to point out that there is
(was) a free network interface library called NET_LIB (NETLIB?) that
provided a single interface to all the most common TCP/IP stacks available
for VMS.
Anyone who does IP network programming on VMS should at least check into
this library before coding anything specific to one stack or another.
I mention this because I used to see numerous VMS things that seemed to be
dependant on one particular stack or another, and that may have been just
because the author didn't know about this library interface.
------------------------------
Date: Wed, 09 Oct 2002 15:01:37 -0700
From: Alex Walker <alex@usenix.org>
Subject: Attend LISA '02, the 16th Systems Administration Conference
Message-Id: <3DA4A741.7020705@usenix.org>
Attend LISA '02, the 16th Systems Administration Conference in
Philadelphia, November 3-8, 2002. http://www.usenix.org/lisa02
This year's conference is packed with:
* Training in cutting-edge technologies through 39 tutorials.
* Personal access to industry experts, including Jim Reese, chief
operations engineer, Google, Eric Allman, original author of sendmail,
Larry Wall, creator of Perl and Paul Vixie, maintainer of the open
source version of BIND ("name service").
* Exposure to the most pressing and controversial issues including, the
constitutionality of SPAM, the debate over the necessity of journaling
and the presentation of a simple, but elegant mathematical model on the
cost of down time.
* Issue filled technical sessions, essential networking and security
tracks, FREE vendor exhibition and provocative refereed papers.
Early registration ends October 11, 2002.
http://www.usenix.org/lisa02
--
Alex Walker
Production Editor
USENIX Association
2560 Ninth Street, Suite 215
Berkeley, CA 94710
510/528-8649 x33
------------------------------
Date: Wed, 9 Oct 2002 19:22:34 +0100
From: "Rubber Duck" <me@home.com>
Subject: Can anyone tell me how to get GD (& GD::Graph) working on Win32!!
Message-Id: <kI0p9.16928$La6.12941@news-binary.blueyonder.co.uk>
Can anyone tell me how to get GD (& GD::Graph) working on Win32!!
As subject. I've searched google till i'm blue in the face Played about
with GD.dll and GD.pll. I'm trying to use GD::Graph but of course this
needs GD which on linux has C dependencies.
Your help will be greatly appreciated :-)
PT
------------------------------
Date: Wed, 09 Oct 2002 13:22:47 -0600
From: Todd Anderson <todd@mrnoitall.com>
Subject: cgi.pm code
Message-Id: <3DA48204.E24F2848@mrnoitall.com>
Dear sirs,
Below is code that should replace /n with <BR>. It doesn't work.
Any help is appreciated.
Thanks in advance.
@display_items = (
"realtorpage",
"text",
"picture1_caption",
"picture2_caption",
"picture3_caption",
"picture4_caption"
);
foreach $thingy(@display_items){
param('$thingy' => ~ s/\n/<BR>/g);
}
------------------------------
Date: Wed, 09 Oct 2002 14:53:58 -0500
From: Cameron Dorey <camerond@mail.uca.edu>
Subject: Re: cgi.pm code
Message-Id: <3DA48956.7030002@mail.uca.edu>
Todd Anderson wrote:
> Dear sirs,
> Below is code that should replace /n with <BR>. It doesn't work.
> Any help is appreciated.
> Thanks in advance.
>
> @display_items = (
> "realtorpage",
> "text",
> "picture1_caption",
> "picture2_caption",
> "picture3_caption",
> "picture4_caption"
> );
>
> foreach $thingy(@display_items){
> param('$thingy' => ~ s/\n/<BR>/g);
> }
>
>
What doesn't work? I don't see anything that _should_ happen here (i.e.,
I don't see any newlines "\n" - not "/n" - in your array).
Irregardless, "It doesn't work" tells the reader absolutely nothing s/he
can use to diagnose your problem. What *does* happen would.
Cameron
--
Cameron Dorey
Associate Professor of Chemistry
University of Central Arkansas
Phone: 501-450-5938
camerond@mail.uca.edu
------------------------------
Date: Wed, 09 Oct 2002 15:03:09 -0400
From: "George C. Demetros" <demetros@vnet.ibm.com>
Subject: Fast Stat
Message-Id: <3DA47D6D.22AA653D@vnet.ibm.com>
Hi.
I need to stat across the ocean and I was wondering of there was anything out
there that would do a stat more efficiently than the built in perl function. I
am aware of using the underscore to speed things up, i.e.:
stat($fileName);
if (-f _) # will utilize the last stat.
Thanks in advance.
George
------------------------------
Date: Wed, 9 Oct 2002 13:18:38 -0500
From: "J. Dawson" <nospam@fakedomain.com>
Subject: GMT Windows vs Linux
Message-Id: <3da47313$0$1403$272ea4a1@news.execpc.com>
When I SSH to my Linux sever and enter the command 'date,' it displays the
correct local time and shows the time zone too as CDT.
However when I use the statement 'gmtime(time)' to calculate GMT in a perl
script on a Linux server, I get a time that is off by 1 hour. I need to
subtract 1 hour to get the actual GMT. It is as if perl is not compensating
for Daylight Savings Time.
On the contrary, on a Windows machine (blechk), compensation for Daylight
Savings Time is performed. I am quite surprised that the linux version
falls behind. Am I forgetting something I need to do on the Linux?
Perl/Linux works so well that I take it for granted sometimes.
------------------------------
Date: Wed, 09 Oct 2002 18:44:33 GMT
From: Darren Dunham <ddunham@redwood.taos.com>
Subject: Re: GMT Windows vs Linux
Message-Id: <lO_o9.2160$_h6.222796079@newssvr13.news.prodigy.com>
J. Dawson <nospam@fakedomain.com> wrote:
> When I SSH to my Linux sever and enter the command 'date,' it displays the
> correct local time and shows the time zone too as CDT.
> However when I use the statement 'gmtime(time)' to calculate GMT in a perl
> script on a Linux server, I get a time that is off by 1 hour. I need to
> subtract 1 hour to get the actual GMT. It is as if perl is not compensating
> for Daylight Savings Time.
Perl is generally asking the system libraries for the data and not
compensating for anything.
Please enter these 6 lines on the linux machine and let's see the
output.
perl -le 'print scalar localtime'
date
perl -le 'print scalar gmtime'
date -u
echo $TZ
perl -le 'print $ENV{TZ}'
--
Darren Dunham ddunham@taos.com
Unix System Administrator Taos - The SysAdmin Company
Got some Dr Pepper? San Francisco, CA bay area
< This line left intentionally blank to confuse you. >
------------------------------
Date: Wed, 9 Oct 2002 15:21:45 -0500
From: "J. Dawson" <nospam@fakedomain.com>
Subject: Re: GMT Windows vs Linux
Message-Id: <3da48fea$0$1404$272ea4a1@news.execpc.com>
"Darren Dunham" <ddunham@redwood.taos.com> wrote in message
news:lO_o9.2160$_h6.222796079@newssvr13.news.prodigy.com...
> J. Dawson <nospam@fakedomain.com> wrote:
> > When I SSH to my Linux sever and enter the command 'date,' it displays
the
> > correct local time and shows the time zone too as CDT.
>
> > However when I use the statement 'gmtime(time)' to calculate GMT in a
perl
> > script on a Linux server, I get a time that is off by 1 hour. I need to
> > subtract 1 hour to get the actual GMT. It is as if perl is not
compensating
> > for Daylight Savings Time.
>
> Perl is generally asking the system libraries for the data and not
> compensating for anything.
>
> Please enter these 6 lines on the linux machine and let's see the
> output.
>
> perl -le 'print scalar localtime'
> date
> perl -le 'print scalar gmtime'
> date -u
> echo $TZ
> perl -le 'print $ENV{TZ}'
>
> --
> Darren Dunham ddunham@taos.com
> Unix System Administrator Taos - The SysAdmin Company
> Got some Dr Pepper? San Francisco, CA bay area
> < This line left intentionally blank to confuse you. >
Here is the input/output you mention.
$ perl -le 'print scalar localtime'
Wed Oct 9 15:06:30 2002
$ date
Wed Oct 9 15:06:48 CDT 2002
$ perl -le 'print scalar gmtime'
Wed Oct 9 20:07:22 2002
$ date -u
Wed Oct 9 20:07:32 UTC 2002
$ echo $TZ
$ perl -le 'print $ENV{TZ}'
I am surprised that they are the same between perl output and the system
output. I will collect the code from my script and check it again and post
it and any results I conclude.
Thanks for your response.
James Dawson
------------------------------
Date: Wed, 09 Oct 2002 15:00:41 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Help me understand *foo = \...
Message-Id: <3DA47CD9.D67629B7@earthlink.net>
David Bouman wrote:
>
> Benjamin Goldberg wrote:
>
> > When you assign an arrayref to a typeglob, it replaces the appropriate
> > slot of the typeglob with that arrayref. In other words, suppose you
> > did:
> > my $x = \@xyz; my $y = [1, 2, 3];
> > print $x, $y, \@xyz, "\n";
> > *xyz = $x;
> > print $x, $y, \@xyz, "\n";
> > You'll get something like:
> > ARRAY(0xdeadbeef)ARRAY(0x12345678)ARRAY(0xdeadbeef)
> > ARRAY(0xdeadbeef)ARRAY(0x12345678)ARRAY(0x12345678)
>
> Euh, if you expect those results shouldn't you have done:
>
> *xyz = $y;
>
> instead ?
Oops, yes. I ought to have tested before posting.
--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]
------------------------------
Date: Wed, 09 Oct 2002 17:03:50 -0500
From: user <du_bing@hotmail.com>
Subject: How can I tell what version a module is?
Message-Id: <3DA4A7C6.9078B253@hotmail.com>
Specifically, I need to know what IO::Socket::SSL version we have.
Reading its manpage did not give me any clue. It does not have a
version method.
Thanks for any hints,
Bing
------------------------------
Date: Wed, 09 Oct 2002 15:13:48 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: ithreads, perl 5.8 and shared objects
Message-Id: <3DA47FEC.CDEB13CC@earthlink.net>
Ilya Zakharevich wrote:
> Benjamin Goldberg wrote:
> > > Now suppose two modules - which do not know about each other - try
> > > to subclass select(). How would they do it?
> >
> > That's not how you would do it. Let's suppose you have written...
>
> I do not discuss applications. I discuss two *modules*. Both use
> POE. Both substitute their own event loop.
If they use POE, they should use POE's event loop.
Stubstituting their own event loops is a *dumb* thing to do in general,
and should only be done if no other way will work.
> > , and viala! they work fine anyway.
>
> Now I see you all are blindfolded... Let me describe some (only 1/4
> contrived) example.
>
> You have a BourneShell module. This module is given a program (a
> string) of a form
>
> (( a && ( b || c ) ) || (e && (f && h)) & (x || y) ; z ) | ( zz ||v zzz)
>
> and starts the applications *without any forking*. The event loop of
> this module is based on wait().
Why not wait for EOF from the STDOUT of the last process in the chain?
> Each event is a termination of a kid;
> the module then starts the new kids (with appropriate redirected
> outputs) basing on the return value of the current kid.
>
> (I assume POE is good enough to allow using an externally supplied
> wait()-based event loop.)
POE cannot use an externally supplied event loop except via a bridge
class, such as the one which allows it to use Tk's event loop.
POE can only use one externally supplied event loop at a time.
> Author A writes BourneShell using POE
> facilities and replaces POE event loop.
>
> Now I find another module ShowMeTheTree; it is written by author AA;
> it has a pluggable UI backend, and uses POE to get a
> backend-transparent event loop.
Ok, so ShowMeTheTree has it's own bridge class to use POE (whereas
BourneShell had a POE bridge class so POE can use *it*).
> I think: now I can use these two modules and write a debugger for
> bourne shell programs which is essentially a Perl one-liner. Can I?
If POE is using BS's event loop, and SMTT is using the normal interface
to POE's event loop (which gets routed through the bridge to BS), then
it might indeed be possible.
--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]
------------------------------
Date: Wed, 09 Oct 2002 15:36:44 -0400
From: Dan Becker <what_do_i_do@nothotmail.org>
Subject: modification of read-only value error in format
Message-Id: <3DA4854C.112F2BFD@nothotmail.org>
Am using perl 5.6.1, but also have to be compatible with older 5.005_03.
the following program results in the error message:
Modification of a read-only value attempted at t.pl line 6.
I looked (RTFM), but couldnt find a full description of how to share the
format between multiple functions.
I could put the format inside a single function, and it works, but I want
to share it. and I do want to use strict, to look for unintentional
conflicts.
I'm looking for a pointer to a clear description of the interaction between
use strict, use vars, and why this doesnt work.
thanks!
Dan Becker
-----
use strict;
my $foo;
format STDOUT =
@^<<<<<<<<<<
$foo,
~ @^<<<<<<<<
$foo
.
sub hello {
$foo = "Hello, World, today";
write;
}
sub hello2 {
$foo = "Hello, World, tomorrow";
write;
}
&hello;
&hello2;
-----
------------------------------
Date: Wed, 09 Oct 2002 16:54:34 -0400
From: Dan Becker <what_do_i_do@nothotmail.org>
Subject: Re: modification of read-only value error in format
Message-Id: <3DA4978A.6F74A988@nothotmail.org>
found the problem. i knew I just needed to post something.
the formats were wrong. needed ^<<<<<< instead of @^<<<<<<<.
--
Dan Becker
dcbecker@lucent.com
------------------------------
Date: Wed, 9 Oct 2002 16:28:20 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: modification of read-only value error in format
Message-Id: <slrnaq97rk.3au.tadmc@magna.augustmail.com>
Dan Becker <what_do_i_do@nothotmail.org> wrote:
> the following program results in the error message:
> I looked (RTFM), but couldnt find a full description of how to share the
> format between multiple functions.
Sharing the format is not the cause of your problem.
> I'm looking for a pointer to a clear description of the interaction between
> use strict, use vars,
use strict, use vars is not the cause of your problem.
> and why this doesnt work.
See below.
> use strict;
use warnings; # -w on older perls
would have given you a hint.
You should always enable warnings when developing Perl code!
> format STDOUT =
> @^<<<<<<<<<<
> $foo,
You have 2 fields, but only 1 variable.
Did you mean to leave the at-sign out?
--
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.
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 3941
***************************************