[6364] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 986 Volume: 7

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Feb 21 07:07:18 1997

Date: Fri, 21 Feb 97 04:00:19 -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           Fri, 21 Feb 1997     Volume: 7 Number: 986

Today's topics:
     Re: [Q] Array and system <dbenhur@egames.com>
     Re: A form-to-mail perl script needed! Heeeeeeeeeeelp! (Richard Morin)
     Re: Choosing the best method for finding an item on a l <pcunnell@csfp.co.uk>
     Re: efficiency with while? (Ilya Zakharevich)
     Re: escaping quotes/#? <dbenhur@egames.com>
     forwarding a mail message with PERL <geert.nijs@fys.kuleuven.ac.be>
     Re: How to spam - legitimately (Olof Olsson)
     Re: I'm a Win95 user (sorry) and I have 3 questions . . <sfink@cs.berkeley.edu>
     Re: Intrpretor Perl 5 for Win95... (Mike Stok)
     MIME, sendmail, and PERL, HELP <j@j.com>
     output into a variable <mota@ftsu00.ee.TU-Berlin.DE>
     Perl arrays vs. other arrays (was Re: Class library to  (Jonathan King)
     PERL for NT web site <Jimmy@cil.qc.ca>
     Re: Perl module manual pages causing problem with man - (Brooks Davis)
     Re: Question about sorts <dehon_olivier@jpmorgan.com>
     regexp: comma-delimited (csv) with "" inside (Curt Siffert)
     Re: relationship between @INC & PERL5LIB w.r.t. module  <pcunnell@csfp.co.uk>
     sending email and attaching a .gif file penta@knoware.nl
     Solution for "Use of uninitialized value"? <ljohnson@isys.ca>
     Solution for "Use of uninitialized value"? <ljohnson@isys.ca>
     Re: Solution for "Use of uninitialized value"? (Paul Marquess)
     Using Modules w win95. Help a newbie! (Steffen Heinrich)
     Web Form to Perl Problem (Raymond Hines)
     Re: Where can I find code samples. <j@j.com>
     Digest Administrivia (Last modified: 8 Jan 97) (Perl-Users-Digest Admin)

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

Date: Thu, 20 Feb 1997 19:10:02 -0800
From: Devin Ben-Hur <dbenhur@egames.com>
To: Wouter de Boer <wouter.deboer@pi.net>
Subject: Re: [Q] Array and system
Message-Id: <330D120A.E2A@egames.com>

Wouter de Boer wrote:
> I have a module which returns three array, but when I want to use the
> second array from my module is it empty, because all the values are
> strored in the first array. The second and the thirth array are empy.

Well, your code got clipped, but the answer is apparent without it.
You are confused about how Perl returns lists.  The list returned
from a subroutine is always one long flat list, so even if
your wrote
   return (@a,@b,@c);
you really only returned one long list which is the
concatenation of the three lists @a..@c

if you assigned the return like this:
  (@x,@y,@z) = &mysub(whatever);
@x will gobble up the whole returned list and @y and @z will
be empty (as you've observed).  This is correct behavior.

You can do what you want to do using references.  I encourage
you to read the perlref manpage and/or chapter 4 of the blue
Camel.

HTH
--
Devin Ben-Hur      <dbenhur@egames.com>
eGames.com, Inc.   http://www.egames.com/
eMarketing, Inc.   http://www.emarket.com/
"Don't run away. We are your friends."  O-




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

Date: 21 Feb 1997 07:19:49 GMT
From: qnc496@durhamnews.net (Richard Morin)
Subject: Re: A form-to-mail perl script needed! Heeeeeeeeeeelp!
Message-Id: <5ejial$8ot@nr1.toronto.istar.net>

In article <5efdul$4qk$1@news.hol.gr>, thodoris@hol.gr says...
>
>Hi all
>
>I am a 17 year old boy from Greece and I have uploaded my
>personal web page to a local WWW server (www.chalkida.hol
>gr/people/user_pgs/thodoris). 
> 
>I really want to add a form to it, requesting the 
>visitor's NAME, EMAIL address and COMMENTS about the page.


Just do a quick search on the web for formmail.pl  I believe it can be found at 
the various script archives out there.  If you can't find it let me know, and 
I'll have a look.

Some ISP, he should do it for you, and explain how to use it too!

Rich M
qnc496@durhamnews.net



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

Date: Fri, 21 Feb 1997 10:04:22 +0000
From: Paul Cunnell <pcunnell@csfp.co.uk>
Subject: Re: Choosing the best method for finding an item on a list.
Message-Id: <330D7326.15FB7483@csfp.co.uk>

Tad McClellan wrote:
> 
> Alexandre Bento Freire (hawk@ip.pt) wrote:
> : I need to decide the best to find an item on a list.
> 
[...]
> 
> We haven't talked about any of these well known sorting algorithms:
> 
> binary sort
> bubble sort
> quick sort
> heap sort
> bucket sort
> radix sort
> ...
> 

You forgot bogo sort :-)

By the way, a good reference is Robert Sedgewick's 
'Algorithms' (Pub: Addison-Wesley ISBN: 0-210-06673-4)

-- 
Paul Cunnell CSFB RDG (pcunnell@csfp.co.uk) +44 171 888 2946


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

Date: 21 Feb 1997 08:43:19 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: efficiency with while?
Message-Id: <5ejn77$9vl$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Dave Thomas
<Dave@Thomases.com>],
who wrote in article <slrn5gqb7d.rf2.dave@fast.thomases.com>:
> > >    @lines = <FILEIN>;
> Well, slurping in the emacs NEWS file (250k) increased my perl programs size
> by:
> 
>    scalar:  ~300k
>    
>    array:   ~800k

