[10838] in Perl-Users-Digest
Perl-Users Digest, Issue: 4439 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Dec 16 12:25:20 1998
Date: Wed, 16 Dec 98 09:00:25 -0800
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 Dec 1998 Volume: 8 Number: 4439
Today's topics:
500 server error <echandon@yahoo.com>
Re: 500 server error (Fluffy)
Re: binmode (Bart Lateur)
build perl on IRIX-6.5? <schut@rugth5.phys.rug.nltheend>
Re: C structure to perl <tchrist@mox.perl.com>
Re: Complicated sorting problem (Andrew M. Langmead)
Re: Complicated sorting problem <uri@sysarch.com>
Convert Text to Image <sugar@HWS.EDU>
Re: Convert Text to Image <Tony.Curtis+usenet@vcpc.univie.ac.at>
Encrypted Multithreading Server <rweaver@raex.com>
hashes with arrays as values? <thuerman@ibr.cs.tu-bs.de>
Re: hashes with arrays as values? (Bart Lateur)
Re: Hashref Compatibility with Perl 4.0 -- TIA (Tad McClellan)
Re: How do I change current working directory ? (Tad McClellan)
Re: How to extract emails from HTML page <newsposter@cthulhu.demon.nl>
Re: Joined and split arrays (Tad McClellan)
mails <peter.herger@swisslife.ch>
Re: Need some speed tips on this script.. <cbeatson@mail.ci.lubbock.tx.us>
Re: need Sun Solaris 2.6 sun4u gcc binaires (Jim Seymour)
New-style function call from inherited package <anton@belle.urc.ac.ru>
Perl - mySql and MSQL Help <kiml@worldnetla.net>
Perl, JavaScript, html problem jgreenw@my-dejanews.com
Re: Perl/Java cgi script with pws <RBullotta@csi.com>
Plot Graph with GD,chart (lhm)
Re: previous page, perl vs asp <aspinelli@ismes.it>
Re: Problem with script "... cgi-bin\signup.pl' script <freeking@nospam.hub.ofthe.net>
sort it ? <jimbo@cgocable.net>
Re: Sorting a Two-dimensional Numerical Array <ludlow@us.ibm.com>
Re: STDIN works too well (Mark-Jason Dominus)
Re: STDIN works too well (Tad McClellan)
Re: system() hangs server on win95? need to spawn proce dtbaker_dejanews@my-dejanews.com
Re: to grep or to loop, THAT is the question (Tad McClellan)
Why doesn't this work? (Henry Lifton)
Re: Why doesn't this work? <Tony.Curtis+usenet@vcpc.univie.ac.at>
Re: Why doesn't this work? <Jean-Yves.Burlett@scinfo.u-nancy.fr>
Re: Why Is Perl not a Language? (David Jacoby)
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 16 Dec 1998 16:26:51 +0100
From: "Erwann Chandon" <echandon@yahoo.com>
Subject: 500 server error
Message-Id: <758jma$nfd$1@front7.grolier.fr>
I've got a perl script. Why does the server send me a 500 error when I type
http://127.0.0.1/cgi-bin/script.cgi?jdfsfdsiodsifosfioj ?
Thanks,
Erwann
------------------------------
Date: 16 Dec 1998 15:51:44 GMT
From: meowing@banet.net (Fluffy)
Subject: Re: 500 server error
Message-Id: <slrn77flo5.c9n.meowing@meowhost.meow.invalid>
Erwann Chandon <echandon@yahoo.com> wrote:
> I've got a perl script. Why does the server send me a 500 error when I type
> http://127.0.0.1/cgi-bin/script.cgi?jdfsfdsiodsifosfioj ?
Because it's broken. Either your script is sending bad output (or no
output), or you installed it wrong, or the server isn't configured
correctly. There's no way to tell from the information you supplied.
You might want to ask about this in comp.infosystems.www.authoring.cgi
and/or one of the comp.infosystems.www.servers.* groups. The one
thing I *can* tell is that your problem is very general web stuff,
nothing specific to Perl.
------------------------------
Date: Wed, 16 Dec 1998 14:52:50 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: binmode
Message-Id: <3678c935.968437@news.skynet.be>
J.K. wrote:
>Would anyone please explain about binmode function and/or provide a
>piece of example codes.
You ONLY need this on PC's. It prevents the conversion of CR+LF to "\n",
and vice versa. It's a noop on Unix and Mac.
Use it to read from or write to binary files. It also prevents a
permature EOF when reading files, when it encounters a chr(26).
Usage is simple:
open(IN,"$file); binmode IN;
or
open(OUT,">$file); binmode OUT;
Only: use it before doing any reading of writing from/to the file.
p.s. If you want to write portable code, use it on Unix and Mac too,
when appropriate.
Bart.
------------------------------
Date: 16 Dec 1998 15:03:04 GMT
From: Koos Schut <schut@rugth5.phys.rug.nltheend>
Subject: build perl on IRIX-6.5?
Message-Id: <758i38$dmu$1@info.service.rug.nl>
Hi all,
I am trying to build perl on IRIX-6.5. I have:
perl-5.004 and perl-5.005
gcc-2.8.1
IRIX-6.5 on a mips-3 machine
What happens during the configure step is:
....
Creating sonfig.sh...
Hmm...You had some extra variables I don't know about...
I'll try to keep 'em...
Propagating previous variable $Date...
... some 150 lines like this
next variable substitution is done and shell scripts are extracted.
./mekedepend[29]: /dev/null: cannot execute
./makedepend[4?]: -rf somefile: not found
etc. etc.
It seems that the variable substitiution is not very successful and I
end up with "$rm -rf somefile" becoming " -rf somefile".
Next I can run makedepend by hand without problems.
Next I can run make by hand without problems.
Next make install exits with:
"./perl installperl
Patchlevel of perl (04)and patchlevel of config.sh () don't match
make: *** [install.perl] Error 2"
Questions:
Has anyone built perl on Irix-6.5, yet?
Does anyone have a clue of what goes wrong here?
Cheers.
--
On reply to my address, please remove "the end".
Mazzel, cheers, bye, tabe, moi, tot ziens, have a nice day,
Koos
__________________________to be Y999T-compliant___________________________
JJ Schut | e-mail: schut@phys.rug.nltheend |
Institute for Theoretical Physics | Phone: +31 15 2566804 |
University of Groningen | Phone: +31 70 3116092 |
P.O. Box 800 | Fax: +31 70 3112583 |
9700 AV Groningen, The Netherlands. | Yell: Very, Very loud |
----------------------- use: yyyyyyyyyyyyyyy/mm/dd------------------------
------------------------------
Date: 16 Dec 1998 10:51:48 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: C structure to perl
Message-Id: <7583c4$e6k$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, birgitt@hamburg.citde.net writes:
:Pardon a dumb question from a very new programming student, who started just
:out with C and wants to go to Perl soon. I can't yet read your code and can't
:yet understand enough about C. But does the above mean that I can convert
:each and every program I write in C to Perl with your program ?
No, just the .h files' structures.
--tom
--
Perl itself is usually pretty good about telling you what you shouldn't do. :-)
--Larry Wall in <11091@jpl-devvax.JPL.NASA.GOV>
Let's say the docs present a simplified view of reality... :-)
--Larry Wall in <6940@jpl-devvax.JPL.NASA.GOV>
------------------------------
Date: Wed, 16 Dec 1998 15:03:16 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Complicated sorting problem
Message-Id: <F42CHG.Dro@world.std.com>
moseley@best.com (Bill Moseley) writes:
>In article <x7n24opzl6.fsf@sysarch.com>, uri@sysarch.com says...
>>because this does the regex match for each comparison which will lead to
>>cpu death.
>Thanks for setting me right. I just ran a test benchmark on my P133 and
>my sort routine took over three times longer than the ST.
Whats even worse is that the results aren't linear to the size of the
input. Tom Christiansen posted a great article showing this a few
years back in Message-Id: <4l36f0$ghg@csnews.cs.colorado.edu> that you
can retrieve from dejanews
<URL:http://www.dejanews.com/getdoc.xp?AN=148002172.1> (I personally
think it is better than is "Far More Than Everything You Wanted To
Know About Sorting"
<URL:ftp://theory.uwinnipeg.ca/pub/CPAN/doc/FMTEYEWTK/sorting>)
--
Andrew Langmead
------------------------------
Date: 16 Dec 1998 11:52:56 -0500
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Complicated sorting problem
Message-Id: <x7af0oowpj.fsf@sysarch.com>
>>>>> "BL" == Bart Lateur <bart.lateur@skynet.be> writes:
BL> You've mentioned this OM several times in the last few days. I've never
BL> heard of this before. (sp: Orciam, Orcian, or Orcish)
BL> What is it? Is it (for example) the conversion of numbers to right
BL> justified strings?
it is defined in effective perl programming by joseph hall. its primary
feature is it converts the sort keys to a better form (ala ST) but
inside the sort sub, and saves the converted form in a hash indexed by
the original key. conversions are only done once, then the hashed data
is used. search dejanews for examples, i can't code one on the fly here
as it is not an idiom i am fluent it. i could give some time but i do't
have that right now.
BL> I must say that you do loose the original data this way. Or you have to
BL> put them in a hash, and reference through the hash,, just like Larry
BL> Rossler did in his post on dec 13
BL> (<MPG.10de1d51f12e3aab989957@nntp.hpl.hp.com>). That doesn't look
BL> "fast".
you need to take a class in basic sorting and searching algorithms. the
number of comparisons is generally the major factor in sorting. you try
to keep the work there as short as possible. so precomputing better keys
and postcomputing the original data is usually faster than doing the
work each time in the comparison. the terms used are O(nlogn) for the
comparisons and O(n) for the pre and post work. that means that you do n
* log(n) comparisons which grows faster than n. so the more data you
have the worse the sort if you do all the work in the compare. short
data sets don't count as they emphasize the conversion work over the
compare work. this is basic sort theory and there has been volumes
written on it.
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
Perl Hacker for Hire ---------------------- Perl, Internet, UNIX Consulting
uri@sysarch.com ------------------------------------ http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
------------------------------
Date: Wed, 16 Dec 1998 09:58:36 EDT
From: <sugar@HWS.EDU>
Subject: Convert Text to Image
Message-Id: <Pine.PMDF.3.95.981216095611.780011A-100000@HWS.EDU>
I would like help with a script that could convert text to an image and
take a string of text and change it to corresponding text and then create
an html file in the form of a table.
The file looks like this
Friday|Saturday|Sunday|Monday|Tuesday
MDLN|54|31|NNW|9|01|
The MDLN would be converted to a corresponding city name as text and the
01 would be converted to a corresponding text file.
David Sugar <sugar@hws.edu>
Phone: 315-787-6525
Mailing Address: David Sugar
Hobart and William Smith Colleges
3769 Scandling Center
Geneva, New York 14456
------------------------------
Date: 16 Dec 1998 16:06:34 +0100
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: Convert Text to Image
Message-Id: <83g1ag9ldx.fsf@vcpc.univie.ac.at>
Re: Convert Text to Image, David <sugar@HWS.EDU>
said:
David> I would like help with a script that could
David> convert text to an image and take a string of
David> text and change it to corresponding text and
David> then create an html file in the form of a
David> table.
A combination of the GD and CGI modules would be my
route.
hth
tony
--
Tony Curtis, Systems Manager, VCPC, | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien, | <URI:http://www.vcpc.univie.ac.at/>
"You see? You see? Your stupid minds! | private email:
Stupid! Stupid!" ~ Eros, Plan9 fOS.| <URI:mailto:tony_curtis32@hotmail.com>
------------------------------
Date: Wed, 16 Dec 1998 10:19:09 -0500
From: Ralph <rweaver@raex.com>
Subject: Encrypted Multithreading Server
Message-Id: <Pine.GSO.3.96.981216101551.27062B-100000@vectura.raex.com>
Hi,
I'm being drafted into doing an encrypted multi-threaded server and I
was looking for a few pointers on where to look for information. I've got
a few examples of MTS's but I haven't found alot of information on
encrypting the communications between them. Right now i'm kinda looking
for ideas more than anything and i'm not really concerned with actual code
yet. So basically if you know of a good encryption mod or decent source
somewhere drop me a line please. Also what are some things to watch out
for when doing a project like this? (this is my first encrypted server.)
Ralph
------------------------------
Date: 16 Dec 1998 16:44:13 +0100
From: Urs Thuermann <thuerman@ibr.cs.tu-bs.de>
Subject: hashes with arrays as values?
Message-Id: <ysdbtl4ay7m.fsf@tuborg.ibr.cs.tu-bs.de>
I'd like to have hashes whose values are arrays. Before reading the
documentation I just tried it out and was indeed surprised to find
that it seems to work to some extent:
#!/usr/bin/perl
$start = 10;
for $key (apple, peach, orange) {
for $i (1..5) {
$hash{$key}[$i] = $start + $i
}
$start += 10;
}
@hash{mango} = (9,8,7,6,5,4,3,2,1,0);
#printf "%d\n\n", $#hash{apple};
for $key (apple, peach, orange, mango) {
for $i (1..5) {
printf " %d", $hash{$key}[$i];
}
}
print "\n";
This does print the line
11 12 13 14 15 21 22 23 24 25 31 32 33 34 35 0 0 0 0 0
So it seems I have three arrays, @hash{apple}, @hash{peach}, and
@hash{orange}. But the assignment to @hash{mango} doesn't work.
Also, the construction $#hash{apple} produces a compile time error.
Is it somehow possible to use array-valued hashes? If not, what
exactly does the above short program do?
I did not find an answer to this in the man pages and perlfaq.
urs
------------------------------
Date: Wed, 16 Dec 1998 16:48:35 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: hashes with arrays as values?
Message-Id: <3678dd98.198444@news.skynet.be>
Urs Thuermann wrote:
> @hash{mango} = (9,8,7,6,5,4,3,2,1,0);
>So it seems I have three arrays, @hash{apple}, @hash{peach}, and
>@hash{orange}. But the assignment to @hash{mango} doesn't work.
No, not quite. The values for the hash are not actually arrays, but
references to (anonymous) arrays.
You can set $hash{mango} by either:
$hash{mango} = [ 9,8,7,6,5,4,3,2,1,0 ];
or
@{$hash{mango}} = (9,8,7,6,5,4,3,2,1,0);
For some reason, you may NOT drop the outer braces in this case. I don't
feel like searching on the why, as I personally would find it less
readable. Yes, I actually LIKE the @{...} or %{...} syntax. :-)
Try printing $hash{mango}; you'll see something like ARRAY(0xccb00),
indicating that it is indeed a ref to an array. The @{...} construct
allows you to access the array itself. ("dereference")
>Also, the construction $#hash{apple} produces a compile time error.
This was asked and answered earlier this week. Try using
$#{$hash{mango}} instead.
HTH,
Bart.
------------------------------
Date: Wed, 16 Dec 1998 08:29:54 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Hashref Compatibility with Perl 4.0 -- TIA
Message-Id: <25g857.hrg.ln@magna.metronet.com>
Emmett McLean (emclean@slip.net) wrote:
: Some people just like to grump.
Pot. Kettle. Black.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 16 Dec 1998 09:03:36 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: How do I change current working directory ?
Message-Id: <84i857.gch.ln@magna.metronet.com>
Peter Forsbom (KONPEF@statoil.com) wrote:
: I want to change the current working directory so when my perl program
: is done my pwd is diffrent from when I started the program.
See the Perl FAQ, part 8:
"I {changed directory, modified my environment} in a perl script.
How come the change disappeared when I exited the script?
How do I get my changes to be visible?"
It kinda matters what Operating System you are using.
You should have shared that with us...
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 16 Dec 1998 10:57:25 -0500
From: Erik van Roode <newsposter@cthulhu.demon.nl>
Subject: Re: How to extract emails from HTML page
Message-Id: <3677D864.BE14C45F@cthulhu.demon.nl>
dturley@pobox.com wrote:
>
> In article <3676C929.5EB677F9@popcorn-studio.ch>,
> Philip Class <philip.class@popcorn-studio.ch> wrote:
> > Dear Friends ;-)
> >
> > To be honest - The main purpose for collecting emails is a commercial one.
> > Contancting potential customers in a discrete way (inculding our own personal
> > address data as sender and offering a 'REMOVE ME' feature) is not what I call
> > usual cheap spam.
>
> But extracting email addresses from web pages is such a trivial perl script.
> Could we actually trust your programming on the "REMOVE ME" program part of
> it?
Spammers usually use a throw-away account at yahoo/hotmail/... for the 'remove'
messages. In most other cases they use an invalid return address. Even if the
remove message actually arrives, then they'll take it as a confirmation that
you're interested. In other words: in most cases it's a good idea not to reply
to 'remove' addresses. Just drop a note in the spammer's ISP abuse/postmaster
mailboxes. Note that a lot of spam has forged headers.
Erik
------------------------------
Date: Wed, 16 Dec 1998 07:46:52 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Joined and split arrays
Message-Id: <ckd857.hrg.ln@magna.metronet.com>
David Combs (dkcombs@netcom.com) wrote:
: In article <kiqo47.802.ln@magna.metronet.com>,
: Tad McClellan <tadmc@metronet.com> wrote:
: >Brad McBride (Brad.McBride@Axom.com) wrote:
: >: @opentickets = split(/:/, @openticketlist);
: >
: >: When I print out the contents of @openticketlist, I see all of my
: >: information, nicely seperated by :s. When I print out my split array,
: >: instead of seeing the same information formated differently, I get the
: >: number 6. That's it, just the number 6. Is there something I am screwing
: >: up with the split function or am I going about this all the wrong way?
: >
: >
: > You are going about this the wrong way.
: >
: > split() wants a _string_ as the second argument. You have
: > given in a list.
: Do not these things *check* their args? Or am I missing
: something basic -- the answer to which we could all benefit
: from?
I think that it may be that you are missing one or both of
two important Perl concepts: automatic conversion between
numbers and strings, and scalar vs. list context.
split() wants a string to split, but using an array in a scalar
context (as above) returns a _number_ rather than a string.
When perl is given a number where it is expecting a string, it
automatically converts the number to a string (See "Scalar values"
section in 'perldata').
So split() above sees: @opentickets = split(/:/, '6');
It finds no split patterns, and returns a list consisting
of a single element.
Scalar vs. list context is explained in the "Context" section
in the 'perldata' man page.
The short version is that Perl's functions/constructs may
return different things depending on which of the contexts
it is used in.
e.g.
$line = <STDIN>; # scalar context: read *one* line
@lines = <STDIN>; # list context: read *all* of the remaining lines
The RHS is identical in these two usages, but their effects
are different due to their context.
So you need to be able to recognize the context in order to
know what to expect.
In the case of functions (see perlfunc) if the function
signature uses LIST or ARRAY, then it will provide a list
context for whatever appears there. Most (all?) of the other
meta-args provide a scalar context (e.g. the EXPR for split).
Both of these aspects of Perl's behavior are crucial to using
Perl effectively.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 16 Dec 1998 16:03:16 +0100
From: Herger Peter <peter.herger@swisslife.ch>
Subject: mails
Message-Id: <3677CBB4.CB24093A@swisslife.ch>
Hi everybody
I've wrote a little script like that:
use Mail::Send;
$mail=Mail::Send->new(
Subject => "blablabla",
To => 'user@remote.host.com',
To => 'user2@remote.host.com');
.....
How can I add more recipients with "To=>"?
If I do it like the example above, it is only delivered to the first
recipient.
Thanks a lot
Peter Herger (peter.herger@swisslife.ch)
------------------------------
Date: Wed, 16 Dec 1998 10:01:16 -0600
From: "Chris Beatson" <cbeatson@mail.ci.lubbock.tx.us>
Subject: Re: Need some speed tips on this script..
Message-Id: <758lpi$gci$1@spider.ci.lubbock.tx.us>
Thanks for the help everyone. This is what I came up with after all the
sugestions, it runs much faster. I learned some good lessons too.
use strict;
sub Main;
sub GrabIps;
my %ips;
my $filename;
Main;
sub Main {
unless (@ARGV) {
print "useage -- ips2.pl <filename> ";
exit;
}
$filename="@ARGV";
&GrabIps;
exit;
}
sub GrabIps {
open (FILE, "<$filename") || die "cant open file $!\n";
while (<FILE>) {
if (/(^\d+\.\d+\.\d+\.\d+),/) {
$ips{$1}++;
}
}
close (FILE);
open (RESULTS, ">ips") || die "could not open 'ips' $!\n";
foreach (sort keys %ips) {
print RESULTS "$_\n";
}
close (RESULTS);
}
Chris
------------------------------
Date: 16 Dec 1998 15:17:33 GMT
From: jseymour@jimsun.LinxNet.com (Jim Seymour)
Subject: Re: need Sun Solaris 2.6 sun4u gcc binaires
Message-Id: <758iud$pnm$2@jimsun.uucp>
In article <hYGd2.131$595.238@nsw.nnrp.telstra.net>,
mgjv@comdyn.com.au (Martien Verbruggen) writes:
> In article <36772FE5.67BAF8BF@crl.com>,
> euclid <euclid@crl.com> writes:
>> I desparately need Sun Solaris 2.6 sun4u gcc binaires ...
[snip]
>
> How long did you wait for an answer from one of them? Those are
> definitely much more appropriate groups. A group for solaris would
> probably have been even more appropriate.
As in: "comp.unix.solaris", perhaps?
>
> Oh, what the hell. I'm feeling generous today.
Ah what the heck--it's the season, right?
He might also try:
http://metalab.unc.edu/pub/packages/solaris/sparc/
Where he can find all kinds of pre-compiled packages in
"pkgadd" form for 2.3 through 2.6 (at present). There's
also a section for x86 Solaris, not surprisingly:
http://metalab.unc.edu/pub/packages/solaris/i86pc/
Quite handy.
Regards,
Jim
--
Jim Seymour
jseymour@jimsun.LinxNet.com
http://home.msen.com/~jimsun
------------------------------
Date: 15 Dec 1998 05:53:46 GMT
From: Anton Voronin <anton@belle.urc.ac.ru>
Subject: New-style function call from inherited package
Message-Id: <754tha$nj8$1@netserv1.urc.ac.ru>
Hello,
I am trying to create something like header file to be able to have the
constants (which are the functions in real) and use that header file in
more than one module. I don't want to have .ph file and then require it
into my modules because in such case I'll need to use '&' when call those constants-
-functions (and this means they won't be inlined because only new-style calls
may be inlined).
So I need my "header-file" to be a .pm module itself so that I could import
its names into my module's namespace. It looks like the following:
# file Module_h.pm
package Module;
use constant CONST1 => 'value1';
use constant CONST2 => 'value2';
...
And here are two modules that need to use the constants (one module is
basic and the other is inheritant):
# file Module.pm
package Module;
use strict;
use Module_h;
...
$var = CONST1 - CONST2; # all is ok
...
# file Module/Deriv.pm
package Module::Deriv;
use strict;
use Module;
use vars qw( @ISA );
@ISA = ( 'Module' );
...
$var = CONST1 - CONST2; # oops! CONST1 and CONST2 are the barewords.
# but if I use &CONST1 - &CONST2
# or CONST1() - CONST2(), it works again(!)
...
This works ok only if I make two separated blocks in Module_h.pm:
# file Module_h.pm
{
package Module;
use constant CONST1 => 'value1';
use constant CONST2 => 'value2';
...
}
{
package Module::Deriv;
use constant CONST1 => 'value1';
use constant CONST2 => 'value2';
...
}
but doesn't look nice ;)
Why the names from Module_h (declared as belonging to namespace of package
Module) are not imported into package Module::Deriv ? What am I doing wrong?
Or is it a perl's bug?
Thanks in advance,
Anton
--
Anton Voronin | Ural Regional Center of FREEnet,
anton@urc.ac.ru | Southern Ural University, Chelyabinsk, Russia
http://www.urc.ac.ru/~anton | Programmer & System Administrator
------------------------------
Date: Wed, 16 Dec 1998 10:52:25 -0600
From: "Kim Long" <kiml@worldnetla.net>
Subject: Perl - mySql and MSQL Help
Message-Id: <3677e4ae.0@209.4.101.246>
I need to create a script that will
a) be spawned from an entry to a MSQL database and create an entry into
a mySQL database on a different server
-or-
b) query the MSQL databases for changes and reflect those changes in the
mySQL db on diff. server.
Any ideas where to begin. I'm more than willing to do the research but just
need a jumping off point. I'm at the beginner to intermediate stage.
Thanks in advance,
Kim
kiml@worldnetla.net
------------------------------
Date: Wed, 16 Dec 1998 16:11:56 GMT
From: jgreenw@my-dejanews.com
Subject: Perl, JavaScript, html problem
Message-Id: <758m4a$kqi$1@nnrp1.dejanews.com>
Below is a short little script that does everything I want except for one
or two things:
First, I want the category names to change as you select different projects.
Right now the text area gets changed, depending on which project is selected,
but never the categories.
Second, I want to be able pass an array to the javascript portion, rather than
have the current hard-coded array. (The array will actually be the categories
in a Gnats database, as its now possible to access multiple databases, these
arrays will be dynamic)
Sorry about the cross-post, but I wasn't exactly sure where the topic fit.
#!/usr/bin/perl -w
use CGI qw(:standard);
print header,start_html(-bgcolor=>'white');
javascript();
htmlscript ();
print end_html;
#*****************************************
sub htmlscript {
$q = new CGI;
@proj = qw(0 1 2);
print $q->start_form(-name=>'ug'),
$q->popup_menu(-name=>'popup',
-values=>\@proj,
-labels=>{'0'=>'Select a project',
'1'=>'A','2'=>'B'},
-onChange=>"showIt(this)"),"\n",
$q->textarea(-name=>'ta',-rows=>'12', -cols=>'20'),"\n",
$q->popup_menu(-name=>'cat',
-values=>'Category'),
end_form;
}
#*****************************************
sub javascript {
print <<EOF
<SCRIPT LANGUAGE="JavaScript">
<!--
function showIt(menu){
var index = menu.options[menu.selectedIndex].value;
if (index == 1) {
db=new Array("alpha","beta","gamma","delta");
}else if(index == 2) {
db=new Array('epsilon','zeta','theta');
}else{
db=new Array('Select an item');
}
document.ug.ta.value=db; // Show it on the text box
document.ug.cat.value=db; //I want to change categories
}
//-->
</SCRIPT>
EOF
}
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Wed, 16 Dec 1998 09:59:06 -0000
From: "RBullotta" <RBullotta@csi.com>
Subject: Re: Perl/Java cgi script with pws
Message-Id: <ut9gkTQK#GA.222@uppssnewspub05.moswest.msn.net>
Paul:
There are 3rd party application (I believe one is called JRun or something
similar) that allow you to run Java Servlets on web servers that do not
natively support the Servlet interface...would make your Java CGI stuff
cleaner, easier, and eliminate the annoying DOS window...
Check it out!
- Rick Bullotta
Lighthammer Software Development Corp
Paul Chapin wrote in message <3676721c.0@amhnt2.amherst.edu>...
>What I'm trying to do is write a cgi script in java to run on a Personal
Web
>Server running on a Win95 system. The server is not, during development,
>connecting to anything so everything is local using 127.0.0.1
>
>The fundamental problem with Java as cgi script is that it doesn't
>understand environmental variables. The solution to this appears to be to
>use a perl script that then invokes the java script, records the results,
>and then prints out the resulting html page. It all looks something like
>this,
>
>@results=`...path...\\java testjava`;
>
>foreach (@results) {
> print $_;
>}
>
>At this point I'm not worrying about environmental variables.
>testjava.class just spits out a basic html page including the Content-type:
>header.
>
>Now if I run the perl script from a DOS prompt, I get the results I want
>displayed to the window. However, if I try to invoke the script from a
>form, I get a DOS window - titled JAVA - to display briefly, then nothing
>happens until the client times out. I can verify that the perl script is
>being started, and getting to the Java program, but no further.
Ctl-Alt-Del
>indicates that a perl process is running, but no sign of Java. It looks
>like Perl is not recognizing that the Java program is done.
>
>Just to make things interesting, I took the java class, the perl script,
and
>the html page with the form and moved it to my Apache server on a UNIX box.
>After hacking a few paths and the like so that they're UNIX and not DOS, I
>find that I can invoke the perl script from the form and have it return the
>Java output without problem.
>
>My problem is that I'm not sure where the problem is, which is why this is
>cross-posted all over the place. Is perl messing up and not recognizing
the
>end of the Java program? Is there a problem with Java causing it to not
>exit properly? Is there a problem with pws so that it just can't deal with
>this program within a script approach?
>
>If anybody's interested in seeing what's suppose to work they can go to
>www.amherst.edu/~pdchapin/calendar/shortform.html and hit the "Input and
>time button". The page that will be returned will only contain "/n" but
>that's because testjava doesn't do anything. However, a valid page is
being
>returned which is more than happens with pws.
>
>(This is my second try to post this. My apologies if it ends up appearing
>twice.)
>
>-----
>Paul Chapin
>UNIX Manager
>Amherst College
>413 542-2144
>http://www.amherst.edu/~pdchapin
>
>
>
------------------------------
Date: 16 Dec 1998 15:34:49 GMT
From: lhm@hkuspace.org (lhm)
Subject: Plot Graph with GD,chart
Message-Id: <758jup$al4@news.hk.linkage.net>
I can use chart module to write a cgi for ploting bar chart in
perl5.004 under Solaris environment with Apache web server. I
am looking for the possibility to write a similar cgi under
win NT environment with IIS.
I have installed the Win32 port of GD.pm for ActivePerl 507 in
NT WS. But everytime I try to perl xxx.pl that use GD , it will
dies with error "...No loadable module .." .
Does any one has similar problem ? Thanks for any information on
it.
Rgds,
Phyllis
------------------------------
Date: Wed, 16 Dec 1998 15:59:24 +0100
From: Andrea Spinelli <aspinelli@ismes.it>
Subject: Re: previous page, perl vs asp
Message-Id: <3677CACC.B91681C5@ismes.it>
Eric Bohlman wrote:
>
> Dan Albertsson <dan.albertsson@swipnet.se> wrote:
> : I have seen on different shopping websites, written in ASP, that if you
> : update a page (for instance your shopping cart) and then press your
> : browsers Back button, the browser does not show how the page look like
> : before you updated it.
>
> : Is that possible to do with cgi-scripts written in Perl.
I've seen it in my own application, when I use Netscape,
and happens not to fit well my intended purposes :(
The fact is that Netscape 4.0 (and also IE 4.0) has a bug! It does not
interpret correctly the concept of 'previous'!
If a page A has been produced by a script S, and page B
by the same script S (but with different parameters),
the browser will think they are the same (when using the Back
button. Invoking S through a SUBMIT button works)!
If you develop your application relying on this bug,
it will break when the bug will be fixed (not a good idea!).
I completely agree with Eric Bohlman when he says that
> You need to go back to the definition of your
> problem rather than the definition of one possible solution.
What you are apparently going to go is exposed to easy attacks.
Suppose that your user sees the pages P1 and then P2; from P1
you call the script S1 and obtain P2. The good use is calling
S2 from P2 to go on. Calling S1 again will break your application.
Now, a malicious user can (and will!) go to page P1,
save it with a 'Save As...', activate S1. Then s/he will load
P1 from the file, and call S1 again. Bingo!
If you mount some complicated mechanism to make it difficult
to re-load the page, s/he can always build a CGI request from
Perl (see HTTP::Request in your Perl doc) and mess up your app.
Moreover, (this one actually happened to me, the other one is
theoretical), suppose that your script S takes a lot to complete
(maybe 10 sec). Since users are always impatient, the user
will click again on the SUBMIT button, and S1 will be called
twice, with disastrous consequences.
I realize now this discussion would be more appropriate
on a Web newsgroup. I beg the pardon of Perl folks!
However, I think this is a common theme for many Perl
users todat, so maybe I'll escape the flames...
Andrea
------------------------------
Date: Mon, 14 Dec 1998 09:37:44 -0600
From: "Richard H. King" <freeking@nospam.hub.ofthe.net>
Subject: Re: Problem with script "... cgi-bin\signup.pl' script produced no output "
Message-Id: <758jd9$bst$1@remarQ.com>
|Problem with script "... cgi-bin\signup.pl' script produced no output "
I may have missed something, but it seems like you didn't quite get the help
you were looking for.
I understand M$ stuff isn't always as great as it could be, but try
convincing 98% of corporate America about. Sometimes we just don't have the
choice.
AnnyhooOOo, try Re-installing perl. ( http://www.ActiveState.com )
Then try running some "Hello World"-like scripts... IE type this from the
DOS Prompt, while behind the Server:
perl -e "print q[Hey.]"
And then, if that works, put this in a file and run it by typing "perl
<file>.pl" at the command line:
#!/usr/bin/perl -w
print "Content-type: text/html\n\n Hey.";
__END__
Now, if both of those work, then you're having a CGI&NT problem and not a
perl&NT one...
In that case make sure that when you go into Management Console the
directory you want to put your script in is "chmod +x"'d. In other words:
find the directory (by default a "Virtual Directory" named "SCRIPTS".
Right-click, Properties, and then in one of the tabs in the menu that pops
up, look for the section where you see something like this:
[ ] Read Permissions Only
[ ] Script Access
[ ] Execute (Including Script)
"Script", counter-intuitively means Micro$oft's ASP's, not standard CGI's.
So make sure Execute is checked.
THEN, stick your script (that you made earlier) in the directory you just
right-clicked in.
>From a browser (local or no), type in
http://<server>/<scriptsdir>/<script>.pl
I almost guarantee that if the top steps worked, this last one will too.
HTH
-Ryan King
------------------------------
Date: Wed, 16 Dec 1998 11:44:29 -0500
From: "Jim Fitzsimmons" <jimbo@cgocable.net>
Subject: sort it ?
Message-Id: <3677e377.0@news.cgocable.net>
hello,
I need to sort a tab separated text file, based on a price, for example: the
price1 column
I'm hoping some kind soul will bail me out here, I've read the faq's, stayed
up nights drinking lots of coffee, and to no avail. the book I have (perl5
for dummies) doesn't seem to help either.
text file looks like this, in the format of vendor, price 1, price2, price
3, price4....etc. :
vendor1 99.00 98.00 299.00 300.00
vendor2 89.00 94.00 299.00 300.00
vendor3 99.00 14.00 299.00 300.00
vendor4 19.00 39.00 299.00 1514.00
vendor5 99.99 199.00 299.00 300.00
vendor6 99.00 26.00 186.00 400.00
vendor7 99.00 199.00 299.00 300.00
vendor8 49.98 279.99 299.00 189.99
vendor9 99.00 199.00 299.00 300.00
here's my script: (without any attempt at sorting)
#!/usr/local/bin/perl5
require "cgi-lib.pl";
print &PrintHeader;
open(SIMM1,"ramdata.txt");
@simm1 = <SIMM1>;
close(SIMM1);
foreach $i (@simm1) {
chop($i);
($vendor,$price1,$price2,$price3,$price4,$type,$highlights,$url)
= split(/\t/,$i);
print "<table border=0 CELLSPACING=0 width=450>\n";
if ($highlights eq "on")
{
print "<TR BGCOLOR=#FFFF00>\n";
print "<td><B>$vendor</B></td>\n";
print "<td align=right><B>$price1</B></td>\n";
print "<td align=right><B>$price2</B></td>\n";
print "<td align=right><B>$price3</B></td>\n";
print "<td align=right><B>$price4</B></td>\n";
print "</tr>\n";
print "</table>\n";
}
else
{
print "<tr>\n";
print "<td>$vendor</td>\n";
print "<td align=right>$price1</td>\n";
print "<td align=right>$price2</td>\n";
print "<td align=right>$price3</td>\n";
print "<td align=right>$price4</td>\n";
print "</tr>\n";
print "</table>\n";
}}
Thank you for your time.
Jim Fitzsimmons
jimbo@cgocable.net
------------------------------
Date: Wed, 16 Dec 1998 10:22:39 -0600
From: James Ludlow <ludlow@us.ibm.com>
Subject: Re: Sorting a Two-dimensional Numerical Array
Message-Id: <3677DE4F.96FE25D7@us.ibm.com>
Tom Briles wrote:
> I did read this FAQ entry (I also looked in Learning Perl and Programming Perl, as well as
> three other Perl books).
>
> Perhaps I'm being daft, but I still don't see how to sort a multi-dimensional array. The
> FAQ talks about single-dimensional arrays. Maybe I just need an explanation of the
> explanation...
>
> - Tom
I need to apologize for that one. I remembered it being in the faq, and
it is in a sense, but it's not really obvious. When the faq talks about
the Schwartzian Transform it uses a line like sort{$a->[1] cmp
$b->[1]}. This would be the info you were looking for, but it's not
likely to jump right off the page.
Andrew Langmead provided a nice solution to your particular problem,
which you can catch on Dejanews if you missed it.
--
James Ludlow (ludlow@us.ibm.com)
(Any opinions expressed are my own, not necessarily those of IBM)
------------------------------
Date: 16 Dec 1998 10:16:18 -0500
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: STDIN works too well
Message-Id: <758is2$3hn$1@monet.op.net>
In article <913819358.597458@elaine.drink.com>,
Alan Barclay <gorilla@elaine.drink.com> wrote:
>print "input is tty\n" if($stdin & 020000);
Hey, that's no good. It says that /dev/null is a tty, which it isn't.
------------------------------
Date: Wed, 16 Dec 1998 08:58:26 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: STDIN works too well
Message-Id: <jqh857.gch.ln@magna.metronet.com>
Tim Cutts (timc@chiark.greenend.org.uk) wrote:
: As far as I know, there is no way for a program to tell whether its
: STDIN is a pipe or not (UNIX gurus feel free to correct me).
You can use the isatty() function in C.
In Perl, you use the -t filetest (see perlfunc):
-t Filehandle is opened to a tty.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 16 Dec 1998 16:30:59 GMT
From: dtbaker_dejanews@my-dejanews.com
Subject: Re: system() hangs server on win95? need to spawn process?
Message-Id: <758n84$lrj$1@nnrp1.dejanews.com>
In article <366A95F3.DB7372BE@busprod.com>,
Dan Baker <dtbaker-@busprod.com> wrote:
> I'm working on a little script that will be called from a HTML page with
> either GET or POST, passed a filename, and will open up the file in
> notepad.exe in win32 (windows95).
>
> The problem I'm having is that the script opens up the file in notepad,
> but then times-out on my local server. I'm guessing that the system()
> call doesn't spawn a new process, so the perl script waits for the
> notepad to close, which times out the server if it is open for more than
> 2 seconds.
>
> what is the solution?
-----------------
thought I'd followup with the solution I got from Shaun Wandler, works like a
charm:
You just need to put "start" in front of the command line that
you give to system.
ie. system(start notepad.exe somefile.txt);
Dan
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Wed, 16 Dec 1998 10:23:08 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: to grep or to loop, THAT is the question
Message-Id: <cpm857.3sh.ln@magna.metronet.com>
Software Sciences (nospam.eam@starfire.mlb.semi.harris.com) wrote:
: Does perl have commands that operate on a FILE instead of a line level,
: aside from say File::copy? For example, I use
: system("grep pat ./myfile > ./newfile");
perl -ne 'print if /pat/' ./myfile > ./newfile
see the 'perlrun' man page for descriptions of perl's
command line switches (which can often be included in
the shebang line too).
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 16 Dec 1998 15:06:02 GMT
From: henlif@elsfl.com (Henry Lifton)
Subject: Why doesn't this work?
Message-Id: <758i96$a91$1@remarQ.com>
I am a newbie who has been going crazy with this. Can any one tell me what is
wrong?
open(land,'/data/land.txt') || die "can't open file land";
$key=$ENV{'PATH_INFO'};
$key =~ s|/||;
$info=$land{$key};
($id,$address,$city,$type,$imp,$desc,$terms,$comments)=split('\t',$info);
$key is a number that corresponds to the first field $id and comes from
the sending page.
In trying to debug it, I print the $key and $info variables. $key comes up
properly but $info is blank.
I need to be able to split this into the proper fields.
I would be grateful for any help
Thanks
Henry Lifton
------------------------------
Date: 16 Dec 1998 16:37:01 +0100
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: Why doesn't this work?
Message-Id: <83d85k9jz6.fsf@vcpc.univie.ac.at>
Re: Why doesn't this work?, Henry <henlif@elsfl.com>
said:
Henry> I am a newbie who has been going crazy with
Henry> this. Can any one tell me what is wrong?
Henry> open(land,'/data/land.txt') || die "can't
Henry> open file land";
Henry> $key=$ENV{'PATH_INFO'};
Aha, CGI! (You don't need the quotes around the ENV
key by the way) and you might want to think about
the access methods included in CGI.pm for this.
/data is part of your web-space (local url-path)
isn't it?
open() works on real file-system pathnames, so you
need to work out where the web-space is located.
hth
tony
--
Tony Curtis, Systems Manager, VCPC, | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien, | <URI:http://www.vcpc.univie.ac.at/>
"You see? You see? Your stupid minds! | private email:
Stupid! Stupid!" ~ Eros, Plan9 fOS.| <URI:mailto:tony_curtis32@hotmail.com>
------------------------------
Date: 16 Dec 1998 16:36:52 +0100
From: JYB <Jean-Yves.Burlett@scinfo.u-nancy.fr>
Subject: Re: Why doesn't this work?
Message-Id: <i8nemq0nlnv.fsf@pollux.scinfo.u-nancy.fr>
henlif@elsfl.com (Henry Lifton) writes:
> I am a newbie who has been going crazy with this. Can any one tell me what is
> wrong?
I'm kinda newbie too, but i'll give it a try.
> open(land,'/data/land.txt') || die "can't open file land";
>
> $key=$ENV{'PATH_INFO'};
> $key =~ s|/||;
^^^^^^^^^^^^^
What did you meant to do with that?
(I know, removing the slashes but i can't see why)
> $info=$land{$key};
^^^^^^^^^
You're calling a hash, but we can't see the declaration of it.
%land have nothing to do with the file handle land. (correct me)
> ($id,$address,$city,$type,$imp,$desc,$terms,$comments)=split('\t',$info);
Seems correct. (maybe "\t" instead of '\t')
> $key is a number that corresponds to the first field $id and comes from
> the sending page.
>
> In trying to debug it, I print the $key and $info variables. $key comes up
> properly but $info is blank.
It's because %land is an empty hash, fill it!
> I need to be able to split this into the proper fields.
You could do that:
while (<land>) {
chomp;
($id,$address,$city,$type,$imp,$whatever....)=split('\t');
put the stuff in a hash of list # you've got your %land
};
You can also do this (in the while)
/(\S+)\s+(.*)/; # i know this is not very clean but...
$land{$1}=$2;
and you'll have a %land that fit to your $info=$land{$key}!
(Sorry for poor english)
--
login:burlett
Contact: Jean-Yves.Burlett@scinfo.u-nancy.fr / jburlett@lemel.fr
------------------------------
Date: 16 Dec 1998 15:52:16 GMT
From: jacoby@pier.ecn.purdue.edu (David Jacoby)
Subject: Re: Why Is Perl not a Language?
Message-Id: <758kvg$23v@mozo.cc.purdue.edu>
In article <oeeemq0qhth.fsf@alpha.hut.fi>,
Jarkko Hietaniemi <jhi@alpha.hut.fi> wrote:
>nhoop@centuryinter.net (Nat) writes:
>> >ps. Why is the perl mascot a camel? (Versatility?)
>>
>> Larry Wall notes that a Camel is sometimes called "a horse designed by a
>> committee."
>>
>> Perl was designed by many.
>
>Well, I'd say no. Perl was designed by Larry Wall but his sources of
>inspiration were many. There are features from C, UNIX shells,
>FORTRAN, BASIC-PLUS, Ada, Sanskrit (just testing whether you are still
>awake), LISP, ...
He is a linguist. I wouldn't put adding Sanskrit to Perl beyond him....
But my understanding is that "The camel has evolved to be a 'workhorse'
in a hostile environment. It has not, however, evolved to smell good.
Same with Perl."
--
Dave Jacoby - jacoby@ecn.purdue.edu - http://pier.ecn.purdue.edu/~jacoby/
Lamport's Law:
A distributed system is one in which the failure of a computer
you didn't even know existed can render your own computer unusable.
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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.misc (and this Digest), send your
article to perl-users@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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 V8 Issue 4439
**************************************