[7197] in Perl-Users-Digest
Perl-Users Digest, Issue: 822 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Aug 7 09:13:24 1997
Date: Thu, 7 Aug 97 06:00:47 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 7 Aug 1997 Volume: 8 Number: 822
Today's topics:
Re: ? on Server Redirection with Perl <sibsib@hotmail.com>
Re: bug passing alists as sub arguments (Tad McClellan)
Re: Case Statement.. (Tina Marie Holmboe)
Re: chop vs chomp <rovf@earthling.net>
comparing for a range of number - easiest way to do it? <rovf@earthling.net>
Re: EASY PROBABLY: removing names from paths (Jeff Stampes)
Re: EASY PROBABLY: removing names from paths (Tad McClellan)
Re: file extensions (Topher Eliot)
File IO interrupt <byersa@agva.com>
Re: File IO interrupt <rootbeer@teleport.com>
Re: File locking (Casper H.S. Dik - Network Security Engineer)
Re: Have array, will (won't?) sort <parkhurs@indiana.edu>
How to execute remote Perl script from Perl? <destornell@ProbityITC.com>
Re: How to make Perl Regular expressions "Rightmost is <seay@absyss.fr>
Re: Idiotic Perl Problem, can anyone help.... (Adam Rogoyski)
info from dead child-process in SIGN{'CHLD'} <kristoff.bonne@mpl108.is.belgacom.be>
Java and Perl together (Ken Williams)
Re: Java and Perl together <rootbeer@teleport.com>
Re: parsing techniques (advice needed) <reljr@sigg.com>
Perl access on NT using Netscape results in ERROR_BAD_E (Ken Kranz)
Re: Printing to absolute screen position (Toru Shiono)
Re: Seeking object enlightenment (David Bonner)
Style and efficiency ( Thomas Lachlan XMS x4206 )
Re: Too Many Files for Foreach Loop? <tom@mitra.phys.uit.no>
Re: Unclear documentation for map() <tom@mitra.phys.uit.no>
What means --> Can't call method "xxxxxxx" on unblessed <itcg@com.latnet.lv>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 06 Aug 1997 13:16:05 -0400
From: Scott Blanksteen <sibsib@hotmail.com>
Subject: Re: ? on Server Redirection with Perl
Message-Id: <33E8B154.8DE0A5C2@hotmail.com>
John Barnett wrote:
>
> I have a question I hope some could answer. I would like to know if it
> is possible to redirect some to a WWW server based on IP or DNS name. I
> have two Web servers one on the East coast and the other on the West.
> Each coast is using a different IP subnet.
>
John -
Yes, it can be done with Perl. I assume, based on your later comments,
that you can easily identify East- and West-coast browsers.
Let's say your two servers are www.east.foo.com and www.west.foo.com.
Alias one of them to www.foo.com. Now, when someone asks for
<http://www.foo.com/>, run a CGI script (written in Perl or anything
else) which returns a 'redirect' to the browser. If the browser is from
the East coast, redirect to <http://www.east.foo.com/> and similarly for
West coast browsers. Assuming all the links in your html doc's are
relative :-) everything should work hunky-dorily from now on.
Scott
--
Scott I. Blanksteen
sib (at) worldnet (dot) att (dot) net
------------------------------
Date: Tue, 5 Aug 1997 19:17:12 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: bug passing alists as sub arguments
Message-Id: <8qf8s5.ag5.ln@localhost>
William Biesty (biestw01@popmail.med.nyu.edu) wrote:
: I'm getting the following error message
: Odd number of elements in hash list at iceflow.pl line nnn
: in Perl 5.004 on a DEC Alpha UNIX (Digital UNIX V4.0B (Rev. 564);) when
: I
: pass an associative array as the middle argument to a subroutine.
: sub bob {
: local ($x, %y, $z) = @_;
: # some code here
: bob $x-1, %y, $z;
: }
:
: %aa=(...);
: bob 3, %aa, 0;
So, of course, when your SUBroutine did not work, you, being a savvy
programmer, immediately turned to the documentation for SUBroutines
that is included with the perl distribution (perlSUB), right?
I guess somehow or another you missed this part (in the second
paragraph under the "DESCRIPTION" heading. I'm beginning to think
you didn't check the docs at all...):
------------------------
The Perl model for function call and return values is simple: all
functions are passed as parameters one single flat list of scalars, and
all functions likewise return to their caller one single flat list of
scalars. Any arrays or hashes in these call and return lists will
collapse, losing their identities--but you may always use
pass-by-reference instead to avoid this. Both call and return lists may
contain as many or as few scalar elements as you'd like. (Often a
function without an explicit return statement is called a subroutine, but
there's really no difference from the language's perspective.)
------------------------
: When I move the list to the end of the arguments, I don't
: get the error. This code worked fine in version 4.0.1.7
: patch level 35 on ULTRIX V4.2A (Rev. 47).
: Is there a patch for this?
1) put the hash as the last arg ;-)
2) use references (see perlref man page)
--
Tad McClellan SGML Consulting
tadmc@flash.net Perl programming
Fort Worth, Texas
------------------------------
Date: 6 Aug 1997 09:12:30 GMT
From: tina@scandinaviaonline.se (Tina Marie Holmboe)
Subject: Re: Case Statement..
Message-Id: <5s9f5u$2mn$3@news1.sol.no>
In article <19970805235801.TAA15218@ladder02.news.aol.com>,
ct2963@aol.com (CT2963) writes:
> Question...
Answer...
> Is there any type of case statement in Perl??? I cant seems to find any
> references to one or any code that uses one.
Ehem.
man perlsyn:
The BLOCK construct is particularly nice for doing case
structures.
SWITCH: {
if (/^abc/) { $abc = 1; last SWITCH; }
if (/^def/) { $def = 1; last SWITCH; }
if (/^xyz/) { $xyz = 1; last SWITCH; }
$nothing = 1;
}
There is no official switch statement in Perl, because there
are already several ways to write the equivalent. In
addition to the above, you could write
SWITCH: {
$abc = 1, last SWITCH if /^abc/;
$def = 1, last SWITCH if /^def/;
$xyz = 1, last SWITCH if /^xyz/;
$nothing = 1;
}
(That's actually not as strange as it looks once you realize
that you can use loop control "operators" within an
expression, That's just the normal C comma operator.)
or
SWITCH: {
/^abc/ && do { $abc = 1; last SWITCH; };
/^def/ && do { $def = 1; last SWITCH; };
/^xyz/ && do { $xyz = 1; last SWITCH; };
$nothing = 1;
}
or formatted so it stands out more as a "proper" switch
statement:
SWITCH: {
/^abc/ && do {
$abc = 1;
last SWITCH;
};
/^def/ && do {
$def = 1;
last SWITCH;
};
/^xyz/ && do {
$xyz = 1;
last SWITCH;
};
$nothing = 1;
}
or
SWITCH: {
/^abc/ and $abc = 1, last SWITCH;
/^def/ and $def = 1, last SWITCH;
/^xyz/ and $xyz = 1, last SWITCH;
$nothing = 1;
}
or even, horrors,
if (/^abc/)
{ $abc = 1 }
elsif (/^def/)
{ $def = 1 }
elsif (/^xyz/)
{ $xyz = 1 }
else
{ $nothing = 1 }
A common idiom for a switch statement is to use foreach's
aliasing to make a temporary assignment to $_ for convenient
matching:
SWITCH: for ($where) {
/In Card Names/ && do { push @flags, '-e'; last; };
/Anywhere/ && do { push @flags, '-h'; last; };
/In Rulings/ && do { last; };
die "unknown value for form variable where: `$where'";
}
Another interesting approach to a switch statement is
arrange for a do block to return the proper value:
$amode = do {
if ($flag & O_RDONLY) { "r" }
elsif ($flag & O_WRONLY) { ($flag & O_APPEND) ? "a" : "w" }
elsif ($flag & O_RDWR) {
if ($flag & O_CREAT) { "w+" }
else { ($flag & O_APPEND) ? "a+" : "r+" }
}
};
My sincerest apologies to those who have *allready* read the silly
manpages; as if they could ever provide the answer to anything.... >:)
--
Tina Marie Holmboe tina@mail.scandinaviaonline.se
The opinions expressed above are mine, and should in no way or under any
circumstances be associated with Scandinavia Online AB unless this disclaimer
is explicitly revoked.
------------------------------
Date: 07 Aug 1997 13:57:58 +0200
From: Ronald Fischer <rovf@earthling.net>
Subject: Re: chop vs chomp
Message-Id: <xz2en868at4.fsf@uebemc.siemens.de>
>>>>> On 6 Aug 1997 14:52:04 GMT
>>>>> "JF" == Jonathan Feinberg <jdf@pobox.com> wrote:
JF> Benarson.Behajaina@swh.sk said...
>> 1. chop and chomp
JF> chomp is "safe chop"; it only chops if the last character of the
JF> choppee is \n.
Actually, if it is $/ ....
--
Ronald Fischer (rovf@Earthling.net) (PGP public key available)
http://ourworld.compuserve.com/homepages/ronald_fischer/
[When posting a followup, mailing a courtesy copy is fine, provided it is
clearly marked as such.]
------------------------------
Date: 07 Aug 1997 14:03:15 +0200
From: Ronald Fischer <rovf@earthling.net>
Subject: comparing for a range of number - easiest way to do it?
Message-Id: <xz2d8nq8akc.fsf@uebemc.siemens.de>
Hi
not a very important question, but I am curious ....
does someone know an easier way to write
die "foo" if ($x <= $a or $x >= $b);
provided that
$a <= $b
and $a and $b are integers,
and $b not very much greater as $a (i.e. that the usage of $a..$b
would be practical)?
I.e. I am looking for the simplest way to check if $x lies in a range
$a..$b, but as far I understood, the range operator (..) is not
applicable here; but maybe I'm wrong. If anyone knows a good solution
to this, please let me know.
--
Ronald Fischer (rovf@Earthling.net) (PGP public key available)
http://ourworld.compuserve.com/homepages/ronald_fischer/
[When posting a followup, mailing a courtesy copy is fine, provided it is
clearly marked as such.]
------------------------------
Date: 6 Aug 1997 17:52:37 GMT
From: stampes@xilinx.com (Jeff Stampes)
Subject: Re: EASY PROBABLY: removing names from paths
Message-Id: <5sadl6$gob$1@neocad.com>
Shaun O'Shea (lmisosa@eei.ericsson.se) wrote:
: I have an array of file paths and I want to remove everything except the
: file name and extension.
: EG
: ARRAY:
: The/location/of/the/file.extension
: The/location/of/the/file2.extension
: The/location/of/the/file23.extension
This would be a perfect time to use File::Basename, a module
that comes with the standard distribution.
--
Jeff Stampes -- Xilinx, Inc. -- Boulder, CO -- jeff.stampes@xilinx.com
------------------------------
Date: Tue, 5 Aug 1997 09:30:10 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: EASY PROBABLY: removing names from paths
Message-Id: <idd7s5.gt1.ln@localhost>
Shaun O'Shea (lmisosa@eei.ericsson.se) wrote:
: I have an array of file paths and I want to remove everything except the
: file name and extension.
: EG
: ARRAY:
: The/location/of/the/file.extension
: The/location/of/the/file2.extension
: The/location/of/the/file23.extension
: i.e how do I remove everything BEFORE the LAST "/" to leave me with
: file.extension
: file2.extension
: file23.extension
: I tried a few substitutions but I couldn't get the right regexp to do
: the job.
s!.*/!!;
--
Tad McClellan SGML Consulting
tadmc@flash.net Perl programming
Fort Worth, Texas
------------------------------
Date: 06 Aug 1997 17:35:24 GMT
From: eliot@kern1.dg.com (Topher Eliot)
Subject: Re: file extensions
Message-Id: <ELIOT.97Aug6133524@kern1.dg.com>
Shaun O'Shea (lmisosa@eei.ericsson.se) wrote:
: I have an array whose elements are all file paths E.G.
: address/of/the/file/in/question/file1.Uen.A.fmk
: address/of/the/file/in/question/file1.Uen.B.fmk
: address/of/the/file/in/question/file2.Uen.A.fmk
: address/of/the/file/in/question/file3.Uen.A.fmk
: I would like to use this array to create another array which just
: contains the file extensions i.e.
: .Uen.A.fmk
: .Uen.B.fmk
: .Uen.A.fmk
: .Uen.A.fmk
: I tried to find some way to substitute everything up as far as the first
: "." with nothing but I couldn't.
Try this:
($newstring) = $oldstring =~ /[^\.]*(.*)/
I suspect the critical item is the backslash in front of the period, to
indicate that you're talking about a real period, not "any character".
The [^\.] construct means "any character that isn't a period".
I'll leave the iterating through the array to you. Try the "map" operator.
Topher Eliot Data General Unix Core Development
(919) 248-6371 eliot at dg-rtp.dg.com
Obviously, I speak for myself, not for DG.
Visit misc.consumers.house archive at http://www.geocities.com/Heartland/7400
"Do you digest water?" Peter, age 5
------------------------------
Date: Wed, 06 Aug 1997 13:45:57 -0400
From: Al Byers <byersa@agva.com>
Subject: File IO interrupt
Message-Id: <33E8B855.568@agva.com>
Can anyone point me to an example of how perl would be used to
immediately react to a file modification?
--
Al Byers Automation Group of Virginia
(540) 949-8777 P.O. Box 1091
byersa@agva.com Waynesboro, VA 22980
------------------------------
Date: Wed, 6 Aug 1997 14:39:46 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Al Byers <byersa@agva.com>
Subject: Re: File IO interrupt
Message-Id: <Pine.GSO.3.96.970806143603.12246D-100000@kelly.teleport.com>
On Wed, 6 Aug 1997, Al Byers wrote:
> Can anyone point me to an example of how perl would be used to
> immediately react to a file modification?
I'm not sure what you mean by "immediately". Perl has no way of being
notified when a file has been modified. (Neither does any other language,
so far as I know.) The only way to know for sure that a file has been
modified is to check it against either a safe copy or a strong checksum,
such as MD5. You could probably use the modification timestamp in most
cases, though.
If you want to run a Perl script periodically on a Unix machine, you may
want to read up on how to use the cron or at utilities. Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 7 Aug 1997 09:26:10 GMT
From: Casper.Dik@Holland.Sun.COM (Casper H.S. Dik - Network Security Engineer)
Subject: Re: File locking
Message-Id: <casper.870946164@uk-usenet.uk.sun.com>
bart.mediamind@tornado.be (Bart Lateur) writes:
>Randal Schwartz <merlyn@stonehenge.com> wrote:
>> May I also add that *every* version of Perl prior to 5.004
>>(which came out this spring) has an active CERT-ifiable security hole,
>>so it's wise to upgrade anyway if you consider your data to be
>>valuable.
>Does this mean that 5.004 doesn't have any security hole, or just that
>nobody has found it yet?
I think that this the security bugs found in perl have proven once
and for all that the main argument against writing set-uid scripts,
"You never know what the interpreter will to do you" holds for
perl as well as for C-shell (and less so for sh/ksh).
That big unknown factor you get with set-uid scripts is too much of a risk
to take, in my opinion. Especially now that an interpreter which was
constructed with a lot of care towards the writing of secure scritps has
proven not to be immune. That those bugs have been fixed is moot.
Set-uid scripts, not in any language.
Casper
--
Expressed in this posting are my opinions. They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.
------------------------------
Date: Thu, 07 Aug 1997 06:51:42 -0400
From: "D.F. Parkhurst" <parkhurs@indiana.edu>
To: Tad McClellan <tadmc@flash.net>
Subject: Re: Have array, will (won't?) sort
Message-Id: <33E9A8BE.6823@indiana.edu>
Thanks, Tad.
My problem originated from translating an awk to a perl program. Awk
only has associative arrays, so that's what a2p gave me. I've fixed the
program now that I understand what's happening.
Dave
------------------------------
Date: Wed, 06 Aug 1997 13:56:14 -0400
From: David Estornell <destornell@ProbityITC.com>
Subject: How to execute remote Perl script from Perl?
Message-Id: <33E8BABE.72B8@ProbityITC.com>
Is it possible to execute a remote Perl script from Perl? I would like
to 'capture' the output from the remote Perl script and have it appear
in-line with the output of the parent script.
For example, say the URL for remote.pl is
http://abcdefg.net/cgi-bin/remote.pl. This script executes the following
command:
print 'World';
Now, say I am running my script parent.pl:
print 'Hello ';
# What is the real Perl code to do this?
execute 'http://abcdefg.net/cgi-bin/remote.pl';
exit;
Is there a perl command (or group of commands) that I could use in
parent.pl to replace the line beginning with 'execute' so that the final
output of parent.pl will be 'Hello World'?
If you got the answer would you mind emailing it to me?
Thanx
David Estornell
Probity Information Technologies Corporation
731 Street Road, Suite 1
Cochranville, PA 19330
------------------------------
Date: Thu, 07 Aug 1997 12:28:41 +0200
From: Doug Seay <seay@absyss.fr>
To: Patrice Boissonneault <Patrice.Boissonneault@nrc.ca>
Subject: Re: How to make Perl Regular expressions "Rightmost is greediest"?
Message-Id: <33E9A359.3D8328A6@absyss.fr>
[posted and mailed]
Patrice Boissonneault wrote:
>
> How to tell Perl to match the caracters up to the first c. "Rigthmost
> is greediest".
This isn't really "rightmost greediest", but can you easily reverse your
RE pattern? If so, how about
my $backwards = reverse $string;
m/$backwards/$inverted_pattern/;
my @matches = ($3, $2, $1);
Or something like that. Maybe this is good enough. As someone else
pointed out, maybe just using non-greedy REs will get the job done.
- doug
------------------------------
Date: 7 Aug 1997 05:36:59 GMT
From: ifqa242@spice.cc.utexas.edu (Adam Rogoyski)
Subject: Re: Idiotic Perl Problem, can anyone help....
Message-Id: <5sbmtr$g0h$1@geraldo.cc.utexas.edu>
Julian Rose (Julian@productivity-group.co.uk) wrote:
: Hi,
: I have a perl script that's currently using the Unix ls command, I need to
: rewrite the section that does so in order to run it on a server that allows
: no unix commands.
: I believe I will have to use a readdir command, but I have no idea how to
: start, can anyone help, either an idiots guide to readdir, or, to earn
: eternal gratuity, rewrite the section to work for me :)) (I live in hope)
: The relevent defined variables for the script are:
: $basedir:
: Directory where the search page and graphic files are located.
: $baseurl:
: URL where search page and graphic files are located.
: @files:
: Location and type of files to search.
: The section in question is as follows:
: ----snip----
: sub get_files {
: chdir($basedir);
: foreach $file (@files) {
: $ls = `ls $file`;
: print "$ls";
: @ls = split(/\s+/,$ls);
: foreach $temp_file (@ls) {
: if (-d $file) {
: $filename = "$file$temp_file";
: if (-T $filename) {
: push(@FILES,$filename);
: }
: }
: elsif (-T $temp_file) {
: push(@FILES,$temp_file);
: }
: }
: }
: }
: ----snip----
: Currently, the print is in there so I can watch the output, the current
: output from the print "$ls" line is:
: ----snip----
: jobs/1068-ip.html
: jobs/2625-ip.html
: jobs/2741-ip.html
: jobs/2854-ip.html
: jobs/2922-ip.html
: jobs/blank.html
: Content-type: text/html
: ----snip----
: Any help would be most appreciated, I can be reached direct on
: Julian@prodgrp.demon.co.uk (quickest way).
: Cheers
: Julian Rose
opendir CURRENTDIR, $dir || die "Cannot read $dir : $! \n";
This will open a Directory for reading.
@files= readdir (CURRENTDIR);
This will put all the files in CURRENTDI into an array @files.
Is this what you were asking?
--
__/\__. [-Temperance-] .__)\__
! \ oO / . :[Adam Rogoyski]: . \ oO / !
. /_\/_\ . :[ apoc@laker.net ]: . /_\/_\ .
\/ . :[ http://www.laker.net/apoc ]: . \/
------------------------------
Date: 6 Aug 1997 08:00:02 -0700
From: Kristoff Bonne <kristoff.bonne@mpl108.is.belgacom.be>
To: comp.lang.perl.misc@myriad.alias.net, comp.lang.perl@myriad.alias.net
Subject: info from dead child-process in SIGN{'CHLD'}
Message-Id: <9708061438.AA19587@mpl108.bc>
Greetings,
When a forked child-process dies, the father-process receives a =
'CHLD'-signal.
Is there a way for the SIGN{'CHLD'}-subroute of the father-process to =
find out WHAT=20
child-process generated the signal. (the PID would be ideal).
Please reply cc: mail as my news-feed is not what is supposed to be. ;-)
Cheerio! Kr. Bonne.
------------------------------
Date: Wed, 06 Aug 1997 14:33:21 -0400
From: ken@forum.swarthmore.edu (Ken Williams)
Subject: Java and Perl together
Message-Id: <ken-0608971433210001@news.swarthmore.edu>
Hi-
I've read a couple of very short posts lately about Java and Perl, and I
wouldn't mind talking about this a little bit. Specifically, I read about
the new "Perl Resource Kit" by Larry Wall, etc.
(http://www.oreilly.com/catalog/prkunix/desc.html) and I'm intrigued by
this line:
Software tools on the Kit's CD include:
-A Java-enhanced Perl compiler, written by Larry Wall, creator of Perl
What does that mean, "Java-enhanced"? Does it mean you can press a button
and your perl script will turn into a Java applet/application? Does it
mean you can inline Java code in a Perl script, or vice versa? Does it
mean something small, like a library for calling applets on a web page?
Anybody know?
On a related note, what kinds of connections would people like to see
between Java and Perl? What's your wish-list?
-Ken Williams
The Math Forum
ken@forum.swarthmore.edu
------------------------------
Date: Wed, 6 Aug 1997 14:31:28 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Ken Williams <ken@forum.swarthmore.edu>
Subject: Re: Java and Perl together
Message-Id: <Pine.GSO.3.96.970806142344.12246B-100000@kelly.teleport.com>
On Wed, 6 Aug 1997, Ken Williams wrote:
> Software tools on the Kit's CD include:
> -A Java-enhanced Perl compiler, written by Larry Wall, creator of Perl
>
> What does that mean, "Java-enhanced"? Does it mean you can press a button
> and your perl script will turn into a Java applet/application? Does it
> mean you can inline Java code in a Perl script, or vice versa? Does it
> mean something small, like a library for calling applets on a web page?
> Anybody know?
Come to the Perl Conference, and expect to hear more about this!
http://www.ora.com/info/perl/conference/
http://perl-conf.songline.com/cgi-bin/p/guest.pl?x-a=v&x-id=419
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Wed, 06 Aug 1997 16:09:01 -0500
From: Robert Lee <reljr@sigg.com>
Subject: Re: parsing techniques (advice needed)
Message-Id: <33E8E7EC.C3F80F70@sigg.com>
Ryan wrote:
> I know there are modules for doing this, but just as an example, what is
> the best way to go about parsing links from HTML pages and other similar
^^^^
> tasks?
>
>
Best? What is it you really want?
Small learning curve, lowest program overhead, fastest, smartest?
------------------------------
Date: Wed, 06 Aug 1997 14:20:25 GMT
From: kkranz@ebbtide.com (Ken Kranz)
Subject: Perl access on NT using Netscape results in ERROR_BAD_EXE_FORMAT error
Message-Id: <33e88320.6110856@client.news.psi.net>
I know this problem has been addressed and I've read the FAQ's but I
am still hopelessly lost. Any help would be appreciated
I am trying to get Perl CGI scripts to run under Netscapes Enterprise
Server 2.01
Here is what I have done:
1) enabled cgi as a file type
2) set my CGI directory (www.xxx.com/cgi-bin) to
/web/xxx/htdocs/cgi-bin
3) set my Win CGI directory (www.xxx.com/win-bin) to
/web/xxx/htdocs/win-bin
4) set my Shell CGI directory (www.xxx.com/shell-bin) to
/web/xxx/htdocs/shell-bin
5) associated ".pl" and ".cgi" with /mks/mksnt/perl.exe (thats MKSs
Perl 5.0 interperter)
6) created a test perl script:
print "Content-type: text/html\n\n";
print "<HTML><HEAD><TITLE>PERL Test Page</TITLE></HEAD>\n";
print "<BODY><P>This is a PERL based test</P>";
print "<P> input args: $ARGV[0]</P>\n";
print "</BODY></HTML>\n";
exit 1
7. created duplicate versions called ptest.pl and ptest.cgi and
installed them in the shell-bin directory
8. run and verified each program from the command line (aka both work
+ if I run them and redirect the output to htdocs/foo.html the browser
can read the contents)
9. verified that the files & the perl.exe have "everyone" access
10. restarted my server about 1422 times ;)
Problem:
When I type in the URL: www.xxx.com/shell-bin/ptest.pl (note the PL
extension) the contents of the file itself are displayed:
print "Content-type: text/html\n\n";
print "<HTML><HEAD><TITLE>PERL Test Page</TITLE></HEAD>\n";
print "<BODY><P>This is a PERL based test</P>";
print "<P> input args: $ARGV[0]</P>\n";
print "</BODY></HTML>\n";
exit 1
When I type in the URL ending in cgi I get the old standard:
Server Error
This server has encountered an internal error which prevents it from
fulfilling your request. The most likely cause is a
misconfiguration. Please ask the administrator to look for messages in
the server's error log.
Finally, the error log contains the following:
failure for host xxx trying to GET /shell-bin/ptest.cgi, send-cgi
reports: could not send new process (ERROR_BAD_EXE_FORMAT)
BTW: I also created a C version ctest.exe and placed it in the cgi-bin
directory. That works fine.
Well thats it. If anyone has specific knowledge of this problem
please give me a shout. My e-mail address is kkranz@ebbtide.com. If
you could CC my e-mail address with a response thats make my
miserable life a bit better ;) Thanks.
------------------------------
Date: 7 Aug 97 07:55:29 GMT
From: tshiono@cv.sony.co.jp (Toru Shiono)
Subject: Re: Printing to absolute screen position
Message-Id: <TSHIONO.97Aug07075529@aquarius.cv.sony.co.jp>
In article <33E398B4.2E17E7F6@funnel.demon.co.uk>
NOSPAMadam@funnel.demon.co.uk (Adam Naylor) writes:
>I need to print to an absolute screen position from perl, so that I can
>update that same line with new information.
>
>Example:
>
>12 of 100
>13 of 100
>14 of 100
>
>.......but preferably overwriting the earlier print without calling
>'clear'.
How about:
sub locate {
my($row, $col) = @_;
print STDOUT "\e[$row;${col}H";
}
$| = 1;
for (1 .. 100) {
locate(3, 10); # or anywhere you wish
print "$_ of 100";
}
--
Toru Shiono Sony Corporation, JAPAN
------------------------------
Date: 6 Aug 1997 15:55:07 GMT
From: davidb@news.kenan.com (David Bonner)
Subject: Re: Seeking object enlightenment
Message-Id: <5sa6or$de2@pony.kenan.com>
Bill Goffe (bgoffe@cook.cba.usm.edu) wrote:
: : gives some of the motivation for OOP.
: This is indeed quite useful, but some hints on how to use objects
: with perl would be useful as well.
Try taking a look at Tom's Object-Oriented Tutorial. perldoc perltoot
should give it to you.
--
#==========================================================================#
#"it's the word's suppression that gives it the power, | david bonner #
# the violence, the viciousness" - lenny bruce | dbonner@cs.bu.edu #
#==========================================================================#
------------------------------
Date: 7 Aug 1997 11:39:03 GMT
From: etltsln@etlxd30.ericsson.se ( Thomas Lachlan XMS x4206 )
Subject: Style and efficiency
Message-Id: <5scc4n$sh2@newstoo.ericsson.se>
Hello,
The following sub, that is called many times
is helpling itself to all my processors memory.
I expressly used for loops and buffers to
ensure this didn't happen. A few pointers
to where I'm going wrong would be gratefully
received.
sub get_summer {
$sum=0
$buf=256;
$num_blocks=$total_bytes / $buf;
($whole,$rem)=split /\./,$num_blocks;
if($rem){$num_blocks = $whole + 1;}
open(FILE,"$absolute_entry") || die "$!\n";
for($curr_block = 1;$curr_block <= $num_blocks; $curr_block++){
read (FILE,$line, $buf);
seek FILE, 0,1 ;
}
$div=int($sum / 65535);
sum += $div;
chomp($sum %= 65536);
close(FILE);
}
Thanks in advance regds Tom.
------------------------------
Date: 06 Aug 1997 16:52:22 +0000
From: Tom Grydeland <tom@mitra.phys.uit.no>
Subject: Re: Too Many Files for Foreach Loop?
Message-Id: <nqoyb6f6ypl.fsf@mitra.phys.uit.no>
"Paul Denman" <pdenman@ims.ltd.uk> writes:
> foreach $file_in (< *.dat>) {
> This has worked when there have only been a handful of files, but it
> is producing nothing with such a large number of files.
> I am running Perl5 on a Unix box (Irix v.5)
That's right. <*.dat> is a glob and (AFAIK) calls csh to do the
globbing. This is easy, slow and prone to csh's limitations. Try
this instead:
opendir DIR, "." or die "Couldn't opendir: $!";
while (defined $file_in = readdir DIR) {
next unless $file_in =~ /\.dat$/;
# process file
}
closedir DIR;
Beware that the order in which you get the files will (usually) be
quite different from the sorted list you get by globbing. If this is
a concern, try
opendir # as above
@sorted_files = sort grep /\.dat$/, readdir DIR;
closedir DIR;
while ($file_in=shift @sorted_files) {
#process files
}
You can of course use any sort criteria you like in the sort.
> Any help would be appreciated.
HTH,
> pdenman@ims.ltd.uk
--
//Tom Grydeland <Tom.Grydeland@phys.uit.no>
------------------------------
Date: 07 Aug 1997 12:28:46 +0000
From: Tom Grydeland <tom@mitra.phys.uit.no>
Subject: Re: Unclear documentation for map()
Message-Id: <nqowwlyfa81.fsf@mitra.phys.uit.no>
jot.news@bofh.com (Jot Powers) writes:
> I wanted a way to convert a numerically subscripted array (ie @bob) into
> a hash array (%bob) without having to step through all of @bob. Being
> the good little perl programmer, I thought that map() might be of
> help and I broke out my second edition camel.
Good.
[...]
> However, I couldn't find a reference for genkey().
> So, I looked at my man pages and found the following:
Good.
> %hash = map { getkey($_) => $_ } @array;
>
> which didn't help, since I couldn't find anything but the
> two occurences that are in that example.
>
> (node127% cd /usr/local/man/man1
> node127% grep getkey perl*
> perlfunc.1:\& %hash = map { getkey($_) => $_ } @array;
> perlfunc.1:\& $hash{getkey($_)} = $_;
> )
>
> I also checked Tom's on-line errata and found no corrections for
> that section.
Good.
> About then I realized that both getkey() and genkey() were probably
> there to let people know that they needed to use a function to tell
> perl what the mappings were. ^^^^^^^^^
Not *needed to*, but *could*. If the key generation function is
complicated, it would help clarify things too.
> Now, in my case I wanted the hash
> for doing a poor man's 'sort -u', so I resorted to:
Wait a second. You *are* of course aware of the FAQ entry (in perlfaq4)
How can I extract just the unique elements of an array?
=======================================================
Perhaps this is what you want? (Sometimes, you can't use the FAQ
without knowing, given your problem, which question to ask. :-)
Chaining the answer to this faq with a vanilla sort gives you your
"poor man's sort -u":
@new_bob = sort grep {!$seen{$_}++} @bob;
(Assuming, of course, that you can spare %seen for a minute.)
Now wasn't that better?
[...]
> Jot Powers news@bofh.com
--
//Tom Grydeland <Tom.Grydeland@phys.uit.no>
------------------------------
Date: Mon, 04 Aug 1997 20:04:33 +0300
From: ITCG <itcg@com.latnet.lv>
Subject: What means --> Can't call method "xxxxxxx" on unblessed reference ...?
Message-Id: <33E60BA1.4705@com.latnet.lv>
Hello big brothers,
Can anybody explain what does this message mean:
-------
Can't call method "AddHeader" on unblessed reference at pop4.pl line 88,
<SOCK2> line 29.
-------
{Who can bless it?}
The goal is to check as frequently possible the mailbox, parse the
contents and the send the HTTP request to WEB server.
My program does it very nicely but after 3rd or 4th time it shows this
message and dies.(Or dies and then shows the message...?) I have placed
everything in while(1){...} loop.
I thought - maybe requests are being sent very fast one after another
(about 2,3 seconds) and tried to add sleep(). Doesn't help.
I can send a source if somebody is interested to help...
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.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 822
*************************************