I'm not sure you did it right (perl malloc with all the optimizations on):

> env PERL_DEBUG_MSTATS=2 perl -e "open N,'NEWS'; undef $/; $a = <N>; 1"
Memory allocation statistics after compilation: (buckets 8..8192)
    8640 free:    20   112    25    10    15   1   0     1   1 0 0
   65664 used:   204   248   471   145    33   7   4    15   2 0 1
Total sbrk():    75776. Odd ends: sbrk():       0, malloc():    1312 bytes.
Memory allocation statistics after execution:   (buckets 8..524288)
  524720 free:    22   112    24    10    15   1   0     1   1 0 1 1 1 1 1 1 0
  589968 used:   202   248   472   145    33   7   4    15   2 0 1 0 0 0 0 0 1
Total sbrk():  1140736. Odd ends: sbrk():       0, malloc():    1312 bytes.

> env PERL_DEBUG_MSTATS=2 perl -e "open N,'NEWS'; @a=<N>; 1"
Memory allocation statistics after compilation: (buckets 8..8192)
    8608 free:    20   112    26     7    16   1   0     1   1 0 0
   65696 used:   204   248   470   148    32   7   4    15   2 0 1
Total sbrk():    75776. Odd ends: sbrk():       0, malloc():    1312 bytes.
Memory allocation statistics after execution:   (buckets 8..32768)
   16008 free:   113    38    17    26    10   1   3     1   0 0 1 0 0
  973176 used:  1903   442   975  1090  3174   7   5   261   4 2 3 2 3
Total sbrk():  1015808. Odd ends: sbrk():       0, malloc():    4992 bytes.

Thus	scalar: 1.1M
	array: 1.0M

Scalar is very simple to explain, array much harder.

Scalar is of 270K itself, so goes into 516K bucket, and leaves a trail
of another 512K when it grows (but see below).

