[6963] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 588 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jun 8 16:17:18 1997

Date: Sun, 8 Jun 97 13:00:21 -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           Sun, 8 Jun 1997     Volume: 8 Number: 588

Today's topics:
     Re: any editor for perl? (Gordon D. Pusch)
     Re: Bizarre error <rootbeer@teleport.com>
     Re: filehandle problem (Andrew M. Langmead)
     Re: Help for "date" <dean@tbone.biol.sc.edu>
     Re: how to make a script executable on DOS (Andrew M. Langmead)
     Re: how to make a script executable on DOS <dada@divinf.it>
     localtime(time) yelds year 97, not 1997. In all realiza (PAF)
     Re: localtime(time) yelds year 97, not 1997. In all rea <dean@tbone.biol.sc.edu>
     Re: Parsing Comma Delemited Text DataBase--RTF (Jahwan Kim)
     Re: perl reconnecting PPP <rootbeer@teleport.com>
     Re: Reading one char at a time? <dean@tbone.biol.sc.edu>
     Re: Reading one char at a time? (Andrew M. Langmead)
     Re: Refs to globs (Charles DeRykus)
     Sockets in Perl (Ken Ficara)
     Re: sockets select() problem <rootbeer@teleport.com>
     Re: String Compare Problem (Chipmunk)
     Re: trace mode - ksh equivalent of -x <rootbeer@teleport.com>
     UUencoding between UNIX and PC - newlines (Matthew Burnham)
     Re: Windows 3.1 / Perl 4 or 5 <dean@tbone.biol.sc.edu>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: 08 Jun 1997 13:36:59 -0500
From: pusch@mcs.anl.gov (Gordon D. Pusch)
Subject: Re: any editor for perl?
Message-Id: <phbu5hj60k.fsf@xanadu.mcs.anl.gov>

In article <5n459g$1ie$1@mainsrv.main.nc.us>
scott@lighthouse.softbase.com (Scott McMahan) writes:

> Monty Scroggins (Monty@dhc.net) wrote:
>
> : Vi is really old and nauseating...
>
> Vi is still around because they got it right the first time and
> nothing better has come along. (Emacs is just a bloated vi clone! :))

As far as *I'm* concerned, they got everything =WRONG= the first time.

Each and =EVERY= ``feature'' of `vi` behaves exactly the =OPPOSITE=
of rationaly; it =ALWAYS= makes me want to throw the @#&$%$# terminal
through the nearest window after at _most_ fifteen keystrokes, because
the ferschlugginer thing =NEVER= does what I expect !!!

I consider vi's name to be =remarkable= apt --- it makes me quite
=VIolent= each and =EVERY= time I'm _forced_ to use it (because it's
the only @$##^%# editor on the @$##^%# system). Therefore, as a matter
of policy, I now =REFUSE= contracts from ANY customer who won't provide me 
with a gnu-Emacs working environment...


--  Gordon D. Pusch   <pusch@mcs.anl.gov>

Disclaimer:  I'm a consultant collaborating with Argonne researchers;
I don't speak for ANL or the DOE --- and they *certainly* don't speak
for =ME= !!!


------------------------------

Date: Sun, 8 Jun 1997 11:06:30 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Gene Johannsen <gej@spamalot.mfg.sgi.com>
Subject: Re: Bizarre error
Message-Id: <Pine.GSO.3.96.970608110305.19852D-100000@kelly.teleport.com>

On 8 Jun 1997, Gene Johannsen wrote:

> I got this error from a script:
> 
>     Bizarre copy of CODE in leavesub at /usr/asrs/mack.pl line 514

This means that something went wrong internally in Perl (or in an
extension which was linked into it). Are you using a version prior to
5.004, or are you using any new extensions which aren't fully debugged?
Based upon the evidence, I'd guess that the answer is yes. :-) 

It's not unlikely that you've found a new bug which the Perl development
team would like to know about. If you can reproduce this problem in some
small test code with Perl 5.004, run perlbug to submit it. Thanks! 

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/



------------------------------

