[10597] in Perl-Users-Digest
Perl-Users Digest, Issue: 4190 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Nov 10 14:07:52 1998
Date: Tue, 10 Nov 98 11:01:33 -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 Tue, 10 Nov 1998 Volume: 8 Number: 4190
Today's topics:
Re: PLEASE HELP! (Gord Barentsen)
Re: pwd without backticks? (Sean McAfee)
Re: pwd without backticks? (David B. White)
Re: pwd without backticks? <uri@fastengines.com>
Re: pwd without backticks? (Bart Lateur)
Reading binary data from HTTP body <rkatz@ndsisrael.com>
Re: Reading binary data from HTTP body (Andre L.)
Re: Shared Libs from XS code <dhabersetzer@micron.com>
Re: STANDARD PERL for WIN 95/NT EXECUTABLE (Bernie Cosell)
Re: UDP sockets <dgris@rand.dimensional.com>
Re: unable to write to MS access database...HELP <perlguy@technologist.com>
Want to learm Perl <software@longisland.com>
Re: Want to learm Perl <mikane@shell3.ba.best.com>
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 10 Nov 1998 18:02:37 GMT
From: gpb@ppaolucci.com (Gord Barentsen)
Subject: Re: PLEASE HELP!
Message-Id: <36487f72.957900@news.the-wire.com>
Reni:
Thank you for the reply. I actually stumbled on this shortly
after I posted the code, made the change, and it still doesn't work.
But I am beginning to think that it is more of a server configuration
issue than something within the code itself (unless someone else finds
something wrong with this?). Thanks for your help!
Gord Barentsen
On Sun, 08 Nov 1998 00:59:03 +0100, R. A. Larsen <r_larsen@image.dk>
wrote:
>gpb@ppaolucci.com (Gord Barentsen) wrote:
>>
>> On Fri, 6 Nov 1998 12:11:22 GMT, Brent Michalski
>> <perlguy@technologist.com> wrote:
>> [please include code example]
>
>[most of the code snipped]
>> ------------------------------------------------------------------------
>> HTMLHEAD.PL
>>
>> #!d:\Program Files\sambar41\perl\perl.exe
>>
>> sub HTML_Header
>>
>> {
>> print "\n","<HTML><HEAD>","\n\n";
>> print "<title>",@_,"</title>","\n\n";
>> print "</HEAD>","\n\n";
>>
>> }
>>
>1; # see perldoc -f require
>> #END HTML_Header
>
>'perldoc -f require' gives:
>
> Note that the file will not be included twice under the
> same specified name. The file must return TRUE as the
>look here-------------------------------------^^^^
> last statement to indicate successful execution of any
> initialization code, so it's customary to end such a
> file with "1;" unless you're sure it'll return TRUE
>and here-------^^
> otherwise. But it's better just to put the "`1;'", in
> case you add more statements.
>
>
>I hope this helps.
>
>Reni
------------------------------
Date: Tue, 10 Nov 1998 17:01:22 GMT
From: mcafee@waits.facilities.med.umich.edu (Sean McAfee)
Subject: Re: pwd without backticks?
Message-Id: <Cj_12.5976$fS.19663217@news.itd.umich.edu>
In article <36481571.94FFE19A@dial.pipex.com>,
Dean Darlison <dean_darlison@dial.pipex.com> wrote:
>Stephane Barizien wrote:
>> Might sound a stupid question, but how to I get the current working
>> directory other than with:
>> $cwd = `pwd`;
>> which has the [performance] drawback of invoking a shell?
>in ksh/sh/(bash ?) the current directory is already held in the
>environment variable $PWD
Shells update this variable when the working directory is changed, but
Perl does not. Try this:
perl -le 'print $ENV{PWD}; chdir "/"; print $ENV{PWD};'
Module "Cwd" will do what the original poster wants.
perl -le 'use Cwd; print cwd;'
--
Sean McAfee | GS d->-- s+++: a26 C++ US+++$ P+++ L++ E- W+ N++ |
| K w--- O? M V-- PS+ PE Y+ PGP?>++ t+() 5++ X+ R+ | mcafee@
| tv+ b++ DI++ D+ G e++>++++ h- r y+>++** | umich.edu
------------------------------
Date: 10 Nov 1998 17:01:05 GMT
From: dbwhite@btv.ibm.com (David B. White)
Subject: Re: pwd without backticks?
Message-Id: <729rgh$15ok$1@mdnews.btv.ibm.com>
In article <7290th$ier1@janus.ocegr.fr>,
"Stephane Barizien" <NOSPAM.stephane.barizien@ocegr.fr> writes:
> Might sound a stupid question, but how to I get the current working
> directory other than with:
> $cwd = `pwd`;
try executing: perldoc Cwd
or see page 386 in "Programming Perl, Second Edition"
--
David B. White
IBM Microelectronics, Circuit Verification & Design Tools
Internal: dbwhite@btv Internet: dbwhite@vnet.ibm.com
Phone: 802-769-5671 (TieLine: 446) Fax: 802-769-5722
------------------------------
Date: 10 Nov 1998 12:20:01 -0500
From: Uri Guttman <uri@fastengines.com>
Subject: Re: pwd without backticks?
Message-Id: <sarww53a2im.fsf@camel.fastserv.com>
>>>>> "DD" == Dean Darlison <dean_darlison@dial.pipex.com> writes:
DD> Stephane Barizien wrote:
>> Might sound a stupid question, but how to I get the current working
>> directory other than with:
>>
>> $cwd = `pwd`;
>>
>> which has the [performance] drawback of invoking a shell?
>>
1st try
DD> in ksh/sh/(bash ?) the current directory is already held in the
DD> environment variable $PWD
DD> in csh/tcsh I think it is $cwd
2nd try:
DD> Whoops.
DD> forgot to add:
DD> print "Current dir : ", $ENV{'ENV'}, "\n";
Ding! Ding! Ding!
you win the prize for 2 incorrect answers in a row!
the original question was how to do it in perl and you answered with
shell stuff. then you (in)corrected yourself with an unknown ENV
value. and you can't depend on the type of shell being run to get $PWD
or some other ENV value.
the correct answer to get cwd in perl is:
use Cwd ;
$cwd = cwd ;
hth,
uri
--
Uri Guttman Fast Engines -- The Leader in Fast CGI Technology
uri@fastengines.com http://www.fastengines.com
------------------------------
Date: Tue, 10 Nov 1998 17:58:09 GMT
From: bart.mediamind@ping.be (Bart Lateur)
Subject: Re: pwd without backticks?
Message-Id: <36487e74.352014@news.ping.be>
Uri Guttman wrote:
>the correct answer to get cwd in perl is:
>
>use Cwd ;
>
>$cwd = cwd ;
Too bad we need the "use Cwd". I think that cwd should have been a Perl
primitive. Oh well.
Bart.
------------------------------
Date: 10 Nov 1998 15:38:23 GMT
From: "Ron Katz" <rkatz@ndsisrael.com>
Subject: Reading binary data from HTTP body
Message-Id: <01be0cc1$00450fa0$c1040a0a@rkatz.ilndc.com>
Hi,
I am reading an HTTP response using straight PERL (no modules).
If the data is ASCII I can read the headers and then the message using
standard angle bracket read from the socket e.g. $variable =<$sock>;
When the message body is binary, I am reading the headers using angle
brackets, and then switching to sysread for the body. However, this is not
working.
I see in the book that it is not good to combine reads and sysreads on the
same
filehandle.
Any ideas how I can read the HTTP binary data ?
thanks,
Ron
rkatz@ndsisrael.com
------------------------------
Date: Tue, 10 Nov 1998 13:20:57 -0500
From: alecler@cam.org (Andre L.)
Subject: Re: Reading binary data from HTTP body
Message-Id: <alecler-1011981320570001@dialup-547.hip.cam.org>
In article <01be0cc1$00450fa0$c1040a0a@rkatz.ilndc.com>, "Ron Katz"
<rkatz@ndsisrael.com> wrote:
> [...] Any ideas how I can read the HTTP binary data ?
Are you working in Windows, by any chance? In this case, you need
binmode() to read/write binary data.
Andre
------------------------------
Date: Tue, 10 Nov 1998 09:52:05 -0700
From: Daryl Habersetzer <dhabersetzer@micron.com>
Subject: Re: Shared Libs from XS code
Message-Id: <36486F35.D3BFAE22@micron.com>
kellyj@advtech.uswest.com wrote:
>
> I have got some shared libraries for which I want to write an XS extension
> (OS=Linux,CC=gcc). I have everything working, except
>
> Can anybody tell me how perl finds external *.so files > > from extensions?
You need to push the path on to @INC in a begin block.
--
Daryl Habersetzer, DRAM Product Engineer
Micron Technology, Inc.
Phone : (208) 368-4835
Fax: (208) 368-4495
http://www.micron.com
------------------------------
Date: Tue, 10 Nov 1998 16:04:17 GMT
From: bernie@fantasyfarm.com (Bernie Cosell)
Subject: Re: STANDARD PERL for WIN 95/NT EXECUTABLE
Message-Id: <3648638b.217196720@news.swva.net>
lr@hpl.hp.com (Larry Rosler) wrote:
} [Posted to comp.lang.perl.misc and copy mailed.]
}
} In article <74S2oLPZUkB@link-n-j.poehlmann.link-n.cl.sub.de> on 08 Nov
} 1998 00:00:00 +0000, Johannes Poehlmann <j.poehlmann@link-n.cl.sub.de>
} says...
} > (Weekly posting to comp.lang.perl.misc and de.lang.perl)
} >
} > _Where to find the *STANDARD* windows 95/NT port of perl (binary) ?_
} >
} > (The "standard" has a number of advantages over Microsoft's "Activeware"
} > port. E.g. you can install perl modules not contained in the binary
} > distribution. As long as these Modules do not use C-code you do not need a C-
} > compiler )
}
} This material is 15 months old. I have found the ActivePerl port of
} 5.005_02 (available for free at <URL:http://www.activestate.com>) to be
} quite robust. Is there any reason why that should not be the perl of
} choice today for Win32?
Actually, it is "older" than that, since the world moves on. A trip to the
activestate web site reveals:
> November 4, 1998 Gurusamy Sarathy, leading developer and contributer to the
> Open Source Community, has come to Vancouver to join the development team
> at ActiveState.
So I think it is safe to assume that development of the "Standard" version
has stopped.
/Bernie\
--
Bernie Cosell Fantasy Farm Fibers
bernie@fantasyfarm.com Pearisburg, VA
--> Too many people, too few sheep <--
------------------------------
Date: 10 Nov 1998 10:30:17 -700
From: Daniel Grisinger <dgris@rand.dimensional.com>
Subject: Re: UDP sockets
Message-Id: <m3k913foba.fsf@rand.dimensional.com>
Austin Plunkett <austinp@headland.co.uk> writes:
> Hi. First timer, so go easy :)
Ok.
> I'm wondering how to go about coding a client/server style thing in Perl
> using UDP connections.
I'm sure somebody else will point this out, but UDP is a
connectionless protocol.
> **All** the documentation I can find anywhere
> goes into TCP in depth, but tells me very little about UDP. I'm new to
> this sort of thing, so I'm also curious about all the PF_INET, PF_UNIX,
> AF_INET etc variables.. is there a comprehensive list of all of these
> and what they do? I know they equate to numbers, and I gather they
> relate to the platform, but which is for what purpose?
For perl specific information check out perlipc and the docs
included with most of the Net::* modules.
For more general information, including detailed descriptions of
all common protocols, purchase _Unix Network Programming_ vols 1
and 2 (3 is coming, but last time I was at the bookstore it
hasn't yet been released) by Richard Stevens. All of the examples
are in C, but translating to perl isn't particularly difficult.
(Also, given that perl itself is written in C, it will help your
perl capabilities a great deal to be fluent in C (some might even
say that true perl mastery is impossible without knowing C, I'd
agree with them))
> What I'm trying to create is a packet-parser/-forwarder, so anything
> anyone can tell me about this sort of thing would be useful. I'm
> assuming I'm going to have to fork the process to get the client and
> server talking? Can anyone give me a brief introduction to forking?
fork() is the only way that new processes are ever created in
Unix[0]. When fork() is called it creates a new process, called
the child, and both child and parent continue execution with the
statement following the call to fork(). You can tell whether
the parent or child is executing by checking the return value
from fork(). It returns 0 to the child and the PID of the child
to the parent. For example-
my $pid = fork(); # create a new process
if ($pid) { # we have a $pid, this is the parent process
do_parent_stuff();
}
else { # $pid isn't set, this is the child
exec('some_other_process');
}
In the above example, after the call to fork() the parent has
the child's PID in $pid and the child has 0 in $pid. Both
processes then continue execution at if($pid) and both processes
execute the remainder of the program normally until they crash,
die(), exit(), or exec(). You control what each process does
by checking whether it is the parent or the child.
There are several things to be aware of when fork()ing. The
parent's entire current environment will be available to the
child. This includes variables, filehandles, sockets, input
and output buffers, and access permissions. You can run into
some really bizarre and hard to locate bugs because of
unflushed buffers, it's usually best to explicitly flush
all of your filehandles before forking.
For more details check out the somewhat misnamed _Advanced
Programming in the Unix Environment_, also by Richard Stevens
(wow, I feel like an Addison-Wesley salesman this morning :-).
> Perl5 on Slackware Linux.. can't check precise versions at the moment.
Shouldn't matter. Things like network protocols and fork()
semantics are essentially written in stone (I can't begin to
imagine the amount of code that would break if UDP or fork()
were to be changed).
HTH.
dgris
0- To be precise, this isn't entirely true. init and
kswapd aren't started by fork(), but they're special.
--
Daniel Grisinger dgris@rand.dimensional.com
Supporter of grumpiness where grumpiness is due on clpm.
perl -Mre=eval -e'$_=shift;;@[=split//;;$,=qq;\n;;;print
m;(.{$-}(?{$-++}));,q;;while$-<=@[;;' 'Just Another Perl Hacker'
------------------------------
Date: Tue, 10 Nov 1998 17:22:41 GMT
From: Brent Michalski <perlguy@technologist.com>
Subject: Re: unable to write to MS access database...HELP
Message-Id: <36487661.62EF0201@technologist.com>
Instead of:
> $sql = "INSERT INTO form ('lastname') VALUES ('Smith');";
Try:
$sql = "INSERT INTO form (lastname) VALUES ('Smith')";
It works on my system...
Good luck!
Brent
--
Java? I've heard of it, it is what I drink when I am hacking Perl. -me
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$ Brent Michalski $
$ -- Perl Evangelist -- $
$ E-Mail: perlguy@technologist.com $
$ Resume: http://www.inlink.com/~perlguy $
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
------------------------------
Date: Tue, 10 Nov 1998 11:14:35 -0500
From: "Richy" <software@longisland.com>
Subject: Want to learm Perl
Message-Id: <729on0$5q5$1@supernews.com>
I am very interested in learning the perl language and am looking for an
online tutorial like sun has for JAVA. If you know of anything like this
please let me know
Richy
------------------------------
Date: 10 Nov 1998 18:31:45 GMT
From: <mikane@shell3.ba.best.com>
Subject: Re: Want to learm Perl
Message-Id: <36488691$0$12767@nntp1.ba.best.com>
Richy,
I realize that reading something online would be free, but please consider
buying a book instead. My first Perl book was 800+ pages, "Teach Yourself
Perl in 21 Days" by David Till.
Mike Landeros
MLD
Novato, CA
Richy <software@longisland.com> wrote:
: I am very interested in learning the perl language and am looking for an
: online tutorial like sun has for JAVA. If you know of anything like this
: please let me know
: Richy
------------------------------
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 4190
**************************************