[6470] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 90 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Mar 11 19:27:52 1997

Date: Tue, 11 Mar 97 16:00:35 -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, 11 Mar 1997     Volume: 8 Number: 90

Today's topics:
     Re: @hash{@fields} = @values; <dbenhur@egames.com>
     Re: All I want to do is subtract 180 days from a given  <rootbeer@teleport.com>
     Re: All I want to do is subtract 180 days from a given  (Mik Firestone)
     Re: All I want to do is subtract 180 days from a given  (Tad McClellan)
     Can you help me with this script? <somebody@somewhere.com>
     Re: Controlling Output from LWP (Paco Hope)
     Convert DECUnix3.2 dbm to Solaris2.5.1 dbm <vmg@novator.com>
     DFD's for perl5 (Ind study)
     filehandles: better way to test existence of? <jewell@halcyon.com>
     Re: help about rpcgen and perl <jake@organic.com>
     Re: Help! Question about reading files (Jim Shapiro)
     How to overwrite a file? (Claudia  Ma)
     Re: How to spam - legitimately (Lee)
     Include perl script in HTML? (Andreas Wostrack)
     Re: Looking for non-Unix Perl book (David Combs)
     matching whitespace? (alex filippenko)
     Re: Need FILE1 copied to FILE2 (minus the spaces, tabs, (michael allen smith)
     Re: Parsing a form with enctype=multipart (John Caligan)
     Perl FAQ part 0 of 0..9: Overview [Periodic Posting] <tchrist@mox.perl.com>
     Perl FAQ part 1 of 0..9: General Questions [Periodic Po <tchrist@mox.perl.com>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Tue, 11 Mar 1997 12:15:24 -0800
From: Devin Ben-Hur <dbenhur@egames.com>
To: Ken Stevens <kstevens@theglobeandmail.com>
Subject: Re: @hash{@fields} = @values;
Message-Id: <3325BD5C.150D@egames.com>

[mailed & posted]
Ken Stevens wrote:
> Say, I've always wondered about this one.  Why does the following work?
> @fields = ('a', 'b', 'c');
> @values = (4, 7, 9);
> @hash{@fields} = @values;
> print $hash{'b'};               # will print "7"
> I've read all the perl docs, and I can't find any reference to this very
> useful syntax.  Is this an undocumented goodie?

It is documented, though it's not as easy to find
as I expected.  See Camel, p.37.

[Heh, Larry, Tom, Randal, you should add an index entry for
"array slices" next time you revise.]

--
Devin Ben-Hur      <dbenhur@egames.com>
eGames.com, Inc.   http://www.egames.com/
eMarketing, Inc.   http://www.emarket.com/
"Sometimes you just have to step in it and see if it stinks"  O-
    -- Sonia Orin Lyris



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

Date: Tue, 11 Mar 1997 12:38:15 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Blake Swensen <blake@pbgi.com>
Subject: Re: All I want to do is subtract 180 days from a given date!
Message-Id: <Pine.GSO.3.96.970311123354.695W-100000@kelly.teleport.com>

On Tue, 11 Mar 1997, Blake Swensen wrote:

> Subject: All I want to do is subtract 180 days from a given date!
> 
> Really... thats all.  User inputs a date, and gets a date 180..0 days
> earlier.

> I have surfed, searched, read FAQs, downloaded, copied, hacked.  Can
> some kind soul give me the necessary nudge.

Sure. First, convert the date to standard format (which is often the
number of seconds since a certain time and date). Then, use the fact that
there are 24 * 60 * 60 seconds per day and subtract. Finally, you can
convert from the standard format to your local time format, or another
format if that's what you'd prefer.

In order to convert time formats, check out the Date modules on CPAN,
which are found in the modules/by-module/Date subdirectory.

    http://www.perl.org/CPAN/
    http://www.perl.com/CPAN/

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: 11 Mar 1997 20:52:02 GMT
From: mfiresto@vnet.ibm.com (Mik Firestone)
Subject: Re: All I want to do is subtract 180 days from a given date!
Message-Id: <5g4gli$oau$1@mail.lexington.ibm.com>

In article <5g48mt$s75$1@nadine.teleport.com>,
Blake Swensen <blake@pbgi.com> wrote:
>Really... thats all.  User inputs a date, and gets a date 180..0 days 
>earlier. 
> 
>
>I have surfed, searched, read FAQs, downloaded, copied, hacked.  Can 
>some kind soul give me the necessary nudge. 
>
>Blake

Find your nearest CPAN archive and install the Date:DateCalc package.  It
should handle most of this, assuming you are working with Perl5 ( not the
"dead flea-bitten camel carcasses" ) and you can actually get said modules
installed.

Htth
-----
Mik Firestone  mfiresto@mindspring.com
Evil Overlord Rule #2: My ventilation ducts will be too small to crawl
through.




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

Date: Tue, 11 Mar 1997 15:10:15 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: All I want to do is subtract 180 days from a given date!
Message-Id: <nnh4g5.143.ln@localhost>

Blake Swensen (blake@pbgi.com) wrote:
: Really... thats all.  

What's all?

Subjects are often truncated by newsreaders.

Put the question in the body please...


: User inputs a date, and gets a date 180..0 days earlier. 
  ^^^^^^^^^^^^^^^^^^

In what format?

Tue Mar 11 15:05:09 CST 1997
858114303
3-11-97
3/11/97
March 11, 1997
March 11, '97
97-03-11
11 MAR 97
11 March 1997
 ...


: I have surfed, searched, read FAQs, downloaded, copied, hacked.  Can some kind 
: soul give me the necessary nudge. 


After answering the above, I would try and get it into seconds since
the epoch (that's how Unix represents dates, the second one above),
then subtract 180 days worth of seconds, then use localtime() to get
it back to a human readable form...


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: 11 Mar 1997 22:47:20 GMT
From: BOB <somebody@somewhere.com>
Subject: Can you help me with this script?
Message-Id: <5g4ndo$96e@qualcuno.nettuno.it>

Hi to everybody
I use MacPerl 5 as a port to Perl: I've wrote a simple script that
produces a standard letter when a document called "stuff" is dragged into.
more precisely:
1. I've wrote a doc (called "stuff") with some data and ":" as field
separator.
For example "stuff" may be the following:

Sheep:Lighting:29
Camels:Cough:20

2. the brief script is the following:

#!usr/bin/perl


open(STUFF, "stuff") || die "Can't open stuff: $!\n";
open(CTP, ">/dev/ctp") || die "can't open /dev/ctp: $!\n";
while(<STUFF>) {
($beastie,$hazard, $premium,)
=split(/:/, $_); 
}
close STUFF;
while(1) {
print "letter for which beastie: ";
chop($beastie = <STDIN>);
last unless $beastie;
print CTP <<"EndOfLetter";
Dear People:
find enclosed $premium of the annual premium for insuring
my $beastie against $hazard.
EndOfLetter
print CTP"\f";
}

3. in theory, after "stuff" is dragged into this droplet, I'd expect a
message like "letter for which beastie" : so, continuing in my example,
if I digit "Camels" I'd obtain as a output a letter regardindg the
payment of an insurance of my Camels against the cough! :=>

4. But the script doesn't work: macPerl give me the following error:

#Missing right bracket, at end of line

what does it mean? I've changed all the parentheses but without luck...
Any help will be appreciated!!


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

Date: Tue, 11 Mar 1997 22:11:40 GMT
From: paco@cs.virginia.edu (Paco Hope)
To: Michael Stearns <mstearns@darkwing.uoregon.edu>
Subject: Re: Controlling Output from LWP
Message-Id: <5g4las$bbu@jazz.cs.Virginia.EDU>


Michael Stearns <mstearns@darkwing.uoregon.edu> writes:
> I am assuming that I DON'T want some or all of the header info that is
> getting returned, since my browser won't just give me the formatted

Right-O.

Make the first line that comes back:
Content-type: text/html

Follow it with a blank line, and then begin your page.

Cheers,
Paco
-- 
Paco Hope                                         Computer Systems Engineer
paco@cs.virginia.edu                         Department of Computer Science
http://www.cs.virginia.edu/~bah6f/                   University of Virginia


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

Date: Tue, 11 Mar 1997 15:44:54 -0400
From: Victor Granic <vmg@novator.com>
Subject: Convert DECUnix3.2 dbm to Solaris2.5.1 dbm
Message-Id: <3325B637.9CF@novator.com>

I have hundreds of dbm files on my AlphaStation running DECUnix3.2g
that I need to use on a Solaris2.5.1 machine.  Is there conversion
software for this task before I go ahead and write all of the
dbm files on the Alpha to text files and convert them back to
dbm on the Solaris box?  The royal pain with this task is that
many of the dbm files are over 100 Mbytes and I'm severely running
out of disk space.  

Help and suggestions welcome.
Thank you,
Victor Granic


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

Date: 11 Mar 1997 14:27:26 -0700
From: vkomandu@mnemosyne.cs.du.edu (Ind study)
Subject: DFD's for perl5
Message-Id: <5g4inu$l76@mnemosyne.cs.du.edu>

 Really appreciate your help!!

 my email: vkomandu@cs.du.edu
 


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

Date: Tue, 11 Mar 1997 15:08:37 -0800
From: "Cal..." <jewell@halcyon.com>
Subject: filehandles: better way to test existence of?
Message-Id: <3325E5F5.794BDF32@halcyon.com>

Here's what I'm thinking of using to test the existence of a filehandle:

	#!/bin/perl -w

	open (LOGFILE, "> /dev/null") or die "open: logfile: $!\n";

	print "open: fileno\n" if fileno(LOGFILE);

	close LOGFILE;

	print "closed: fileno\n" if fileno(LOGFILE);

I've combed through the perl pods, looking for a better way, but nothing
struck me as the way to go. I've also checked Camels 1 and 2.

Is fileno(fH) the best way to test the existence of a filehandle?

-- 
Cal...                                                jewell@halcyon.com

"The buck stops here." -- Harry Truman in the White House, ca. 1948
"Stop here with the bucks." -- Bill Clinton in the White House, ca. 1993


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

Date: 11 Mar 1997 14:26:25 -0800
From: Jake Donham <jake@organic.com>
Subject: Re: help about rpcgen and perl
Message-Id: <wu9u3mivze6.fsf@organic.com>

Philippe Heitzmann <pmoutier@bplorraine.fr> writes:

> 
> Is someone use rpcgen and perl
> 
> 	thanks

I'm working on a compiler to generate Perl XS files from RPCL
interface descriptions. I'm hoping to get it to an alpha state in the
next week or so.

If you're interested in alpha-testing it please let me know.

Jake


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

Date: 11 Mar 1997 22:58:02 GMT
From: jnshapi@argo.ecte.uswc.uswest.com (Jim Shapiro)
Subject: Re: Help! Question about reading files
Message-Id: <5g4o1q$ert@aeon.ecte.uswc.uswest.com>

Harry Kas (harry@bci.se) wrote:
: Can somebody help me?

: I have to read a textfile into an array (or variable) and must then be able
: to compare character by character.
: I have done something like this:


: open (HTML,"test.txt");
:   $i = 0;

:   while (<HTML>) {
:     $line[$i] = <HTML>;
:     $i++;
:   }
:   close(INFO);


:   for ($j=0; $j<$i ; $j++ ) {
:     for ($x=0; $x < length($line[$j]) ; $x++ ) {
:       print "($line[$j][$x])";       ## here I hope to see character by
: character but I get only whole lines.
:     }
:   }
: }

: I get a whole line with $line[$j][$x] instead of the single character I
: expected.

: I have also tried to read a file with the getc command but that was not
: working at all.
: Can somebody help me? 

The following code reads the file into an array of lines, then breaks
each line into an array of characters.

#!/usr/bin/perl
require 5.003;
use strict;

my(@lines) = (<DATA>);          # read all lines, in this case from DATA
my(@chars);                     # array to hold characters
chop(@lines);                   # get rid of pesky \n
foreach (@lines) {              # loop over all lines
    @chars = split //, $_;      # break each line into characters...
    print "@chars\n";           # and print the character array
}

__END__
one
two
three


: Harry Kas - BCi Sweden

--
Give every man thy ear, but few thy voice,
Take each man's censure, but reserve thy judgment. (W. Shakespeare)

Jim Shapiro


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

Date: 11 Mar 1997 22:45:10 GMT
From: maclaudi@cps.msu.edu (Claudia  Ma)
Subject: How to overwrite a file?
Message-Id: <5g4n9m$r9h$1@msunews.cl.msu.edu>

Hi,

I'm working on a cgi right now: when someone fill a form online, the data
are saved to a file. But the problem is when the same person wants to
change the data, it can't be done.

I use :

$dir = "/mydir";
$file = "myfile";

open (DATAFILE, "> $dir/$file");

Can someone one tell me why?

Thanks,

Claudia


--
============================================================
Claudia Y. Ma, Computer Science Dept., MSU
Email: maclaudi@cps.msu.edu
URL: http://www.cps.msu.edu/~maclaudi
============================================================


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

Date: Tue, 11 Mar 1997 20:30:59 GMT
From: DeathToSpam@dev.null.com (Lee)
Subject: Re: How to spam - legitimately
Message-Id: <3325c0aa.84322097@news.earthlink.net>

The english language is pure democracy in action<s>.

somsky@dirac.phys.washington.edu (William R. Somsky) wrote:

@>-->---And there are also well-educated, native speakers of English
who are _not_
@>-->---going around saying "send me an email", and "I got your
email", etc.,
@>-->---and who cringe when they hear it.  It's _not_ standard -- at
least not
@>-->---yet.  It _may_ become standard, but then again, it may die.
It's still
@>-->---in the "experimental" phase, as far as I can tell, and the
dissention
@>-->---among people in these groups and the length of the discussion
thread
@>-->---should be enough to indicate that it is not yet a settled
issue.
@>-->---
@>-->---English is an _evolving_ language.  And that means that some
new words
@>-->---and usages may become standard even though some people don't
like them
@>-->---and don't use them.  So "an email" _may_ become the standard,
even
@>-->---though some people object to it.  But evolution implies
selection, and
@>-->---that means that some new words and usages will _not_ become
standard
@>-->---even though some people do like them and do use them.  So "an
email"
@>-->---may "die a-borning" even though you and other are in favor of
it.
@>-->---
@>-->---________________________________________________________________________
@>-->---Dr. William R. Somsky
somsky@phys.washington.edu
@>-->---Department of Physics, Box 351560		 B432 Physics-Astro
Bldg
@>-->---Univ. of Washington, Seattle WA 98195-1560
206/616-2954

--Lee

Internet/Intranet Counsulting and Design:
http://www.designwest.com
Nurses' Call:
http://www.nurse.org/Nurses_Call/


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

Date: Mon, 10 Mar 1997 19:17:53 GMT
From: ubcg5ab@muck (Andreas Wostrack)
Subject: Include perl script in HTML?
Message-Id: <E6uDLt.Hs4@mail2.ccs.bbk.ac.uk>

This is probably an FAQ but how do I include a perl script
in an HTML document?
Any help welcome.

Cheers,
   Andreas



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

Date: Tue, 11 Mar 1997 23:22:11 GMT
From: dkcombs@netcom.com (David Combs)
Subject: Re: Looking for non-Unix Perl book
Message-Id: <dkcombsE6wJKz.2Ez@netcom.com>

> Anyway, a little bit of Unix mindset is good for any programmer's
> soul.

BRAVO!


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

Date: 11 Mar 1997 21:30:21 GMT
From: astroweb@astron (alex filippenko)
Subject: matching whitespace?
Message-Id: <5g4itd$4hd@agate.berkeley.edu>


i know i could look it up but i am 20min away from any perl book....sorry

how do I match an intederminate amount of whitespace... 

i thought... /' '.*/... but doesn't work.. 

			Daniel 


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

Date: Tue, 11 Mar 1997 23:22:21 GMT
From: mas@cyberspy.com (michael allen smith)
Subject: Re: Need FILE1 copied to FILE2 (minus the spaces, tabs, CR, or any other invisible characters)
Message-Id: <3325e899.270649050@news.cyberspy.com>

Tom Christiansen <tchrist@mox.perl.com> wrote:

>    perl -i.bak -pe 's/\s//g' file
>

Thanks, Tom.  This worked first time through.  To those that inquiried
on how the data was corrupted:  When I was stripping off the spaces,
etc I apparently stripped some of the data off.  So I was using the ~s
irresponsibly.

mas


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

Date: 11 Mar 1997 21:11:23 GMT
From: GZQQ43A@prodigy.com (John Caligan)
Subject: Re: Parsing a form with enctype=multipart
Message-Id: <5g4hpr$1mt2@newssvr01-int.news.prodigy.com>

abigail@ny.fnx.com (Abigail) wrote:
>
>On 11 Mar 1997 01:28:45 GMT, Tom Christiansen wrote in comp.lang.perl.
misc:
>++ 
>++ Oye, ?nos explicas por donde en tu mensaje aparece la palabra "perl",

>++ de la cual este newsgroup se trata? 
>++ 
>++ Pues, ?no?
>++ 
>++ Entonces sugiero que busques la respuesta a tu pregunta en un sitio 
que
>++ mas pertenezca a lo de CGI, o sea, comp.infosystems.www.authoring.cgi.

>++ Me imagino que alla tendrmas mas suerte que aca.
>++ 
>++ Pero te diri cuatro cosas (ok, una sola :-) -- Lo primero que 
debermas
>++ hacer es adquirir CGI.pm, que ya entiende la tarea que has mencionado.

>++ 
>
>Odd. Isn't this the same poster who complained not so long ago about a
>posting in French?
>
>
>
>Abigail
>

That's Spanish though...(like it matters)...

John



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

Date: 11 Mar 1997 23:20:51 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Perl FAQ part 0 of 0..9: Overview [Periodic Posting]
Message-Id: <5g4pcj$f0g$1@csnews.cs.colorado.edu>

=head1 NAME

perlfaq - frequently asked questions about Perl ($Date: 1997/03/11 23:13:37 $)

=head1 DESCRIPTION

This document is structured into the following sections:

=over

=item perlfaq: Structural overview of the FAQ.

This document.

=item L<perlfaq1>: General Questions About Perl

Very general, high-level information about Perl.

=item L<perlfaq2>: Obtaining and Learning about Perl

Where to find source and documentation to Perl, support and training,
and related matters.

=item L<perlfaq3>: Programming Tools

Programmer tools and programming support.

=item L<perlfaq4>: Data Manipulation

Manipulating numbers, dates, strings, arrays, hashes, and
miscellaneous data issues.

=item L<perlfaq5>: Files and Formats

I/O and the "f" issues: filehandles, flushing, formats and footers.

=item L<perlfaq6>: Regexps

Pattern matching and regular expressions.

=item L<perlfaq7>: General Perl Language Issues

General Perl language issues that don't clearly fit into any of the
other sections.

=item L<perlfaq8>: System Interaction

Interprocess communication (IPC), control over the user-interface
(keyboard, screen and pointing devices).

=item L<perlfaq9>: Networking

Networking, the Internet, and a few on the web.

=back

=head2 Where to get this document

This document is posted regularly to comp.lang.perl.announce and
several other related newsgroups.  It is available in a variety of
formats from CPAN in the /CPAN/doc/FAQs/FAQ/ directory, or on the web
at http://www.perl.com/perl/faq/ .

=head2 How to contribute to this document

You may mail corrections, additions, and suggestions to
perlfaq-suggestions@perl.com.  Mail sent to the old perlfaq alias will
merely cause the FAQ to be sent to you.

=head2 What will happen if you mail your Perl programming problems to the authors

Your questions will probably go unread, unless they're suggestions of
new questions to add to the FAQ, in which case they should have gone
to the perlfaq-suggestions@perl.com instead.

You should have read section 2 of this faq.  There you would have
learned that comp.lang.perl.misc is the appropriate place to go for
free advice.  If your question is really important and you require a
prompt and correct answer, you should hire a consultant.

=head1 Credits

When I first began the Perl FAQ in the late 80s, I never realized it
would have grown to over a hundred pages, nor that Perl would ever become
so popular and widespread.  This document could not have been written
without the tremendous help provided by Larry Wall and the rest of the
Perl Porters.

=head1 Author and Copyright Information

Copyright (c) 1997 Tom Christiansen and Nathan Torkington.
All rights reserved.

=head2 Non-commercial Reproduction

Permission is granted to distribute this document, in part or in full,
via electronic means or printed copy providing that (1) that all credits
and copyright notices be retained, (2) that no charges beyond reproduction
be involved, and (3) that a reasonable attempt be made to use the most
current version available.

Furthermore, you may include this document in any distribution of the
full Perl source or binaries, in its verbatim documentation, or on a
complete dump of the CPAN archive, providing that the three stipulations
given above continue to be met.

=head2 Commercial Reproduction

Requests for all other distribution rights, including the incorporation
in part or in full of this text or its code into commercial products
such as but not limited to books, magazine articles, or CD-ROMs, must
be made to perlfaq-legal@perl.com.  Any commercial use of any portion
of this document without prior written authorization by its authors
will be subject to appropriate action.

=head2 Disclaimer

This information is offered in good faith and in the hope that it may
be of use, but is not guaranteed to be correct, up to date, or suitable
for any particular purpose whatsoever.  The authors accept no liability
in respect of this information or its use.

=head1 Changes

This is the initial release of version 3 of the FAQ; consequently there
have been no changes since its initial release.
-- 
	Tom Christiansen	tchrist@jhereg.perl.com

if (*name == '+' && len > 1 && name[len-1] != '|') {  /* scary */
    --Larry Wall, from doio.c in the v5.0 perl distribution 


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

Date: 11 Mar 1997 23:23:14 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Perl FAQ part 1 of 0..9: General Questions [Periodic Posting]
Message-Id: <5g4ph2$f0g$2@csnews.cs.colorado.edu>

=head1 NAME

perlfaq1 - General Questions About Perl ($Revision: 1.9 $)

=head1 DESCRIPTION

This section of the FAQ answers very general, high-level questions
about Perl.

=head2 What is Perl?

Perl is a high-level programming language with an eclectic heritage
written by Larry Wall and a cast of thousands.  It derives from the
ubiquitous C programming language and to a lesser extent from sed,
awk, the Unix shell, and at least a dozen other tools and languages.
Perl's process, file, and text manipulation facilities make it
particularly well-suited for tasks involving quick prototyping, system
utilities, software tools, system management tasks, database access,
graphical programming, networking, and world wide web programming.
These strengths make it especially popular with system administrators
and CGI script authors, but mathematicians, geneticists, journalists,
and even managers also use Perl.  Maybe you should, too.

=head2 Who supports Perl?  Who develops it?  Why is it free?

The original culture of the pre-populist Internet and the deeply-held
beliefs of Perl's author, Larry Wall, gave rise to the free and open
distribution policy of perl.  Perl is supported by its users.  The
core, the standard Perl library, the optional modules, and the
documentation you're reading now were all written by volunteers.  See
the personal note at the end of the README file in the perl source
distribution for more details.

In particular, the core development team (known as the Perl
Porters) are a rag-tag band of highly altruistic individuals
committed to producing better software for free than you
could hope to purchase for money.  You may snoop on pending
developments via news://genetics.upenn.edu/perl.porters-gw/ and
http://www.frii.com/~gnat/perl/porters/summary.html.

While the GNU project includes Perl in its distributions, there's no
such thing as "GNU Perl".  Perl is not produced nor maintained by the
Free Software Foundation.  Perl's licensing terms are also more open
than GNU software's tend to be.

You can get commercial support of Perl if you wish, although for most
users the informal support will more than suffice.  See the answer to
"Where can I buy a commercial version of perl?" for more information.

=head2 Which version of Perl should I use?

You should definitely use version 5.  Version 4 is old, limited, and
no longer maintained.  Its last patch (4.036) was in 1992.  The last
production release was 5.003, and the current experimental release for
those at the bleeding edge (as of 27/03/97) is 5.003_92, considered a beta
for production release 5.004, which will probably be out by the time
you read this.  Further references to the Perl language in this document
refer to the current production release unless otherwise specified.

=head2 What are perl4 and perl5?

Perl4 and perl5 are informal names for different versions of the Perl
programming language.  It's easier to say "perl5" than it is to say
"the 5(.004) release of Perl", but some people have interpreted this
to mean there's a language called "perl5", which isn't the case.
Perl5 is merely the popular name for the fifth major release (October 1994),
while perl4 was the fourth major release (March 1991).  There was also a
perl1 (in January 1988), a perl2 (June 1988), and a perl3 (October 1989).

The 5.0 release is, essentially, a complete rewrite of the perl source
code from the ground up.  It has been modularized, object-oriented,
tweaked, trimmed, and optimized until it almost doesn't look like the
old code.  However, the interface is mostly the same, and compatibility
with previous releases is very high.

To avoid the "what language is perl5?" confusion, some people prefer to
simply use "perl" to refer to the latest version of perl and avoid using
"perl5" altogether.  It's not really that big a deal, though.

=head2 How stable is Perl?

Production releases, which incorporate bug fixes and new functionality,
are widely tested before release.  Since the 5.000 release, we have
averaged only about one production release per year.

Larry and the Perl development team occasionally make changes to the
internal core of the language, but all possible efforts are made toward
backward compatibility.  While not quite all perl4 scripts run flawlessly
under perl5, an update to perl should nearly never invalidate a program
written for an earlier version of perl (barring accidental bug fixes
and the rare new keyword).

=head2 Is Perl difficult to learn?

Perl is easy to start learning -- and easy to keep learning.  It looks
like most programming languages you're likely to have had experience
with, so if you've ever written an C program, an awk script, a shell
script, or even an Excel macro, you're already part way there.

Most tasks only require a small subset of the Perl language.  One of
the guiding mottos for Perl development is "there's more than one way
to do it" (TMTOWTDI, sometimes pronounced "tim toady").  Perl's
learning curve is therefore shallow (easy to learn) and long (there's
a whole lot you can do if you really want).

Finally, Perl is (frequently) an interpreted language.  This means
that you can write your programs and test them without an intermediate
compilation step, allowing you to experiment and test/debug quickly
and easily.  This ease of experimentation flattens the learning curve
even more.

Things that make Perl easier to learn: Unix experience, almost any kind
of programming experience, an understanding of regular expressions, and
the ability to understand other people's code.  If there's something you
need to do, then it's probably already been done, and a working example is
usually available for free.  Don't forget the new perl modules, either.
They're discussed in Part 3 of this FAQ, along with the CPAN, which is
discussed in Part 2.

=head2 How does Perl compare with other languages like Java, Python, REXX, Scheme, or Tcl?

Favorably in some areas, unfavorably in others.  Precisely which areas
are good and bad is often a personal choice, so asking this question
on Usenet runs a strong risk of starting an unproductive Holy War.

Probably the best thing to do is try to write equivalent code to do a
set of tasks.  These languages have their own newsgroups in which you
can learn about (but hopefully not argue about) them.

=head2 Can I do [task] in Perl?

Perl is flexible and extensible enough for you to use on almost any
task, from one-line file-processing tasks to complex systems.  For
many people, Perl serves as a great replacement for shell scripting.
For others, it serves as a convenient, high-level replacement for most
of what they'd program in low-level languages like C or C++.  It's
ultimately up to you (and possibly your management ...) which tasks
you'll use Perl for and which you won't.

If you have a library that provides an API, you can make any component
of it available as just another Perl function or variable using a Perl
extension written in C or C++ and dynamically linked into your main
perl interpreter.  You can also go the other direction, and write your
main program in C or C++, and then link in some Perl code on the fly,
to create a powerful application.

That said, there will always be small, focused, special-purpose
languages dedicated to a specific problem domain that are simply more
convenient for certain kinds of problems.  Perl tries to be all things
to all people, but nothing special to anyone.  Examples of specialized
languages that come to mind include prolog and matlab.

=head2 When shouldn't I program in Perl?

When your manager forbids it -- but do consider replacing them :-).

Actually, one good reason is when you already have an existing
application written in another language that's all done (and done
well), or you have an application language specifically designed for a
certain task (e.g. prolog, make).

For various reasons, Perl is probably not well-suited for real-time
embedded systems, low-level operating systems development work like
device drivers or context-switching code, complex multithreaded
shared-memory applications, or extremely large applications.  You'll
notice that perl is not itself written in Perl.

The new native-code compiler for Perl may reduce the limitations given
in the previous statement to some degree, but understand that Perl
remains fundamentally a dynamically typed language, and not a
statically typed one.  You certainly won't be chastized if you don't
trust nuclear-plant or brain-surgery monitoring codes to it.  And
Larry will sleep easier, too -- Wall Street programs not
withstanding. :-)