Date: Sun, 8 Jun 1997 14:15:31 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: filehandle problem
Message-Id: <EBGnLv.IF3@world.std.com>

tranhu@JSP.UMontreal.CA (TRAN Huu Da) writes:

>It's not possible to pass a filehadle to a parent process because when the
>child dies, the filehandle is closed. But it is possible to pass
>filehandle from the parent to the child. Using

It isn't so much to do with the filehandle closig when the child
dies. Its a basic part of Unix security. The parent process can make
changes to its own environment, and a child can inheret those changes,
but a child can not effect the parent process. (Imagine if your login
shell could effect what the login(1) program did.)

>	pipe($readhandle,$writehandle)
>or
>	select($rin, $win, $ein, $timeout);

>but I couldn't make the latter work when forking multiple children. I
>posted a question but, due to lack of knowlage in Perl5, I just can't make
>it work. :-(((  Which, BTW, I ould need to but rather use the pipe() for
>now.

pipe() creates two new filehandles, when one writes to one, data is
available to be read by the other. select() takes a list of
filehandles, and returns as soon as the status of a filehandle changes
(a filehandle opened for reading has more data to read, or a
filehandle opened for writing has more room.)

If you want multiple children to write to their parent what you want
to do is:

For each child:
In the parent, use pipe() to create two new filehandles.
In the parent, fork().
In the parent, close the writing filehandle.
In the child, close the read filehandle.
(optionally: In the child, close STDOUT and reopen STDOUT on the write 
filehandle)
Child does its stuff.

When all the children are fork()ed, the parent makes a bitmask of all
the read filehandles it has created, and uses select() to get data
from whichever child has data available.
-- 
Andrew Langmead


------------------------------

Date: 08 Jun 1997 13:42:27 -0400
From: Dean Pentcheff <dean@tbone.biol.sc.edu>
Subject: Re: Help for "date"
Message-Id: <m14tb9at4s.fsf@nauplius.psc.sc.edu>

Petri Backstrom <petri.backstrom@icl.fi> writes:
> Jun Zhuang wrote:
> > Under UNIX prompt, enter "date" will get : Mon Jun 2 13:45:34 CDT 1997
> > Is there a similar function in PERL? What if I only want digits of the
> > date? i.e. I want 970602 instead of Jun 2 1997?
> > Any help will be appreciated.
> 
> See your Perl documentation (if you don't have it, start
> with http://www.perl.com/perl/) for what they say about
> the functions 'time' and 'localtime' (to be more exact,
> look in the 'perlfunc' part of the Perl docs).
> 
> See also the Perl Frequently Asked Questions list at:
> 
>     http://www.perl.org/CPAN/doc/FAQs/FAQ/html/

Even easier, see the Date::Format module, or the strftime() function
within the POSIX module (which comes standard with Perl).  For the
Date::Format module, see the CPAN network at
<URL:http://www.perl.org/CPAN>.

-Dean
-- 
N. Dean Pentcheff   <pentcheff@acm.org>   WWW: http://tbone.biol.sc.edu/~dean/
Biological Sciences, Univ. of South Carolina, Columbia SC 29208 (803-777-3936)
PGP ID=768/22A1A015 Keyprint=2D 53 87 53 72 4A F2 83  A0 BF CB C0 D1 0E 76 C0 
Get PGP keys and information with the command: "finger dean@tbone.biol.sc.edu"


------------------------------

Date: Sun, 8 Jun 1997 00:46:55 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: how to make a script executable on DOS
Message-Id: <EBFM67.Lv9@world.std.com>

Larry D'Anna <ldanna@ix.netcom.com> writes:

>Does anyone know how to make a pearl script executable on a dos machine?
>Thanks in advance.

One way is the hbperl utility
<http://www.perl.com/CPAN/ports/msdos/tips-tricks/hbp_30.zip> Another
is to wrap the perl script inside a batch file. The older DOS versions
had instructions in their documentation on how to do this, the
Activeware Perl port, comes with a PL2BAT program that does it for
you.
-- 
Andrew Langmead


------------------------------

Date: Sun, 08 Jun 1997 18:41:41 +0200
From: Aldo Calpini <dada@divinf.it>
To: Larry D'Anna <ldanna@ix.netcom.com>
Subject: Re: how to make a script executable on DOS
Message-Id: <339AE0C5.14EF9431@divinf.it>

Larry D'Anna wrote:
> 
> Does anyone know how to make a pearl script executable on a dos
> machine?
> Thanks in advance.

The ActiveWare port of Perl comes with a PL2BAT utility that turns 
(better said, embeds) a script into a .BAT file that you can execute
from DOS. There is also an improved version called BATWRAP somewhere...
HTH.

Bye,
Aldo Calpini
---/\-----------------------------------------------------------
--/  \--------------------------------- mailto:dada@divinf.it --
-<dada>-- POPULUS VULT DECIPI, -------- mailto:sis@divinf.it ---
--\  /------- ERGO DECIPIATUR --------- http://sis.divinf.it ---
---\/-----------------------------------------------------------


------------------------------

Date: 8 Jun 1997 16:53:18 GMT
From: "Alexander Petrosyan (PAF)" <paf@i-connect.ru>
Subject: localtime(time) yelds year 97, not 1997. In all realizations?
Message-Id: <01bc742c$5279d370$08c8c8c8@paf>

That's true for 5.001NT port, and, as far as I've heard for 5.004 unix.

Why?
What whould be when in 2000?


-- 
Alexander Petrosyan, Moscow.
email: paf@i-connect.ru, paf@fbit.msk.su
phone: +7(095)535-2222


------------------------------

Date: 08 Jun 1997 13:51:48 -0400
From: Dean Pentcheff <dean@tbone.biol.sc.edu>
Subject: Re: localtime(time) yelds year 97, not 1997. In all realizations?
Message-Id: <m1206dasp7.fsf@nauplius.psc.sc.edu>

"Alexander Petrosyan (PAF)" <paf@i-connect.ru> writes:
> That's true for 5.001NT port, and, as far as I've heard for 5.004 unix.
> 
> Why?
> What whould be when in 2000?

Read the documentation.  The year is returned as the (year-1900).  And
no, there is no Year2000 Problem with that: just don't assume that the
returned value will always be two digits long.

-Dean
-- 
N. Dean Pentcheff   <pentcheff@acm.org>   WWW: http://tbone.biol.sc.edu/~dean/
Biological Sciences, Univ. of South Carolina, Columbia SC 29208 (803-777-3936)
PGP ID=768/22A1A015 Keyprint=2D 53 87 53 72 4A F2 83  A0 BF CB C0 D1 0E 76 C0 
Get PGP keys and information with the command: "finger dean@tbone.biol.sc.edu"


------------------------------

Date: 8 Jun 1997 16:49:14 GMT
From: jahwan@supernova.math.lsa.umich.edu (Jahwan Kim)
Subject: Re: Parsing Comma Delemited Text DataBase--RTF
Message-Id: <slrn5ploka.53g.jahwan@supernova.math.lsa.umich.edu>

On Sun, 08 Jun 1997 10:57:19 -0400, 
    Nasser Al-Zawawi <nzawawi@worldnet.att.net> wrote:
[snip]

Read the FAQ.

Jahwan



------------------------------

Date: Sun, 8 Jun 1997 10:58:20 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Murray Stokely <murray@southeast.net>
Subject: Re: perl reconnecting PPP
Message-Id: <Pine.GSO.3.96.970608105426.19852B-100000@kelly.teleport.com>

On 8 Jun 1997, Murray Stokely wrote:

>     I have a internet perl5 script that I run regularly on both NT and
> FreeBSD boxes.  The problem is that this program takes HOURS to run
> (though with very little cpu usage) and my ISP often disconnects me for
> no real reason. 

Maybe your ISP doesn't like people to be connected for hours for no real
reason. :-) 

> So, I was wondering if it was possible to have my perl script
> detect if the PPP link was still active, and if not, re-initiate it. 

The script is running on your own machine, not your ISP's machine? Then it
could call ifconfig to see whether the link is up, and run another command
to start it if it's not. (I don't know whether there's an equivalent to
ifconfig for NT machines, but you should be able to ping some remote sites
and see whether any of them answers, at least.) 

Having said that, what does this have to do with Perl? You could write the
same script in nearly any other language. Maybe you should have sent this
question to a different newsgroup.

Hope this helps!

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/



------------------------------

Date: 08 Jun 1997 13:49:10 -0400
From: Dean Pentcheff <dean@tbone.biol.sc.edu>
Subject: Re: Reading one char at a time?
Message-Id: <m13eqtastl.fsf@nauplius.psc.sc.edu>

Ian Rawlings <ian@tarcus.demon.co.uk> writes:
> I wanted to create an interactive perl script that would respond to
> single key-presses. I used the character reading functions on stdin,
> completely forgetting that stdin only presents keyboard input after
> return has been pressed. Is there another way to do this?

Check out Term::ReadKey (get it via CPAN starting at
<URL:http://www.perl.org/CPAN>):

Module id = Term::ReadKey
    DESCRIPTION  Read keystrokes and change terminal modes
    CPAN_USERID  KJALB (Kenneth Albanowski)
    CPAN_VERSION 2.07
    CPAN_FILE    KJALB/TermReadKey-2.07.tar.gz
    DSLI_STATUS  Rdcf (released,developer,C,functions)

Enjoy!

-Dean
-- 
N. Dean Pentcheff   <pentcheff@acm.org>   WWW: http://tbone.biol.sc.edu/~dean/
Biological Sciences, Univ. of South Carolina, Columbia SC 29208 (803-777-3936)
PGP ID=768/22A1A015 Keyprint=2D 53 87 53 72 4A F2 83  A0 BF CB C0 D1 0E 76 C0 
Get PGP keys and information with the command: "finger dean@tbone.biol.sc.edu"


------------------------------

Date: Sun, 8 Jun 1997 14:38:48 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Reading one char at a time?
Message-Id: <EBGooo.6x9@world.std.com>

Ian Rawlings <ian@tarcus.demon.co.uk> writes:

>I wanted to create an interactive perl script that would respond to
>single key-presses. I used the character reading functions on stdin,
>completely forgetting that stdin only presents keyboard input after
>return has been pressed. Is there another way to do this?

Setting terminal driver modes is an operating system dependent
function. For some guidence, take a look at this entry in the FAQ:

<URL:http://www.perl.org/CPAN/doc/manual/html/pod/perlfaq5/How_can_I_read_a_single_characte.html>

As it says, you may want to look at getting the Term::ReadKey module
<URL:http://www.perl.com/cgi-bin/cpan_mod?module=Term::ReadKey>

-- 
Andrew Langmead


------------------------------

Date: Wed, 4 Jun 1997 18:52:33 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Refs to globs
Message-Id: <EB9LrM.8so@bcstec.ca.boeing.com>

In article <m7g3eqzyx5c.fsf@ux8.cso.uiuc.edu>,
gregory douglas fast  <g-fast@ux8.cso.uiuc.edu> wrote:
 > In an attempt to create an object-thingie that acted simultaniously
 > like a class and a filehandle, I saw a suggestion that one use a glob
 > reference to store both the filehandle and the hash containing the
 > class's info in the same blessed reference.  So I did this:
 > 
 > package Poo:
 > ...
 > sub new {
 >    my $type = shift;
 >    my $class = ref($type) || $type;	
 >    open(GLOB, "stupidfile") || die "can't open $filename";
 >    $GLOB{FILE} = "stupidfile";
 >    bless \*GLOB,$class;
 > }	
 > 
 > which works in a filehandle-y sense:
 > 
 > $a = new Poo;
 > while(<$a>) { ...   # works a-ok
 > 
 > ...but which breaks the hashy part: '$a->{FILE}' gives me a
 > "Not a HASH reference" error.
 > 
 > while I can do a '*blah = $a; print $blah{FILE};', that's kinda
 > clunky, it can't be my-ed, etc.  Is there a better way to do this?  Or
 > would I be better off trying to find a way to bend <> to my will


Evidently, glob refs don't like being referred to like a hash :)


Maybe, you could add a method, e.g.,

sub Filename { my $obj = shift; $GLOB{FILE} or undef };


Then just substitute $a->Filename.


HTH,
--
Charles DeRykus
ced@carios2.ca.boeing.com


------------------------------

Date: 8 Jun 1997 12:26:27 -0400
From: ficara@panix.com (Ken Ficara)
Subject: Sockets in Perl
Message-Id: <5nemfj$9qu@panix3.panix.com>
Keywords: Sockets perl server client

I have written a server and client in perl (5.003 on Solaris 2.4) basically
using the skeleton server/client pair in the Sockets section of the Camel 
book (p 348 of the second, ie blue, edition).

They work fine together; if I start the server, then start the client, the 
client sends data to the server, the server does its work, and everyone is
happy.

I'm using a specific high-numbered port for the two of them to connect on.

If the server is NOT running, my client starts up fine. All the various
socket calls including socket() itself act like they're working fine -- 
even though there's no server to connect to.

Then, when the client tries  to print to the socket filehandle, it quits
immediately. 

I don't understand this, twice in fact. Once, why it opens the socket 
without returning an error even though there's no server to connect to.
Twice, why print () just quits without any message or without returning
an error.

thanks for any help.

Ken

-- 
==============================================================================
Ken Ficara                                                      ficara@acm.org


------------------------------

Date: Sun, 8 Jun 1997 11:01:05 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Ruben Mendes <etruben@ci.ua.pt>
Subject: Re: sockets select() problem
Message-Id: <Pine.GSO.3.96.970608105946.19852C-100000@kelly.teleport.com>

On 8 Jun 1997, Ruben Mendes wrote:

> I call select() to block until one of two socket descritors is ready for
> _reading_ . In C it works fine because it returns as soon as there is
> one byte to be read.
> It seems that in Perl the select() returns only when some buffer is full.

I don't think there's actually a difference between the behaviors of Perl
and C here. Maybe the sockets are buffered from sender's side. But there's
nothing Perl can do about that.

Hope this helps!

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/



------------------------------

Date: 8 Jun 1997 18:53:30 GMT
From: Ronald.J.Kimball@dartmouth.edu (Chipmunk)
Subject: Re: String Compare Problem
Message-Id: <5nev3a$krt$1@dartvax.dartmouth.edu>

In article <ipaen5.fm.ln@localhost>
tadmc@flash.net (Tad McClellan) writes:

> Chipmunk (Ronald.J.Kimball@dartmouth.edu) wrote:
> 
> : For the perlre manpages:
> 
> :      By default, the "^" character is guaranteed to match only at the
> :      beginning of the string, the "$" character only at the end (or
> : before
> :      the newline at the end)
> 
> : In order to make ^ and $ match at the beginning/end of a line, you need
> : to use the /m modifier.
> 
> In order to make ^ and $ match at the beginning/end of a line
> *in a multiline string*, you need to use the /m modifier.

Now you're just splitting hairs.

> 
> ----------------------
> #! /usr/bin/perl -w
> 
> $_ = 'Ronald Kimball';
> 
> print "matched\n" if /^Ron/; # no 'm' here, matches beginning of line just fine
> ----------------------

It matched 'beginning of line' just fine because the beginning of the
line *is* the beginning of the string in this case.

If you want ^ to explicitly match the beginning of a line, you need to
use the /m modifier.  Otherwise, it will only match at the beginning of
the string.

> The /m modifier has no effect if you are only matching against
> single line strings.

Obviously.

Chipmunk


------------------------------

Date: Sun, 8 Jun 1997 11:08:37 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Zeev Gross <zev@telaviv.ndsoft.com>
Subject: Re: trace mode - ksh equivalent of -x
Message-Id: <Pine.GSO.3.96.970608110743.19852E-100000@kelly.teleport.com>

On Sun, 8 Jun 1997, Zeev Gross wrote:

> Does any one know if there is a way to execute a standard perl script in
> trace mode as in ksh -x switch. 

Maybe you want the perl debugger. See perldebug(1).

> I need to be able to distinguish between a command statement and its
> output. 

The output is what's printed. :-)

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/



------------------------------

Date: Sun, 08 Jun 1997 16:19:23 GMT
From: danew@enterprise.net (Matthew Burnham)
Subject: UUencoding between UNIX and PC - newlines
Message-Id: <33b4b1c2.7385118@194.72.192.4>

I have a script that uuencodes a file and emails it off somewhere,
unfortunately the output is mangled so that the newlines aren't right.
How can I make it work!

This is an extract from the script:

if (-e $filename)
{
	open(FILE, "<$filename");
	while(<FILE>)
	{
		$sendMsg = $sendMsg . $_;
	}
	close(HELP);

	$sendMsg = "begin 644 $filename\n" . pack("u", $sendMsg) .
"end\n";

	$sendTo = $from;
	#$sendFrom = $to;
	$sendFrom = "jamie\@enterprise.net";
	$sendSubject = $subject;
	&sendmail;
	exit;
}
else
{
	$sendMsg = "The file you requested does not exist.\n";

	$sendTo = $from;
	#$sendFrom = $to;
	$sendFrom = "jamie\@enterprise.net";
	$sendSubject = $subject;
	&sendmail;
	exit;
}

sub sendmail
{
	open(MAIL,"$mailprog");
	print MAIL "To: $sendTo\n";
	print MAIL "From: $sendFrom\n";
	print MAIL "Subject: $sendSubject\n\n";	# last header line
therefore \n\n

	print MAIL "$sendMsg\n\n";
	print MAIL "$advert\n\n";
	close (MAIL); # send
}


TIA


-- 
Matthew Burnham, Manager, MindWeb | danew@enterprise.net
Commercial web design and hosting, reasonable rates
UKP24/Mb/Year for DIY space | mindweb@pobox.co.uk
FTP, CGI, password protection, etc. too!
http://www.virtual-pc.com/mindweb/


------------------------------

Date: 08 Jun 1997 13:39:10 -0400
From: Dean Pentcheff <dean@tbone.biol.sc.edu>
Subject: Re: Windows 3.1 / Perl 4 or 5
Message-Id: <m167vpata9.fsf@nauplius.psc.sc.edu>

cgsystem@dircon.co.uk (Zac) writes:
> I have read a mountain of information regarding Perl but nothing seems
> to address my confusion. I am a 486 / Windows 3.11 user, and have
> never seen a Unix Operating System.

A shame...  If you're curious (though it is certainly not necessary
for what you're trying to achieve), you could experiment with Unix by
downloading and installing the free Unix-compatible system "Linux".
It's an excellent version of Unix.  It has its own native file system
(which would imply wiping your disk clean to use it), but it can also
run atop DOS/Windows file systems.  I've installed this version
several times with great success - it won't run as efficiently as
using the native Linux filesystem, but it gives you a way to install
and run Linux within your DOS filesystem if you'd like to experiment.
Just because I'm familiar with it, I'd recommend the Slackware
distribution of Linux.  To install within a DOS system, you'll be
looking for the "UMSDOS" filesystem installation.  To pursue this
further, check out <URL:http://www.linux.org>.

Now, back to our regularly scheduled rambling...

> I understand that I can write a perl script in pure text (in Windows,
> Notepad for example) and upload it to a CGI directory, and it would
> run.
> 
> Is that correct?

Yes.  

> Other information (book: "60 Minute Guide to CGI programming with Perl
> 5" by Robert Farrell) seems to suggest that Even though I am a windows
> 3.11 user, I will still need to download a programme called Perl 5.

You will if you'd like to run the program (or script, or whatever
you'd like to call it) on your own machine prior to uploading it to
your ISP's Unix box, or if you'd like to use Perl for anything other
than CGI programming.

> If Perl is a pure text language, why do I need a Programme which I
> presume is a compiler of some sort. If I then find this programme and
> am able to run it on my Windows 3.11 operating system, will it still
> run on my Service Providers Unix Platform.

Well... in that sense, C, BASIC, COBOL, and Fortran are pure text
languages, too: you write the program in a textual form.  The next
step, however, involves a specialized computer program to read your
text and do something interesting with it.  Perl stands somewhere in
between purely interpreted languages (typified by BASIC) and purely
compiled languages (like C or Fortran).  Perl rapidly compiles your
textual program into an internal represenation every time the program
is run.  It compiles so quickly that, in general, you don't even
notice that it's doing so - to the observer, it looks as though the
Perl program instantly interprets and runs the Perl program with which
it's supplied.

However, the implication is that to run a Perl program that you write,
you'll need the Perl compiler/interpreter on your system.  That
program has been ported to numerous computer and operating system
targets, including DOS/Windows.  

The Perl program that you write should run on your local system, and
should also run on your ISP's system - the text you write will be
treated equivalently by both versions of the Perl interpreter.  Now,
that said, CGI programming can be tricky since the program you write
is written assuming that it will be launched by the WWW server with
certain data input or made available by the WWW server.  That can be
difficult to simulate without a WWW server running on your own
machine.  

I'd strongly recommend using Lincoln Stein's CGI.pm Perl module to
help write CGI programs.  It will make your life easier in general,
and also gives you good capabilities to run a CGI program from the
command line on your system, feeding it test data just as though it
were being run by the ISP's WWW server.  

> Would also be grateful to discover where I might find this programme
> that is able to run on Windows 3.11

One of the best ports of Perl for Windows 3.11 is the OS/2 port of
Perl.  Yes, I know that sounds a bit strange, but it's true.  I've
appended a "cheat sheet" on getting the OS/2 port running under
Windows.  It's a bit old, but the basics should still be true
(specific filenames and so forth may have changed by now).  You'll be
able to find the OS/2 port of Perl by starting to look at
<URL:http://www.perl.com/perl>.

> Thanks in advance.

You're welcome - enjoy Perl!

-Dean
-- 
N. Dean Pentcheff   <pentcheff@acm.org>   WWW: http://tbone.biol.sc.edu/~dean/
Biological Sciences, Univ. of South Carolina, Columbia SC 29208 (803-777-3936)
PGP ID=768/22A1A015 Keyprint=2D 53 87 53 72 4A F2 83  A0 BF CB C0 D1 0E 76 C0 
Get PGP keys and information with the command: "finger dean@tbone.biol.sc.edu"

=============================================================================

I recently went through the exercise of hunting for a DOS/Win Perl,
needing to write a Perl program that would run on Unix, DOS 5, and
Windows 95/NT, and be distributable (along with Perl) with a minimum
of fuss.  

I settled on Ilya Zakharevich's OS/2 port of Perl.  Yup.  It will run
on DOS and Windows systems.  It's a very full Perl port that is
aggressively maintained and kept up to date.

You'll need to tinker slightly.  Following is an outline of a recipe
that worked for me.

Grab the port from CPAN.  Start at <URL:http://www.perl.com/perl> and
look for "Software", then "Alien Ports", then "CPAN/ports", and follow
links until you get to OS/2 ports, and then the "ilyaz" directory.
Once there, look for the most recent version in a directory that looks
something like "5.003.05" (of course, that number will change as
versions get updated).  Within that is a set of zip files.  Get these
files:

                perl_aou.zip
                perl_mlb.zip
                perl_pod.zip
                perl_ste.zip
                perl_utl.zip
                plREADME.zip

Make sure you have a decent unzip utility on DOS/Win.  One that works
is Info-Zip's, which you can grab from the "arcers" directory of the
MSDOS section of the Simtel archives at oak.oakland.edu
(<URL:http://oak.oakland.edu/pub/simtelnet/msdos/arcers/unz520x.exe>).
That file will unzip into multiple files, including a good DOS unzip
program.  The reason you need a good one is that you need to unzip
into a tree, and you need to properly truncate long filenames -- that
unzipper seems to do the job properly.

OK, now that you've got the code and an unzipper, do the following to
create a Perl hierarchy (the following manipulation gets done from a
DOS window, if you're under Windows):

        cd \
        mkdir perl
        mkdir perl\bin
        mkdir perl\lib
        mkdir perl\lib\pod

Now unpack the zip files into appropriate directories.  To do that,
change directories to the target directory first, then from there,
unzip the archive files as follows:

        perl
                plREADME.zip
        perl\bin
                perl_aou.zip
                perl_utl.zip
        perl\lib
                perl_mlb.zip
                perl_ste.zip
        perl\lib\pod
                perl_pod.zip

Put the following in your autoexec.bat (carefully noting the slash
directions in the text that follows):

        set path=...your...existing...path...;c:\perl\bin
        set perllib_prefix=f:/perllib c:/perl

(I assume your perl destination is drive "c:", otherwise modify the
"c:"s above appropriately, but don't change the "f:").

===== Note: The following is from Ilya Zakharevich: =====
 As I mentioned it in another post today, unless you install sh.exe
 from sh_dos.zip, and set PERL_SH_DIR according to the docs, you are
 not going to have backticks and pipes working.
=========================================================

Now, based on addresses in Ilya's documentation, go out and grab the
latest versions of the "emxrt" package and the "rsx" package.  Unzip
them under a temporary directory.  Copy the following files to
c:\perl\bin:

        from the emx package:
                emx.exe      [VCPI DOS extender for DOS]
                emxfpemu     [coprocessor emulator for 386sx machines]
                emxbind.exe  [emx executable load-format twiddling program]
                emxl.exe     [emx stub loader module]
        from the rsx package:
                rsx.exe      [DPMI DOS extender for Windows]

Now drop out into DOS if you're running under Windows (not a DOS
shell: if you're in Windows, kill Windows and drop to plain DOS).

Go to the c:\perl\bin directory and use emxbind to extract the a.out
module from perl_.exe, something like:

        emx emxbind.exe -x perl_.exe perl.out

Use emxbind to bind the a.out module with the emxl.exe stub:

        emx emxbind.exe emxl.exe perl.out perl.exe

Assuming that worked, you can now delete the following files:

        emxbind.exe
        emxl.exe
        perl.out
        perl_.exe
        perl5_00.exe

If you're really twitchy about a startup warning message under
Windows, you can use a hex editor or other binary editor to edit the
file "rsx.exe" so that it will not complain about the emx version
you're using.  In the file "rsx.exe", search for the string
"emx_version".  You'll find the emx version number in reverse,
something like: "emx_version=b9.0" (which really refers to emx version
number 0.9b).  Change the version number/letter to fit the emxrt
version you downloaded (in my case, recently, I changed "b9.0" to
"c9.0", which defines me as really twitchy I suppose).  Save the new
rsx.exe (must be in the filename "rsx.exe").  Then the runtime warning
about emx versions will shut up.

Reboot your machine to let the c:\autoexec.bat changes take effect.


What have you achieved by this?  The OS/2 version will run using
either the emx.exe DOS extender (using the VCPI protocol, suitable for
"naked" DOS) or the rsx.exe extender (using the DPMI protocol,
compatible with Windows 3.x, 95 (and NT?)).  The rigamarole with
emxbind pulled out the core executable and rebound it with a stub
loader that will automatically and transparently find and use the
emx.exe extender in plain DOS, and the rsx.exe extender under Windows
(as long as they're in a directory on the PATH).  Setting the
emxlib_prefix variable properly sets Perl's @INC list of where to
search for Perl libraries.

The "utility" programs in \perl\bin are set up as OS/2 "cmd" files.
You'll need to trim off the top few lines that get them to execute
under the OS/2 command interpreter.  There are magical incantations
you can do to turn them into automatically executing DOS batch files
(which I don't know), or you can create a batch file for each of them
(in the same directory) that looks something like the following (for
an example "utility.cmd" file):

@perl -S utility.cmd %1 %2 %3 %4 %5 %6 %7 %8 %9

in the file "\perl\bin\utility.bat".


And that's that!


------------------------------

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 588
*************************************

home help back first fref pref prev next nref lref last post