[10232] in Perl-Users-Digest
Perl-Users Digest, Issue: 3825 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Sep 25 15:07:19 1998
Date: Fri, 25 Sep 98 12:00:19 -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 Fri, 25 Sep 1998 Volume: 8 Number: 3825
Today's topics:
$? Questions <george.kuetemeyer@mail.tju.edu>
Re: .pl to .bat conversion <r_larsen@image.dk>
Re: [Q:] read/write binary with half-byte length(a nibb (M.J.T. Guy)
Coding Standards? (Lee Mulleady)
desperate for socket help <deg28@columbia.edu>
Re: Getting dialup dynamic IP (David Hawker)
Re: Help compiling <eashton@bbnplanet.com>
Re: help with removing leading zeros with reg-exp <jplundgren@micron.com>
Re: help with removing leading zeros with reg-exp <jplundgren@micron.com>
Re: help with removing leading zeros with reg-exp <r28629@email.sps.mot.com>
Re: help with removing leading zeros with reg-exp (Matt Knecht)
Re: MLDBM object methods (Steve Manes)
Re: Perl & Java - differences and uses <retnuh@pixar.com>
Re: Perl & Java - differences and uses <zenin@bawdycaste.org>
Re: Perl & Java - differences and uses <zenin@bawdycaste.org>
Re: Perl & Java - differences and uses <zenin@bawdycaste.org>
Re: Perl under Win95 and Binary files (Alan Barclay)
Re: Redirection Question (Matt Knecht)
Re: Retrieve cgi results to file rather than to display (Patrick Timmins)
Running apps. list through Perl? <alex@digi-q.com>
Re: Where to put cgi-lib.pl (Patrick Timmins)
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 25 Sep 1998 14:27:25 -0400
From: George Kuetemeyer <george.kuetemeyer@mail.tju.edu>
Subject: $? Questions
Message-Id: <360BE08D.6A75FCDF@mail.tju.edu>
I'm having trouble getting info about the $? variable (which holds the
result of the last backtick, system, or pipe operation). Here are some
questions (all questions assume that $return_code = $? >> 8):
o Should $? always be read after closing the pipe? Or are there reasons
for doing this prior to closing, say after handling the pipe with a
'while' block?
o Are there any reasons why 'invalid' return codes may intermittently
appear? (by 'invalid' I mean that the piped program code just doesn't
ever return the value that $? returns).
o If the piped command is called by a forked child process, should this
make any difference?
o Can hardware or Perl version impact on $? return codes?
Thanks in advance.
------------------------------
Date: Fri, 25 Sep 1998 20:11:17 +0200
From: R. A. Larsen <r_larsen@image.dk>
Subject: Re: .pl to .bat conversion
Message-Id: <VA.0000005d.004935ea@octo>
Brian Day <brianjulz@earthlink.net> wrote:
>
> I used the pl2bat file that comes with the perl distribution to convert
> a perl script to a batch file.
[most of the description of problem deleted]
> The only way it works is
> if I am actually in the c:\perl\bin directory and call it with the
> explicit path c:\perl_work\hello
>
> Is there any way to get this to work by simply typing hello while in
> c:\perl_work ???
Try adding 'c:\perl\bin' to your path or replace the line
perl -x -S %0 %1 %2 %3 %4 %5 %6 %7 %8 %9
with
c:\perl\bin\perl -x -S %0 %1 %2 %3 %4 %5 %6 %7 %8 %9
in pl2bat.
> Any info is greatly appreciated
I hope this helps.
Reni
--
Using Virtual Access
http://www.vamail.com
------------------------------
Date: 25 Sep 1998 18:19:09 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: [Q:] read/write binary with half-byte length(a nibble)
Message-Id: <6ugmqt$91d$1@pegasus.csx.cam.ac.uk>
In article <6ubm28$6sg$1@nnrp1.dejanews.com>, <phu@mobility.com> wrote:
>hi, all
>
>I was trying to read a large binary file, modify a few fields and write it
>back. The problem is some of the fields have only 4-bit length and others
>have, say, 12-bit length. I'v played unpack for a while and searched the
>archive but still can not find a suitable solution. For example, I have a
>2-byte string like this: "0011000000000001" the first 4-bit is one number,
>the rest 12-bit is another, so in this case I should get "3" for first and
>"1" for the second one. I know I need to do something like
>
>>> or << to deal with this but is there any sysmetic way I can do this ? (For each
>data field I know the start bit and bit length.)
vec() might help. But I suspect you'll still have to do the hard work.
Mike Guy
------------------------------
Date: Fri, 25 Sep 1998 17:38:36 GMT
From: lemull@unx.sas.com (Lee Mulleady)
Subject: Coding Standards?
Message-Id: <360bd4b4.968809562@newshost.unx.sas.com>
Can anyone point me to a set of Coding Standards developed
specifically for Perl?
Thanks, Lee
lemull@unx.sas.com
------------------------------
Date: Fri, 25 Sep 1998 14:50:15 -0400
From: Eli Glanz <deg28@columbia.edu>
Subject: desperate for socket help
Message-Id: <Pine.GSO.3.95qL.980925144557.28277A-100000@bonjour.cc.columbia.edu>
here is the relevant source:
$protocol = getprotobyname('tcp');
socket(SOCKET, PF_INET, SOCK_STREAM, $protocol) || die $!;
$local_sok = sockaddr_in(0, gethostbyname('localhost')) || die $!;
bind(SOCKET, $local_sok) || die "Bind: $!";
$remote_ip_addr = gethostbyname($server);
$remote_sok = sockaddr_in($port, $remote_ip_addr);
connect(SOCKET, $remote_sok);
the above lines work, and connects me a server specified by $server and
$port. however if i do:
while (<SOCKET>) {print}
to read the server greeting, the script gets stuck in this while loop. how
can i make it stop once its read the text.
tnx
------------------------------
Date: Fri, 25 Sep 1998 19:11:00 +0100
From: dhawker@removethis.bigfoot.com (David Hawker)
Subject: Re: Getting dialup dynamic IP
Message-Id: <360cdca4.1451611@news.cableol.net>
You're basically doing what I have done, but using UDP instead of TCP. I
tried that and frankly I don't think my version of perl supports UDP. But I
think there is a mistake in your code - you need to specify the 3rd scalar
returned by getprotobyname('udp').
On Sat, 22 Aug 1998 16:10:40 GMT, maurice@hevanet.com (Maurice Aubrey) felt
the need to post:
>On Sat, 22 Aug 1998 14:24:47 GMT, David Hawker <dhawker@bigfoot.com> wrote:
>>Is there any way I can get my perl script to automatically obtain my
>>dynamic IP address whenever I dialup? Perhaps a winsock call? I'm running
>>Windows 95 and perl 5.004_02 for DOS.
>>
>>Currently I'm using a cgi script to send me the $ENV{REMOTE_HOST} data
>>which I then paste into the local perl script as my hostname.
>
>I'm not sure if this will work under 95.
>
># getsockname() to find out what our IP address is.
># The remote host doesn't even need to exist, since
># a UDP connect doesn't actually send anything; it
># just determines what interface is needed to get out.
># If there's no route outside, we die.
>sub _determine_ip {
> my $self = shift;
> my($raddr, $myaddr, $socket);
>
> $socket = new FileHandle;
> $raddr = sockaddr_in(80, '1.1.1.1');
> socket($socket, PF_INET, SOCK_DGRAM, getprotobyname('udp'))
> or die "create socket: $!";
> connect($socket, $raddr)
> or die "connect: $!";
> $myaddr = (unpack_sockaddr_in(getsockname($socket)))[1];
> close $socket;
> return inet_ntoa $myaddr;
>}
--
dhawker@bigfoot.com | ICQ 7222349
http://dhawker.home.ml.org
------------------------------
Date: Fri, 25 Sep 1998 18:08:32 GMT
From: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Re: Help compiling
Message-Id: <360BD9B2.AC0A9B8C@bbnplanet.com>
Adam Levin wrote:
> I recently grabbed perl5.005_01. I'm compiling on a Sun Ultra 1
> running Solaris 2.5.1. I'm compiling using gcc-2.8.1 installed from a
> package pre-compiled downloaded from www.sunfreeware.com.
> gcc -B/usr/ccs/bin/ -o miniperl miniperlmain.o libperl.a -lsocket
> -lnsl -ldl -lm -lc -lcrypt
Hard to say but i'd first lose the -B....
Perl4 was easy when you knew the libs, Perl5 holds your hand. With all
of the defaults it should compile without error.
-Bprefix
This option specifies where to find the executables,
libraries and data files of the compiler itself.
The compiler driver program runs one or more of the
subprograms `cpp', `cc1' (or, for C++, `cc1plus'), `as'
and `ld'. It tries prefix as a prefix for each program
it tries to run, both with and without
`machine/version/'.
For each subprogram to be run, the compiler driver
first tries the `-B' prefix, if any. If that name is
not found, or if `-B' was not specified, the driver
tries two standard prefixes, which are `/usr/lib/gcc/'
and `/usr/local/lib/gcc-lib/'. If neither of those
results in a file name that is found, the compiler
driver searches for the unmodified program name, using
the directories specified in your `PATH' environment
variable.
e.
"All of us, all of us, all of us trying to save our immortal souls, some
ways seemingly more round-about and mysterious than others. We're having
a good time here. But hope all will be revealed soon." R. Carver
------------------------------
Date: Fri, 25 Sep 1998 11:02:26 -0600
From: Joe Lundgren <jplundgren@micron.com>
Subject: Re: help with removing leading zeros with reg-exp
Message-Id: <360BCCA2.F218DA86@micron.com>
This is better than the solution I posted in many ways, but worse in
one....
I used map in what amounted to a void context (shame, shame), but your
(and Uri's) solutions would result in a value of '' for initial values
of '000' and I don't think that's what the original poster was looking
for....
Of course, if he's just going to use these as numbers, there's no reason
to remove the leading zeros at all.....
Craig Berry wrote:
>
> foreach (@line_element[0..5]) {
> s/^0+//;
> }
>
> In 5.005 you can express that even *more* tersely, believe it or not.
Gee, I guess it's a good thing that we aren't using 5.005 here yet.
Already, my coworkers (who don't use as Perl as much as I do) are
complaining they have trouble with my regexs...allowing me to bury even
more into it might result in my having to maintain *all* the code I
write instead of most! :)
------------------------------
Date: Fri, 25 Sep 1998 10:20:34 -0600
From: Joe Lundgren <jplundgren@micron.com>
To: Mark Stackhouse <stackhou@execpc.com>
Subject: Re: help with removing leading zeros with reg-exp
Message-Id: <360BC2D2.E42367E7@micron.com>
tr will replace all instances, not just leading ones. In this example,
you are losing all the zeros. Instead of tr, try one of these:
$line_element[$k] = sprintf "%d", $line_element[$k];
-- or --
$line_element[$k] =~ s/^0{1,2}//;
And an easier way to do this would be with map, ie:
@line_element[0..5] = map { s/^0{1,2}//; $_ } @line_element[0..5];
<code snipped>
------------------------------
Date: Fri, 25 Sep 1998 13:05:56 -0500
From: Tk Soh <r28629@email.sps.mot.com>
Subject: Re: help with removing leading zeros with reg-exp
Message-Id: <360BDB84.364AB56E@email.sps.mot.com>
Uri Guttman wrote:
>
> >>>>> "MS" == Mark Stackhouse <stackhou@execpc.com> writes:
>
> MS> Could someone please clear up my misunderstanding of "tr"?
> MS> I'm trying to remove leading zeros in the first six elements of file
> MS> lines. The closest code I can come up with is:
>
> MS> for ($k=0; $k<=5; $k++) #check the first 6 elements
> MS> {
> MS> if ($line_element[$k] =~ /^0/) #match leading zeros
> MS> {
> MS> $line_element[$k] =~ tr/1-9//cd; #remove zeros
>
> try using s/^0+// instead of tr//
He wanted "000" to be "0", wouldn't s/^0+(?=\d)// be better?
-Tk
------------------------------
Date: Fri, 25 Sep 1998 18:43:45 GMT
From: hex@voicenet.com (Matt Knecht)
Subject: Re: help with removing leading zeros with reg-exp
Message-Id: <BvRO1.532$7Q6.4688277@news2.voicenet.com>
Tk Soh <r28629@email.sps.mot.com> wrote:
>
>He wanted "000" to be "0", wouldn't s/^0+(?=\d)// be better?
Mark Stackhouse <stackhou@execpc.com> wrote:
>
>I'm trying to remove leading zeros in the first six elements of file
>lines.
>
>I want "000" to be "0"
> "001" to be "1"
Everybody keeps forgetting "the first 6 elements".
s/^0{1,5}(?=\d)// would work, as well as my original reply.
--
Matt Knecht - <hex@voicenet.com>
------------------------------
Date: Fri, 25 Sep 1998 18:17:38 GMT
From: smanes@NOSPAM.HEREmagpie.com (Steve Manes)
Subject: Re: MLDBM object methods
Message-Id: <3618dd63.1177507121@news.panix.com>
On Thu, 24 Sep 1998 14:42:29 -0400, John Porter <jdporter@min.net>
wrote:
>Well, I don't know why you would expect any behavior other than what
>you got, considering it's well-documented in many places.
>
>If you want a hash which remembers the order in which the keys
>were added, check out the Tie::IxHash module.
It's my understanding that IxHash only supports in-memory hashes and
isn't supported by MLDBM.
------------------[ http://www.magpie.com ]-----------=o&>o-------
Steve Manes smanes [at] magpie.com N'Yawk, N'Yawk
------------------------------
Date: Fri, 25 Sep 1998 18:16:09 GMT
From: Hunter Kelly <retnuh@pixar.com>
Subject: Re: Perl & Java - differences and uses
Message-Id: <yvtaf3o5a8m.fsf@corona.pixar.com>
The following message is a courtesy copy of an article
that has been posted to comp.lang.perl.misc,comp.lang.java.programmer as well.
[Apologize if this is a repost, error on posting end]
Zenin <zenin@bcawdycaste.org> writes:
<snip>
> And print out 40 and 80. This of course, will not compile. More
> over, it wouldn't be the best example of a closure since we are
> using two different pieces of code (o1 and o2 use two complete
> blocks of code). Indeed, as Java does not support real closures
> an example in Java can't really be done (at least not well, and
> definedly not that will compile).
>
> Here is a better example in Perl:
>
> sub times_something {
> my $x = shift;
> return sub { $x * shift };
> }
>
> my $o1 = times_something (10);
> my $o2 = times_something (20);
>
> print $o1->(4.0), "\n";
> print $o2->(4.0), "\n";
>
> This prints 40 and 80 respectively. Funky hey?
>
> The value passed to times_something() is bound at *run time* in
> the particular anonymous function pointer. Indeed, the ability to
> bind values in the context of the run time environment is key to
> what a lambda function is.
>
> Java can only bind values to a context at compile/load time, which
> is why it can not support closures (lambda functions).
This is blatantly false. Joseph Allen Dane <jdane@hawaii.edu> showed
that this was possible, yet you flamed him because _you_ don't know
how to compile a java program. Here is his code, modified so that it
will fit in one file, so even _you_ can compile it, and also changed
to look like the perl example you just presented.
32 @corona:/tmp> cat closure.java
public class closure {
interface printer {
void printTimes(int i);
void set(int n);
}
public closure() {}
public printer times_something(int num) {
final int pnum = num;
return new printer() {
int foo = pnum;
public void printTimes(int i) {
System.out.println(foo*i);
}
public void set(int n) {
foo = n;
}
};
}
public static void main(String args[]) {
closure cl = new closure();
int a=0,b=0,c=0,times=0;
try {
a = Integer.parseInt(args[0]);
b = Integer.parseInt(args[1]);
c = Integer.parseInt(args[2]);
times = Integer.parseInt(args[3]);
}
catch (Exception e) {}
printer p10 = cl.times_something(a);
printer p20 = cl.times_something(b);
p10.printTimes(times);
p20.printTimes(times);
p10.set(c);
p10.printTimes(times);
}
}
33 @corona:/tmp> javac closure.java
34 @corona:/tmp> java closure 10 20 15 4
40
80
60
35 @corona:/tmp>
It binds the values all at run time. Looks like your perl
example to me. Well, alot more code, granted, but it still
does the same thing.
> : Java typed solution is definitely more verbose than the other languages.
>
> True, but verbosity is not the issue. Mear ability is. Java simply
> can't do closures, and neither can its byte code which is why a
> Scheme Java byte code compiler is impossible.
>
> Inner classes are a major kluge at best to try and make up for
> *some* of the functionality, but not all or even most of it.
What part is it lacking? Give us another example in perl showing what
Java can't do. I'm not being antagonistic or saying that there isn't
anything, just that Java can do what you've described so far.
> To do closures you need to have at least one context stack in the
> runtime. The system does not provide this, and neither does the
> JVM. Therefor, to do closures you would need to build anothern
> runtime system/VM *on top* of the JVM ala the Python written in
> Java. A Python in Java however is much easier then a Perl in
> Java, simply because Python does not properly support closures
> anyway so this isn't a concern there. Lisp, Scheme, or Perl
> runtimes in Java would be harder, but possible. Pure Java byte
> code backends for them however, are likely impossible.
>
> : If there is some design which needs lambda style functions instead of inner
> : classes I would be interested.
>
> Any functional programming book should be able to give you dozens
> of examples. If that fails, I'm sure a couple clicks off of
> www.scheme.org should fill this order and then some. :-)
>
> --
> -Zenin (zenin@archive.rhps.org) From The Blue Camel we learn:
> BSD: A psychoactive drug, popular in the 80s, probably developed at UC
> Berkeley or thereabouts. Similar in many ways to the prescription-only
> medication called "System V", but infinitely more useful. (Or, at least,
> more fun.) The full chemical name is "Berkeley Standard Distribution".
Hunter
------------------------------
Date: 25 Sep 98 18:18:55 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: Perl & Java - differences and uses
Message-Id: <906747750.208790@thrush.omix.com>
Joseph Allen Dane <jdane@hawaii.edu> wrote:
>snip<
: It comes down to different ways of looking at the problem, and to say
: that one way is somehow categorically "better" than another seems
: pretty meaningless to me. Which, I think, was at least part of your
: original point in this eternal thread.
Exactly! This simple logic however, is something that no one seems
able to convince George of.
Thus, our continued harping and my continued request/challenge for
someone, anyone (George, if he can do it), to recode my example in
an OO style that supports George's claims that at least as far as
non-performance issues are concerned and assuming the development
staff is fully versed in OO, that the OO paradigm IS always "better"
then others in either a pure state or mixed state.
If this thread is any indication, George stands alone in this
position and without a shred of evidence to back him up.
--
-Zenin (zenin@archive.rhps.org) From The Blue Camel we learn:
BSD: A psychoactive drug, popular in the 80s, probably developed at UC
Berkeley or thereabouts. Similar in many ways to the prescription-only
medication called "System V", but infinitely more useful. (Or, at least,
more fun.) The full chemical name is "Berkeley Standard Distribution".
------------------------------
Date: 25 Sep 1998 18:39:30 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: Perl & Java - differences and uses
Message-Id: <906748692.251300@thrush.omix.com>
John Porter <jdporter@min.net> wrote:
: Zenin wrote:
: >
: > I would like to challenge
: > that the current OO support set of Perl rivals most other
: > common OO languages such as Python and Java.
:
: Right; because
:
: ( ( Better-OO-Support(X) => Better-Language(X) )
: => not-Better-Language(Perl) ) )
: => not-Better-OO-Support(Perl)
:
: That last is the key predicate.
Wouldn't that be:
( ( Better-OO-Support(X) => Better-Language(X) )
=> not-Better-Language(Perl) )
=> not-Better-OO-Support(Perl)
That extra paren is predicate. :-)
--
-Zenin (zenin@archive.rhps.org) From The Blue Camel we learn:
BSD: A psychoactive drug, popular in the 80s, probably developed at UC
Berkeley or thereabouts. Similar in many ways to the prescription-only
medication called "System V", but infinitely more useful. (Or, at least,
more fun.) The full chemical name is "Berkeley Standard Distribution".
------------------------------
Date: 25 Sep 98 18:51:42 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: Perl & Java - differences and uses
Message-Id: <906749717.612132@thrush.omix.com>
John Porter <jdporter@min.net> wrote:
: Zenin wrote:
>snip<
: > Nothing. It's perfect proof. I never said it wasn't.
:
: I think you both need to revisit your dictionaries.
:
: George said "should be avoided". This is clearly a matter of opinion,
: or advisement. It is not subject to proof.
Quite true.
: Now, laying aside the term "proof", and rather asking "WHY should foobar
: be avoided", then George offered one reason. However, it asks as many
: questions as it answers, so the skeptical discutant is left unsatisfied.
: Zenin, for whatever reasons, is -- or is appearing to be -- satisfied.
On this issue (inner classes being a "kluge") I am satisfied (I
agree with George in this conclusion, but for my own reasons), so
I choose to use the topic to make my point about semantic games
as it had no chance to blur the other topics we're debating.
: > Your comments, true or false, with or without proof are still your
: > opinions as well. I only asked you not to "phrase your opinions as
: > declarations, at least without citing proof"...
:
: This, IMHO, strikes at the heart of the matter.
: George is entirely too prone to stating his opinions as though they
: were fact. I suspect that he might really be unable in his mind to
: distinguish -- without great effort, anyway -- between his opinion
: and objective fact.
Agreed.
--
-Zenin (zenin@archive.rhps.org) From The Blue Camel we learn:
BSD: A psychoactive drug, popular in the 80s, probably developed at UC
Berkeley or thereabouts. Similar in many ways to the prescription-only
medication called "System V", but infinitely more useful. (Or, at least,
more fun.) The full chemical name is "Berkeley Standard Distribution".
------------------------------
Date: 25 Sep 1998 16:58:18 GMT
From: gorilla@elaine.drink.com (Alan Barclay)
Subject: Re: Perl under Win95 and Binary files
Message-Id: <906742697.258365@elaine.drink.com>
In article <6uerjs$sua$1@plug.news.pipex.net>,
nshon <nhon@*spam*hons.compulink.co.uk> wrote:
>than the infile so I guess it must be carriage returns or something. Any
>ideas on solving this? Thanks in advance.
>---------------------
>#!/usr/bin/perl
>$fname=<STDIN>;
>open(IMG,$fname);
>open(OUT,">out.jpg");
>binmode(IMG);
binmode(OUT);
>my $image;
>my $size = -s IMG;
>my $bytes=read(IMG,$image,$size);
>print OUT "$image" if $bytes==$size;
binmode is important on both reading & writing.
------------------------------
Date: Fri, 25 Sep 1998 18:23:00 GMT
From: hex@voicenet.com (Matt Knecht)
Subject: Re: Redirection Question
Message-Id: <8cRO1.531$7Q6.4685528@news2.voicenet.com>
Tom Turton <tturton@cowboys.anet-dfw.com> wrote:
># Defaults #
>print STDERR
> "0) This should go to screen if interactive; abnormal.log if cronjob.\n";
unless (-t STDERR) {
open(STDERR, "> $logfile")
or die "$0: Can't redirect STDERR to $logfile: $1";
}
># Redirect STDERR to error.log #
>open STDERR, ">/home/tturton/PERL/error.log";
>print STDERR "1) This should go to error.log if interactive OR cronjob.\n";
Check return of open()!
># Redirect 'local' STDERR to Default STDERR #
>{
> local *STDERR;
> open (STDERR, ">-"); # ports it to STDOUT, instead of default STDERR
> select STDERR;
> $| = 1;
> print STDERR
> "2) This should go to screen if interactive; abnormal if cronjob.\n";
>}
{
local *STDERR;
if (-t STDERR) {
open(STDERR, ">&STDOUT") or die "Can't dup STDERR to STDOUT: $!";
} else {
open(STDERR, "> $logfile")
or die "$0: Can't redirect STDERR to $logfile: $1";
}
print STDERR
"2) This should go to screen if interactive; abnormal if cronjob.\n";
}
># Resume using STDERR (error.log) #
>print STDERR "3) This should be back in error.log if interactive OR cronjob.\n";
Assuming you haven't dup'd STDERR anywhere else, then yes.
># Redirect STDERR to STDOUT #
>open STDERR, ">&STDOUT";
>print STDERR "4) This should go out to screen if interactive; normal.log if cronjob\n";
No. See above.
--
Matt Knecht - <hex@voicenet.com>
------------------------------
Date: Fri, 25 Sep 1998 18:30:26 GMT
From: ptimmins@netserv.unmc.edu (Patrick Timmins)
Subject: Re: Retrieve cgi results to file rather than to display
Message-Id: <6ugng3$goh$1@nnrp1.dejanews.com>
In article <01bde897$6923c6e0$86ecb5cf@fritz.ccnet.com>,
"Sean Scannell" <dundee@dnai.com> wrote:
>
> > >I want to run a script using crontab to periodically send form data to a
> > >cgi.
>
> (This part I know how to do)
>
> >> Then I want to retrieve those results to file rather than display so
> > >I can perform text searching.
>
> (This part I don't know how to do)
You can do both! 'print' to a filehandle, then return a
'Location:http://www.etc.etc/etc/your_new_file to display.
See the 'open' command in perldoc perlfunc for opening a file (and
file-handle) to write to. See the 'print' command, also in perldoc perlfunc
for info on printing to your open filehandle.
Hope that helps.
Patrick Timmins
$monger{Omaha}[0]
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Fri, 25 Sep 1998 11:40:59 -0700
From: Alex Guberman <alex@digi-q.com>
Subject: Running apps. list through Perl?
Message-Id: <360BE3BB.2EC8@digi-q.com>
Hi,
Does anybody know how to get a list of running applications on the
system through Perl running under Windows95 or NT?
Thank you
------------------------------
Date: Fri, 25 Sep 1998 18:16:32 GMT
From: ptimmins@netserv.unmc.edu (Patrick Timmins)
Subject: Re: Where to put cgi-lib.pl
Message-Id: <6ugmlv$fqs$1@nnrp1.dejanews.com>
In article <360BA66C.8835690C@tritechnet.com>,
Eric Von Zee <evonzee@tritechnet.com> wrote:
> I'll answer each question in turn...
>
> Timmins wrote:
>
> > Looks to me like you're as confused as the other guy (note the 'two' above)
> > ... so answer the question: Where does this 'BEGIN' block go?
>
> At the head of his Perl script. It's a way of blocking the initialization
> stuff at the beginning of the script. Observe.
My point, and I think you know this, is that he already has access to the
cgi-bin (or where ever the web server is looking for cgi programs), since
he has a cgi script there that is calling cgi-lib.pl.
> > Why not just put the cgi-lib.pl file in the same directory as the perl
> > script that is calling it, since the web server already knows where
> > this file is at?
>
> Because he doesn't want to.
How do you know he doesn't want to? It sounded to me like he just didn't
know what to do:
<original post> I know this sounds stupid, but I'm entirely new to PERL
programming in general. I want to know where to put the cgi-lib.pl file ...
</original post>
"I want to know where ..." ne "I don't want to ..."
> Besides, the web server has nothing to do with where Perl looks for
> an included script. Perl looks for 'require'd files in the @INC
> array. Exclusively.
Yes, and the current directory (represented by '.') is always in @INC .
See below.
> > The web server setup will determine where the server looks for CGI activated
> > programs, whether they are Perl scripts or not. So, as I said before:
>
> True, before Perl is invoked. Once inside Perl, though, Perl alone decides
> where to find other Perl scripts.
Yes, but Perl always knows to look in the directory it is already in.
'.' is in @INC, you know! see the @INC documentation in perldoc perlvar,
or try this:
foreach $dir (@INC) { print "$dir\n"; }
Every web server setup I've seen (albeit, not many: 7 or 8) had
cgi-lib.pl in the cgi-bin (or where ever the web server looks). Is this
not, traditionally, the place to put cgi-lib.pl?
In any case, he should get away from cgi-lib.pl if he can, and start using
CGI.pm. Then all of this discussion would be alot more relevant to Perl,
since CGI.pm is a Perl module, and, traditionally, Perl modules are designed
to be used together, and to know where to find each other.
Patrick Timmins
$monger{Omaha}[0]
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: 12 Jul 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 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
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 3825
**************************************