=head2 What's the difference between "perl" and "Perl"?

One bit.  Oh, you weren't talking ASCII? :-) Larry now uses "Perl" to
signify the language proper and "perl" the implementation of it,
i.e. the current interpreter.  Hence Tom's quip that "Nothing but perl
can parse Perl."  You may or may not choose to follow this usage.  For
example, parallelism means "awk and perl" and "Python and Perl" look
ok, while "awk and Perl" and "Python and perl" do not.

=head2 Is it a Perl program or a Perl script?

It doesn't matter.

In "standard terminology" a I<program> has been compiled to physical
machine code once, and can then be be run multiple times, whereas a
I<script> must be translated by a program each time it's used.  Perl
programs, however, are usually neither strictly compiled nor strictly
interpreted.  They can be compiled to a bytecode form (something of a Perl
virtual machine) or to completely different languages, like C or assembly
language.  You can't tell just by looking whether the source is destined
for a pure interpreter, a parse-tree interpreter, a byte-code interpreter,
or a native-code compiler, so it's hard to give a definitive answer here.

=head2 What is a JAPH?

These are the "just another perl hacker" signatures that some people
sign their postings with.  About 100 of the of the earlier ones are
available from http://www.perl.com/CPAN/misc/japh .

=head2 Where can I get a list of Larry Wall witticisms?