Array has 6500 elts of sizes approx. 0 or approx. 70. Long ones go
into 128-byte buckets, short ones into 8-byte buckets. Overhead of
having 6500 scalars fills 240 1K arenas, plus more arenas allocated in
the trail of growing array and growing stacks (2K .. 16K buckets you
see above) - I would estimate 300K for arenas. 80K of these arenas are
for SVs, rest for XPVs (this is unclear to me, since XPVs should not
be allocated in arenas, and the total size is only 80K :-().

There is also the C array of SV* inside AV, and 2 stacks:
"calculator"'s one, and "temporaries deleter"'s one. All three contain
6500 words each, thus go into 32K buckets - but they grow, thus leave
behind trails of allocated freed buckets (these buckets are later
reused for arenas).

Note that the balance of array allocation and scalar allocations can
be greatly changed by small changes in sizes of rows and the total
file (having file of size 240K would lower memory consumption twice
for the scalar case). Note also that preallocation may change the
balance a lot:

> env PERL_DEBUG_MSTATS=2 perl -e "open N,'NEWS'; undef $/; $a ='a'; $a x= 27e4; $a=<N>;1"
Memory allocation statistics after compilation: (buckets 8..8192)
    9256 free:    19   111    17     8    15   1   0     2   1 0 0
   67096 used:   205   249   479   147    33   7   4    16   2 0 1
Total sbrk():    77824. Odd ends: sbrk():       0, malloc():    1312 bytes.
Memory allocation statistics after execution:   (buckets 8..524288)
    9224 free:    21   110    16     8    15   1   0     2   1 0 0 0 0 0 0 0 0
  591416 used:   203   250   480   147    33   7   4    16   2 0 1 0 0 0 0 0 1
Total sbrk():   606208. Odd ends: sbrk():       0, malloc():    1312 bytes.

Hope this helps (read: hurts),
Ilya


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

Date: Thu, 20 Feb 1997 19:30:05 -0800
From: Devin Ben-Hur <dbenhur@egames.com>
To: Jeff Welch <jwelch@world.std.com>
Subject: Re: escaping quotes/#?
Message-Id: <330D16BC.2D2@egames.com>

Jeff Welch wrote:
> I'm modifying a script I've set up and need some help. I'm trying to
> change the line
> print NEWFILE "<body>\n"  (which works fine)
> to output the line "<body bgcolor="#FFFFFF">\n" instead of just
>                    "<body>\n"
> I've tried escaping the quotes and the pound sign but neither seem to work.
> How would I do this?

Well, all you have to do is escape the quotes:
   print "<body bgcolor=\"#FFFFFF\">\n";
but it might cleaner to use an alternate quote:
   print qq[<body bgcolor="#FFFFFF">\n];
or a here-doc form:
   print <<EOH;
<body bgcolor="#FFFFFF">
EOH

Oh BTW (not perl), it's bad HTML style to specify the background
color without also specifying a foreground text and link/vlink
color. Your viewer's defaults may not be your defaults, so if you
change the background there's a good chance that her text color
will have inreadably low-contrast against your background.

--
Devin Ben-Hur      <dbenhur@egames.com>
eGames.com, Inc.   http://www.egames.com/
eMarketing, Inc.   http://www.emarket.com/
"Don't run away. We are your friends."  O-



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

Date: Fri, 21 Feb 1997 11:10:41 -0800
From: Geert Nijs <geert.nijs@fys.kuleuven.ac.be>
Subject: forwarding a mail message with PERL
Message-Id: <330DF331.1443@fys.kuleuven.ac.be>

Hi all,

I want to forward a mail message to another account using perl.

The mail arrives at a Linux account and is transfered to
a PERL Script. (this was easy).

This PERL script can examine the mail by reading STDIN, but this is
not necessary. What I want to do is the following:
  just forward everything (that can be read from STDIN) to 
  another e-mail account (so: without changing any of the headers)

I already tried the following:
   I save STDIN to a file and send this file to an account xxx using
   the mail program, but this has the adverse affect that the headers
   and any attachements of the original message get lost, because
   fundamently I just send a file to account xxx.

Can you still follow ? I hope you can help me.

Hoping to hear from you soon,

Geert Nijs
Network Manager
VSM-KULEUVEN


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

Date: 21 Feb 1997 08:35:09 GMT
From: olof@clear.net.nz (Olof Olsson)
Subject: Re: How to spam - legitimately
Message-Id: <olof-2102972143090001@ppp2-opaque.clear.net.nz>

In article <330CB74B.43@ixlabs.com>, chris@ixlabs.com wrote:

> We have a client who has 18,000 registered web site users.
> 
> They want the users to have the ability te request certain daily data
> sent to them via email (they give us the address when they register).
> 
> All of these emails will be different based on user preferences.
> 
> What is the most efficient way of sending these out without calling
> sendmail 18,000 times? 
> 
> We are using Perl5 on a Solaris box.
> 

Well, you can always use a list manager like majordomo or listserv. If you
want to "do-it-yourself" I would suggest:

*** Write utility that creates a file with all the recipients, one per line.

*** Create an alias that includes the file

*** Write a (perl) utility that calls sendmail (once) sending an e-mail to the 
alias. Make sure sendmail is called with -odq so that the mail is queued.
The message will be queued as a single message (with 18,000 recipients).

*** Run the queue by calling sendmail with -q. This will deliver all
messages in a serial fashion.

You may want to protect the alias so that not just anyone can send
messages to all 18,000 people. 


   --Olof

-- 
Olof Olsson, Internet Product Specialist, mailto: olof@clear.net.nz
CLEAR Net, CLEAR Communications Ltd, Auckland, New Zealand.


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

Date: Fri, 21 Feb 1997 02:48:37 -0800
From: Steve Fink <sfink@cs.berkeley.edu>
Subject: Re: I'm a Win95 user (sorry) and I have 3 questions . . .
Message-Id: <330D7D85.36B8@cs.berkeley.edu>

> 1. How can I call a C routine from a Perl routine (assuming I'm writing
> both & using VC++ 4.0 for the C part)?

man perlapi and related man pages.

> 2. Can I use sockets in Perl?

Yes.

> 3. I forget.

Tie the scissors to one string and start swinging it, then grab the
other string along with the surgical tubing. Feed the white rabbit to
the alligator. Wear your backpack upside down, and repeatedly mutter
"I'll bet you're naked under those clothes" under your breath. If that
doesn't work, reread the Guide and try snorting crushed Advil.

Hope this helps,
Steve


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

Date: 21 Feb 1997 11:21:09 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Intrpretor Perl 5 for Win95...
Message-Id: <5ek0f5$7n4@news-central.tiac.net>

In article <01bc1ecf$5d9460c0$70fa13cc@mephisto.ppp.qbc.clic.net>,
Mario Carrier <mephisto@qbc.clic.net> wrote:

>May have an interpretor Perl 5 for Win95. Where?

You might want to look at http://www.activeware.com/ which contains
information about a port of perl for Win32 and PerlScript.

Hope this helps,

Mike

-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com                |      Pencom Systems Administration (work)


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

Date: 21 Feb 1997 09:04:37 GMT
From: "J" <j@j.com>
Subject: MIME, sendmail, and PERL, HELP
Message-Id: <01bc1fd6$af30bac0$4891f7cd@www>

I have been trying to send a binary file using sendmail from a PERL CGI
script.  I can send mail, I can convert a binary to a base64 encoded
document using mimencode, but I have not been able to product a working
document.



I have been trying to use this code fragment to make it work...

# convert the file in input field 1 to a base64 encoded file

system "mimencode < $INPUT{category1} -o temptext_delete_me";

  open(LOG, "$logfile");  
  while ($line = <LOG>) {
# logfile has this on each line
#name:business_name:email_address:yes/no:yes/no
# where yes/no is either the word yes or no.

    ($name, $business, $email, $cat, $spec) = split(/:/, $line);

 
    open (MAIL, "|$mailprog $email");
    print MAIL "From: MY_COMPANY<mail-list@mycompany.com>\n";
    print MAIL "Subject: mail list \n";
# we can override the option to get the binary file if we want
    if ( ($cat eq "yes" ) || ($INPUT{category2} = "yes") ) {
      print MAIL "MIME-version: 1.0\n";
      print MAIL "Content-type: multipart/mixed;
boundary=\"-----1234-----4567----1234=-----\n";
      print MAIL "-----1234-----457-----1234=-----\n";
      print MAIL "Content-Type: text/plain; charset=\"us-ascii\"\n";
# some garble to stick at the beginning of the letter
      print MAIL "$INPUT{category3}\n";
      print MAIL "-----1234-----4567-----1234=-----\n";
      print MAIL "Content-Type: application/octet-stream;
name=\"$INPUT{category1}\"\n";
      print MAIL "Content-Transfer-Encoding: base64\n";
      print MAIL "Content-Disposition: attachment;
filename=\"$INPUT{category1}\"\n";

 
      open (MIMED, "temptext_delete_me");
      while ($linem = <MIMED>) {
# doesnt always chop off the linefeeds how can i just do MIMED >> MAIL
         chop($linem);
         print MAIL "$linem";
        }
  
      print MAIL "-----1234-----4567-----1234=-----\n";
      close (MIMED);
      close (MAIL);

 now this produces output almost identical to that from my normal email
client, some of the linefeeds are messed up, which I suspect is the
problem, but I havent been able to get it to work.  Is there an easier
way???
Thanks for any help you can provide
Jeff



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

Date: Fri, 21 Feb 1997 10:52:24 +0100
From: Edjair de Souza Mota <mota@ftsu00.ee.TU-Berlin.DE>
Subject: output into a variable
Message-Id: <330D7057.3F4C@ftsu00.ee.TU-Berlin.DE>

Hallo, Perl gurus

I'm coming to the perl world and testing how it works as a simulation
controller.

I need to run a same C-simulation model many times, each time I've got
the results at my monitor. In order to analyse these results I need to
read them and the way I've found 'till today is sending the output to a
temporary file ( "tempaq"), read the results, make some calculations and
depending on the accuracy of the results I ask for another run of the
program. I'm afraid making a hole at the memory 'cause the simulation
runs a hundred of thousends of time :-)

Is there any way to get the output direct to a Perl array ?

Thanks in advance.

-----------------------------------------------------------------------
Edjair de Souza Mota
Technical University of Berlin	   	        Tel.: ++49 (030) 314-23833 
Sekr. FT 5/Telecommunication Networks   	Fax.: ++49 (030) 314-22514
Einsteinufer 25, 10587 Berlin		        mota@ftsu00.ee.TU-Berlin.DE


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

Date: 21 Feb 1997 09:04:59 GMT
From: king@cogsci.ucsd.edu (Jonathan King)
Subject: Perl arrays vs. other arrays (was Re: Class library to make C++...)
Message-Id: <5ejofr$m1r@news1.ucsd.edu>
Keywords: arrays, types, allocation, defined, undef

In article <5eh3cl$9mt$1@csnews.cs.colorado.edu> 
tchrist@mox.perl.com (Tom Christiansen) writes:

[stuff deleted about hashes]

>:and the <vector> and
>:<matrix> template classes which are far superior to the built-in Perl
>:or C-type arrays. 
>
>I'm amazed to see anyone mention Perl arrays and C arrays in such
>a parallel construct, considering how little they have in common.

I agree, but that doesn't mean that something like <vector> couldn't
be better, at least for some purposes.  (I don't know anything about
<vector> other than it's apparently a C++ thingy.)  But on to Perl
and C:

>C arrays can't hold just anything, can't be inspected post-facto about
>what their types are, 

OK, I seem to be having a slight difficulty with these two
statements.  Perl seems to have a different notion of types than
most languages I know of, and, indeed, it is stated on page
36 of the Blue Camel, perl has only 3 data types, namely scalars,
arrays of scalars, and hashes of scalars.  So in one sense, you
could probably say that Perl's array can "only" hold scalars.  Now,
I think that page 36 of the Blue Camel is not quite right, since you
can use ref() to return a type for anything you can take a reference
of, and get back REF, CODE, GLOB, or foo (where foo is the class of
a blessed object), in addition to SCALAR, ARRAY, and HASH.  Page 204
of the Blue Camel actually tells you to think of ref as a "typeof"
operator.  But if that's true, then it's a typeof operator that
doesn't know or care about the difference between a string and an
integer or a float. I don't think Perl deserves full credit in the
"what their types are" department.

>don't grow on demand, don't have an inspectable
>length, and don't get garbage collected.

Of course, similarly dynamic structures in other languages are often
called lists, except maybe for the inspectable length part.  Don't
get me wrong--Perl arrays are cool for many things (e.g., negative
subscripts can be fun), but fixed length vectors they are not, and
those can give you benefits, too.

>C arrays are just blocks of
>memory, or wild pointers thereto, with all the attendant problems such
>things have in other low-level languages -- like assembler.

But Perl arrays have a similar kind of problem in that Perl will
cheerfully extend an array for you and tell you that it has a length
of 128, but won't tell you that some of the stuff in the middle
could be uninitialized.  In fact, my version of Perl will tell you that
such an undefined value is equal to 0 or to "" in an if-statement,
and that's really annoying.  (Even if equal to zero it doesn't have
the value 0 when you try to add something to it, until it gets
coerced that way, so if you didn't have the -w switch you might
never know).  I guess that's not low-level behavior, but I guess you
might call it unsophisticated (or too sophisticated?).

[stuff about Perl's stomping advantages in the regex department deleted.]

Sorry if this sounds cranky, but one of my worst recent memories was
the time when I wrote past what "should" have been the end of an
array, and didn't get a core dump, crash, or error message. :-(

jking




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

Date: Fri, 21 Feb 1997 04:10:20 -0500
From: Jimmy Beattie <Jimmy@cil.qc.ca>
Subject: PERL for NT web site
Message-Id: <330D667C.1262@cil.qc.ca>

I'm new in PERL programming and I see a lot of people searching for more
informations concerning PERL on Windows NT.  Did somebody found a
specialized web site on this subject?

If not, I really hope that some PERL gourous will do it.  I'm sure that
they will got a lot of WEB HITS in the next months...

I currently have some problems with SMTP (form-mail-cgi).

Thanks for your help!
Jimmy@cil.qc.ca


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

Date: 17 Feb 1997 18:40:53 GMT
From: brdavis@orion.ac.hmc.edu (Brooks Davis)
Subject: Re: Perl module manual pages causing problem with man -k
Message-Id: <5ea8nm$d6v$1@cinenews.claremont.edu>

Duncan C. White (d.white@surrey.ac.uk) wrote:
: All tests on all modules work fine.  All the manual pages got installed
: into /usr/man/man3p, which is fine.  Then I run, as I always do after
: installing a package with man pages in /usr/man:
: 
: catman -w -M /usr/man
: 
: This rebuild /usr/man/windex containing the man -k database.  When
: I look at the windex file, or do a man -k perl search, I get lots of
: lines like:
: 
: "NAME"          .IX (3p)        - Arbitrary length float math package
: "NAME"          .IX (3p)        - Arbitrary size integer math package
: "NAME"          .IX (3p)        - CGI Interface for Fast CGI
: "NAME"          .IX (3p)        - CGI routines for writing to the HTTPD
: error log
: "NAME"          .IX (3p)        - Copy files or filehandles
: 
: Clearly, the man pages that pod2man has generated are completely
: confusing Solaris' catman program.  Has anyone got a solution?
: I've started looking at the program that catman invokes to do the
: work, /usr/lib/makewhatis, and I can probably (eventually) work out
: what is confusing it, but many other people must have found this
: problem themselves already, and hopefully some have solved the problem!
: Can pod2man be altered somehow?

I hadn't noticed the problem before, but once you pointed it our it annoyed
me so I decided to fix the problem.  The problem is that Solaris has a
really stupid makewhatis script which dosen't delete certain headers.
I changed a few lines of the sed code in it, but that didn't work correctly.
There were also some other bugs in it that prevented it from doing the
right thing in some cases.  I have written a replacement which seems to
work right.  I get some odd windex errors sometimes, but it seems to work 
all right.  I'm including the script at the end of this message.  To use it.
First, move /usr/lib/makewhatis to something like /usr/lib/makewhatis.sun
so you can recover it if you don't like my script.  Then, create a new
makewhat is script with the following commands in it:

#!/bin/sh
/usr/local/bin/perl /usr/lib/makewhatis.pl $*

Finaly install my script as /usr/lib/makewhatis.pl

The script isn't perfect, but I think it works a lot better then the one
Sun provided.  Let me know what you think.

-- Brooks

/usr/lib/makewhatis.pl --<cut>--
#!/usr/local/bin/perl
# makewhatis -- a working replacement for the Solaris makewhatis
#
# Copyright (c) 1997 Brooks Davis.  All rights reserved.  This script is
# free software; you may redistribute and/or modify it under the same
# terms as Perl itself.
#
# 02/17/97 - Created BD

exit 1 if (! -d $ARGV[0]);

chdir $ARGV[0];

$windex_file = "$ARGV[0]/windex";

# grab data from all the man pages
foreach $SECTION (<man?*>) {
  chdir $SECTION;
  while (<*.?*>) {
    $NAME_line = `/usr/lib/getNAME $_`;
    # get rid of a bunch of junk
    $NAME_line =~ s/(\\|\\\*|-)-/-/g;             # unescape -es
    $NAME_line =~ s/ VAX-11//;
    $NAME_line =~ s/.IX Header \"NAME\"//;     # trash some pod2html things
    $NAME_line =~ s/\\f[PRIB0123]//g;          # trash formating codes
    $NAME_line =~ s/\\f\(CW//g;                # trash formating codes
    $NAME_line =~ s/\\\|//g;                # trash formating codes
    $NAME_line =~ s/\\s[-+0-9]*//g;            # trash formating codes
    $NAME_line =~ s/^[^-]*\n//g;               # delete lines without -es
    $NAME_line =~ s/\.TH \S+ ([a-z0-9]?\S*).*\t\s*([^-]*) -/$1\t$2 -/;
    $NAME_line =~ s/^\s*//;                    # trash leading white space
    $whatis .= $NAME_line;
  }
  chdir '..';
}

foreach (split /\n/, $whatis) {
  if (!/(\S+)\t(.+)$/) {
    die "Impelmenation error...";
  }
  $section = $1;
  $command_list = $2;
  $manpage = $2;
  $manpage =~ s/([\w:]+).* - .*/$1/;
  # deal with all the commands
  foreach (split /\s*\.PP\s*/, $command_list)
  {
    /(.*) - (.*)/;
    $commands = $1;
    $description = $2;
    foreach $command (split /\,\s*/, $commands)
    {
      if (length($command) < 8)
      {
        if (length("$manpage ($section)") < 8) {
          $windex .= "$command\t\t$manpage ($section)\t\t$description\n"; 
        } else {
          $windex .= "$command\t\t$manpage ($section)\t$description\n";
        }
      } else {
        if (length("$manpage ($section)") < 8) {
          $windex .= "$command\t$manpage ($section)\t\t$description\n"; 
        } else {
          $windex .= "$command\t$manpage ($section)\t$description\n";
        }
      }
    }
  }
}
open(WINDEX, "| sort >$windex_file") || die "Couldn't open windex: $windex_file $!";
print WINDEX $windex;
close WINDEX


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

Date: 21 Feb 1997 10:47:28 +0100
From: Olivier Dehon <dehon_olivier@jpmorgan.com>
Subject: Re: Question about sorts
Message-Id: <njzwws2trrj.fsf@jpmorgan.com>

jete@dgs.dgsys.com (Jete Software Inc.) writes:

> 
> I have two classes of error messages which I need to sort numerically
> by class. The class is denoted by a character attribute (V or R) and
> then has a numeric value.
> ex.
> 	"V1", V3", "R12", "V2", "R1"
> 
[ Code snippet deleted ]
> 
> Sort subroutine didn't return a numeric value at Check_Forms.pl line 98, 
> <IN> chunk 1.
> 
> Why??? 

A comparison function is supposed to return -1, 0, or 1 depending on
whether the left argument is numerically less than, equal to, or
greater than the right argument (c.f. Camel book or Perl info file).

Regards,
Olivier Dehon


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

Date: 21 Feb 1997 08:57:37 GMT
From: siffert@shell.wco.com (Curt Siffert)
Subject: regexp: comma-delimited (csv) with "" inside
Message-Id: <5ejo21$hhr$1@news.wco.com>

I've been reading Jeffrey's Owl book and there is extensive work 
with the CSV example - If you're making a comma-delimited file
by exporting from Excel, for instance, it will put quotes around
phrases with commas in them.  His example takes that into account
so it won't split on those internal commas.  However, what of phrases
that also have quotes?

When exporting to CSV:

Earvin "Magic" Johnson     yields    "Earvin ""Magic"" Johnson"


The code I'm using:

  push(@new, $+) while $text =~ m{
      "([^\"\\]*(?:\\.[^\"\\]*)*)",?  # groups the phrase inside the quotes
    | ([^,]+),?
    | ,
  }gx;
  push(@new, undef) if substr($text,-1,1) eq ',';


This unfortunately treats "Earvin ", "Magic", and " Johnson" as three
separate fields.  I've been trying to figure out a way to make the 
first regexp alternative skip over a "" but I'm getting crossed up 
somewhere.  I don't necessarily need to switch the "" to a " while 
I'm matching; I can just do that in the push statement.  But I need
a regexp that can successfully process:

"Earvin ""Magic"" Johnson"
"""Magic"" Johnson"
(and)
"Earvin ""Magic"""

without counting the outside "'s as part of the "" that it should ignore.
Is there an easy adjustment I can make?

(Suggestions on how to make this work with Text::ParseWords appreciated,
as well - it has the same problem.)

Cc's to my inbox appreciated.

Thanks,
Curt Siffert
siffert@tangrams.com



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

Date: Fri, 21 Feb 1997 10:14:20 +0000
From: Paul Cunnell <pcunnell@csfp.co.uk>
To: Silvio Picano <spicano@ptdcs2.intel.com>
Subject: Re: relationship between @INC & PERL5LIB w.r.t. module loading?
Message-Id: <330D757C.59E2B600@csfp.co.uk>

[mailed & posted]

Silvio Picano wrote:
> 
> I've installed DataDumper down a personal path, outside the perl
> installation tree. Now I though that adding paths into @INC was
> enough to find these modules, but I cannot get them to load thru
> @INC:
> 
> --- fails to find modules ---
> [1] unsetenv PERL5LIB

The 'use' gets executed before the 'push'es, because it's a compile-time
rather than run-time sort of thing. So you need to put a BEGIN block
in there to get the ordering right. e.g. :

>     perl
      BEGIN { # <<<<< Add this
>     push @INC, '/usr/guest/spicano/lib/perl5/site_perl/rs_aix325';
>     push @INC, '/usr/guest/spicano/lib/perl5/site_perl';
      }       #  <<<< And this
>     use Data::Dumper;


> 
> Any ideas on why I cannot load thru @INC? I really do not
> want to use PERL5LIB.
> 

Personally, I prefer using PERL5LIB, as it means you _don't_
have to wire search paths into the scripts, which will then
break when moved to a different environment.

-- 
Paul Cunnell CSFB RDG (pcunnell@csfp.co.uk) +44 171 888 2946


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

Date: Fri, 21 Feb 1997 18:16:24 GMT
From: penta@knoware.nl
Subject: sending email and attaching a .gif file
Message-Id: <5ejp57$arb@news.knoware.nl>

I am working on a program to automaticaly send  E-mail messages to my
members. Sending a message is easy. I already fixed that part. But,
now I want to attach a graph of statistics to this mail. This is
difficult. I looked at a page which handled about MIME, but I did not
understand how to use this.

Does someone have a perl-script that sends E-mail and attaches a file?

Thanks.

Ronald Roosjen




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

Date: 21 Feb 1997 09:21:32 GMT
From: "Lee Johnson" <ljohnson@isys.ca>
Subject: Solution for "Use of uninitialized value"?
Message-Id: <5ejpes$h3q@nr1.ottawa.istar.net>

Been through the man pages...understand the error more or less not quite
sure what I'm doing wrong (again) though.

I've tried variations on this line including $date_command, by nothing
seems to work:

$date =`$date+"%y%m%d"`; chop($date);

Did I miss something again?





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

Date: 21 Feb 1997 09:21:46 GMT
From: "Lee Johnson" <ljohnson@isys.ca>
Subject: Solution for "Use of uninitialized value"?
Message-Id: <5ejpfa$h3s@nr1.ottawa.istar.net>

Been through the man pages...understand the error more or less not quite
sure what I'm doing wrong (again) though.

I've tried variations on this line including $date_command, by nothing
seems to work:

$date =`$date+"%y%m%d"`; chop($date);

Did I miss something again?





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

Date: 21 Feb 1997 09:43:20 GMT
From: pmarquess@bfsec.bt.co.uk (Paul Marquess)
Subject: Re: Solution for "Use of uninitialized value"?
Message-Id: <5ejqno$ovm@pheidippides.axion.bt.co.uk>

[ Posted & Mailed ]

Lee Johnson (ljohnson@isys.ca) wrote:
: Been through the man pages...understand the error more or less not quite
: sure what I'm doing wrong (again) though.

: I've tried variations on this line including $date_command, by nothing
: seems to work:

: $date =`$date+"%y%m%d"`; chop($date);
          ^

Try this:

$date =`date +"%y%m%d"`; chop($date);

Paul


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

Date: Fri, 21 Feb 1997 10:30:21 GMT
From: s581009@tfh-berlin.de (Steffen Heinrich)
Subject: Using Modules w win95. Help a newbie!
Message-Id: <5ejthk$jvc@sun04.tfh-berlin.de>

Hello everyone!

The _perl_for_win32_FAQ_ didn't help me on that:
Installing v.5.003_07, Build 303 under Win95 everything, registry
entries, putting up the path (short DOS names only) and associating
pl files with "E:\PERL\PERL5\bin\perl.exe "%1"" first seemed to work
fine.
Then I found that seemingly the interpreter is not able to expand or
use any of of the pathes provided. While perl.exe itself is found by
win95 (the command-box resp.) I need to change to the place where the
script is or include it's full path into the evocation of perl.
Does that mean I have to put all scripts and packages into the \bin -
directory?
That still doesn't work with classes. The .pl-script has

   use CLASS::method;
package CLASS_PL;
use CLASS;

and even when I put up ..\bin\CLASS\method.pm additionally to
 .\lib\CLASS\method.pm perl won't find the module.
I suspect that perl is not able to expand the pathes(DOS and Win95
alike) because internally it uses the slash instead of the backslash
as a seperator.
Am I the only one who encounters these problems, is it a bug in the
specific build?
Being a complete newbie(rookie in terms of perl?) I take myself the
freedom for crying out loudly: HELP! PLEASE!

Thank you, Steffen





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

Date: Fri, 21 Feb 1997 10:07:15 GMT
From: solari@gte.net (Raymond Hines)
Subject: Web Form to Perl Problem
Message-Id: <330d7284.253104955@news.gte.net>

Greets,

I and several other friends have yet to figure out this really
annoying and perplexing problem. Mayhaps one of you out there can help
us?

Basically, I have a guestbook script that I've modified to allow users
the choice of posting to one of two guestbooks, "rumors" or "news".
The name of this variable is "site".

The script runs fine, however, it doesn't seem to be taking the 'site'
variable from the web form.

I have it set up via radio buttons that the user can select two 
sites:  'rumor' and 'news'.

The script that handles this part is as follows:

if ($FORM{'site'} eq "rumor") {
   $guestbookurl = "http://www.gatorcountry.org/rumors.html";
   $guestbookreal = "/usr/www/users/gators/rumors.html"; }
else 
{ 
   $guestbookurl ="http://www.gatorcountry.org/news.html";
   $guestbookreal ="/usr/www/users/gators/news.html"; }            

For some reason it keeps defaulting to the ELSE function even if 
'rumor' is true.  I hardcoded $FORM{'site} = "news" and it worked 
properly.  Is the webform somehow munging the site variable in 
transfer?  I checked it independently in my browser and it comes out 
fine.

The web page in question has:

<form method=POST
action="http://www.gatorcountry.org/cgi-bin/mill.pl">
<INPUT NAME=site TYPE=radio VALUE=rumor> Discussion & Rumors  <br>
<INPUT NAME=site TYPE=radio VALUE=news> News & Information

(I have even tried different methods of submission such as <SELECT>,
<CHECKBOX>, etc., to no avail.)

All seems in order on both fronts.  I have exhausted my brain thus 
far --- I'm hoping one of you can point out a silly error or 
something that I may have overlooked.  Or better yet, is there a 
better way of handling this condition in perl?

I'm about to jump out of the window after spending a couple of hours
just on this little problem.  

Many heartfelt thanks. :)

Ray

Ray Hines --> solari@gte.net
DreamStates Technologies, Inc.



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

Date: 21 Feb 1997 09:13:01 GMT
From: "J" <j@j.com>
Subject: Re: Where can I find code samples.
Message-Id: <01bc1fd7$dbcb6160$4891f7cd@www>

Also, try the web site http://www.eff.org/~erict/Scripts/
which has some really good scripts.  i have taught myself perl  in the last
week using those scripts as examples.


Terry Robison <trobison@erols.com> wrote in article
<01bc1b92$3f92ed20$e86aaccf@trobison>...
> I am just starting to write perl scripts and would like to look at some
> sample code. Where can I find some? My first task is to read a binary
file
> and print it to an ASCI file. I have the Camel Book but some samples
would
> help.  Thanks in advance...
> 
> Terry Robison
> trobison@erols.com
> 
> 


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

Date: 8 Jan 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Jan 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.

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 V7 Issue 986
*************************************

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