Over a hundred quips by Larry, from postings of his or source code,
can be found at http://www.perl.com/CPAN/misc/lwall-quotes .

=head2 How can I convince my sysadmin/supervisor/employees to use version (5/5.004/Perl instead of some other language)?

If your manager or employees are wary of unsupported software, or
software which doesn't officially ship with your Operating System, you
might try to appeal to their self-interest.  If programmers can be
more productive using and utilizing Perl constructs, functionality,
simplicity, and power, then the typical manager/supervisor/employee
may be persuaded.  Regarding using Perl in general, it's also
sometimes helpful to point out that delivery times may be reduced
using Perl, as compared to other languages.

If you have a project which has a bottleneck, especially in terms of
translation, or testing, Perl almost certainly will provide a viable,
and quick solution.  In conjunction with any persuasion effort, you
should not fail to point out that Perl is used, quite extensively, and
with extremely reliable and valuable results, at many large computer
software and/or hardware companies throughout the world.  In fact,
many Unix vendors now ship Perl by default, and support is usually
just a news-posting away, if you can't find the answer in the
I<comprehensive> documentation, including this FAQ.

If you face reluctance to upgrading from an older version of perl,
then point out that version 4 is utterly unmaintained and unsupported
by the Perl Development Team.  Another big sell for Perl5 is the large
number of modules and extensions which greatly reduce development time
for any given task.  Also mention that the difference between version
4 and version 5 of Perl is like the difference between awk and C++.
(Well, ok, maybe not quite that distinct, but you get the idea.)  If
you want support and a reasonable guarantee that what you're
developing will continue to work in the future, then you have to run
the supported version.  That probably means running the 5.004 release,
although 5.003 isn't that bad (it's just one year and one release
behind).  Several important bugs were fixed from the 5.000 through
5.002 versions, though, so try upgrading past them if possible.

=head1 AUTHOR AND COPYRIGHT

Copyright (c) 1997 Tom Christiansen and Nathan Torkington.
All rights reserved.  See L<perlfaq> for distribution information.
-- 
	Tom Christiansen	tchrist@jhereg.perl.com


I have a different view of the world.  --Andrew Hume. Show&Tell '87


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

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

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