[6434] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 59 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Mar 5 23:15:15 1997

Date: Wed, 5 Mar 97 20:00:24 -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           Wed, 5 Mar 1997     Volume: 8 Number: 59

Today's topics:
     beginner! <esuax@csv.warwick.ac.uk>
     Re: beginner! (Tad McClellan)
     Re: BUG? Please explain this behavior <billc@tibinc.com>
     Re: Comm.pl client/server woes (Eric Arnold)
     Re: Comparing various srtings in a database (Jeff Stampes)
     Does Perl regular expression support other languages? <johnnyw@novell.com>
     Re: error using system under NT (Reinoud van Leeuwen)
     Re: Filehandles and subroutines <dbenhur@egames.com>
     Re: Filehandles and subroutines (Tom Harrington)
     Re: Filehandles and subroutines <tchrist@mox.perl.com>
     Re: flock quandary <fishbowl@fotd.netcomi.com>
     Re: flock quandary <tchrist@mox.perl.com>
     FREE Virus Alert Newsletter (Tim Lorge)
     Re: garbage collection (Thomas A. Horsley)
     HELP!  (interpreted pattern matching problem) (David Youd)
     Re: HELP!  (interpreted pattern matching problem) (Tad McClellan)
     Re: HELP!  (interpreted pattern matching problem) <billc@tibinc.com>
     Re: HELP!  (interpreted pattern matching problem) <ajohnson@gpu.srv.ualberta.ca>
     HELP!!! I need your help with .pl files! <imantsb@hotmail.com>
     I am new to perl <flash@winning.com>
     Re: Initializing array contents to all zeros <billc@tibinc.com>
     Re: Interface to BibTeX <dana@boi.hp.com>
     making large perl CGIs run faster <damon@netserver.stanford.edu>
     Re: mathematically correct? <ajohnson@gpu.srv.ualberta.ca>
     Re: mathematically correct? (Tim Dierks)
     Re: Newbie question: perl, OS/2, and #! (Ilya Zakharevich)
     Perl & Win 95 <kmiller@mail.cheta.net>
     Perl Question <rohit@ebs330.eb.uah.edu>
     Perl/Win32 seems to choke on high bits <mark@dragonsys.com>
     Re: Problem Calling Sendmail From Script <eryq@enteract.com>
     Solaris 2.5.1 & gethostbyname (Daniel L. Mercer)
     Re: Timer which can handle milliseconds.. (Daniel Sundin)
     Re: Which one is the best (pattern matching) (Jeff Stampes)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Thu, 6 Mar 1997 00:15:08 +0000
From: Mr A H Abdul Aziz <esuax@csv.warwick.ac.uk>
Subject: beginner!
Message-Id: <Pine.SOL.3.95.970306000356.17229A-100000@lupin>

Help!Help!

Can anyone help me to solve this problem in perl ...I've write it in awk
already...

The problem are to do a pattern matching between two words an English
words and French , case-insensitive .

example,
 
we read input from file that have two english words ,cat and I ..
then the program will read from dictionary file that contains info. like
this :-

chat           [2]  cat
je             [5]  I
manger         [1]  eat

and then output like this 

The nouns "chat" (French) and "cat" (English) have similar meanings
The preposition "je" (French) and "I" (English) have similar meanings

wher [2] or [5] are part of speech of the words , like this ..


Digit
      Part of Speech
 1
      verb
 2
      noun
 3
      adjective
 4
      adverb
 5
      preposition
 6
      article
 
 Thanks in advance .....

new to perl
esunx@csv.warwick.ac.uk   



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

Date: Wed, 5 Mar 1997 19:08:50 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: beginner!
Message-Id: <2f5lf5.1p4.ln@localhost>

Mr A H Abdul Aziz (esuax@csv.warwick.ac.uk) wrote:
: Help!Help!

Don't plead. It's demeaning.


: Can anyone help me to solve this problem in perl ...I've write it in awk
: already...

: The problem are to do a pattern matching between two words an English
: words and French , case-insensitive .

: example,
:  
: we read input from file that have two english words ,cat and I ..
: then the program will read from dictionary file that contains info. like
: this :-

: chat           [2]  cat
: je             [5]  I
: manger         [1]  eat

: and then output like this 

: The nouns "chat" (French) and "cat" (English) have similar meanings
: The preposition "je" (French) and "I" (English) have similar meanings

: wher [2] or [5] are part of speech of the words , like this ..


: Digit
:       Part of Speech
:  1
:       verb
:  2
:       noun
:  3
:       adjective
:  4
:       adverb
:  5
:       preposition
:  6
:       article
:  

----------------------
#!/usr/bin/perl -w

@speech = qw(none verb noun adjective adverb preposition article);

while (<DATA>) {           # for each line
   ($f, $sp, $e) = split;  # seperate the three parts
   $sp =~ s/\D//g;          # digits only remain
   print qq(The $speech[$sp]s "$f" (French) and "$e" (English) have similar meanings\n);
}



__DATA__
chat           [2]  cat
je             [5]  I
manger         [1]  eat
----------------------


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


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

Date: Wed, 05 Mar 1997 21:22:25 -0500
From: Bill Cowan <billc@tibinc.com>
To: Jim Garrison <jhg@austx.tandem.com>
Subject: Re: BUG? Please explain this behavior
Message-Id: <331E2A61.68BB@tibinc.com>

Jim Garrison wrote:
> 
> I understand all the results up to the last one.
> I expect the string "key1val1key2val2", not what is
> obviously a decimal interpretation of a pointer.
> 
> Is this a bug?
> 
>   DB<1> $aref = [0,1,2,3];
> 
>   DB<2> $href = {"key1" => "val1", "key2" => "val2"};
> 
>   DB<3> p $aref->[0]
> 0
>   DB<4> p $href->{"key1"}
> val1
>   DB<5> p join(' ',@$aref)
> 0 1 2 3
>   DB<6> p join(' ',%$href)
> key1 val1 key2 val2
>   DB<7> p @$aref
> 0123
>   DB<8> p %$href
> 268671480
> 
> --
> James Garrison                  mailto:jhg@mpd.tandem.com
> Tandem Computers, Inc
> 14231 Tandem Blvd, Rm 2346      Phone: (512) 432-8455
> Austin, TX 78728-6699           Fax:   (512) 432-2118

FYI: I get following:

  DB<6> $href = {"key1" => "val1", "key2" => "val2"};

  DB<7> p %$href
key1val1key2val2
  DB<8> p scalar(%$href)
2/8
  DB<9> p %{$href}
key1val1key2val2
  DB<10>

while using Win32 Perl 5.001m.

-- Bill
-----------------------------------------------------------------------
Bill Cowan <billc@tibinc.com>    Voice:919-490-0034   Fax:919-490-0143
Tiburon, Inc./3333 Durham-Chapel Hill Blvd Suite E-100/Durham, NC 27707


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

Date: 6 Mar 97 02:53:07 GMT
From: eric.arnold@sun.com (Eric Arnold)
Subject: Re: Comm.pl client/server woes
Message-Id: <ERIC.97Mar06025307@m-e-ir1.sun.com>


It is actually a strange thing to do, to use "select" on a file handle
to a plain file (and not a pipe, socket, pty, etc.).  (For me, I only
have to hit return once for it to send all lines to the server, but
that's Solaris2.5).  I'm guessing that the return from STDIN just sends
some signal that wakes up the "select".

Just read from the file, and print it to the server handle.  

-Eric

In article <857452558.8293@dejanews.com>
	khawkins@ncsa.uiuc.edu writes:
>Well, let me first point out that I'm using Perl 5.003 on a SunOS 4.1.4
>sun4c machine.
>
>I'm having trouble getting my client to communicate properly to my server.
>However, the problem is minimal, and I'd venture to guess that it's
>something sitting right in front of my face, though perlipc, deja news,
>the Perl FAQ, etc., have not made it clear to me.
>
>The problem is this: My client is supposed to read lines out of an input
>file, and send them to the server, which, at this point, is supposed to
>echo them to the screen.  Simple, right?  Well, it worked just fine when
>my input filehandle was STDIN, but when I changed that to an input file
>filehandle, the server would not echo the output lines unless I hit
><Return> for each line of input in the client window...and the client is
>running as a daemon???  The client procedure is listed below.  It
>interfaces just
>fine with the server.  It's pretty much the client example given in the
>examples at the end of the Comm.pl package, except that it reads from a
>file instead of STDIN.  Any help would be greatly appreciated.
>
>		TIA,
>		Kevin Hawkins
>
>require "Comm.pl";
>&Comm'init;
>
>sub submit_to_server  {
>   local($Server_handle, $SERVER, $PORT, $handle, @ready_handles,
>         $buffer);
>
>   $SERVER = "my.server.machine.com";
>   $PORT = 5050;
>   $| = 1;
>
>   open(INPUT, "/tmp/temp_file") || die "Can't open input: $!\n";
>   $Server_handle = &open_port("$SERVER", $PORT, 5);
>   die "Couldn't connect to server: $!\n" unless $Server_handle;
>
>   $done = 0;
>   while (!$done)  {
>      @ready_handles = &select_it(5, $Server_handle, INPUT);
>      foreach $handle (@ready_handles)  {
>         if ($handle eq "INPUT")  {
>            if ($buffer = <INPUT>)  {
>               chop($buffer);
>               print $Server_handle "$buffer\n" ||
>                  die "Could not print buffer to $SERVER";
>            } else  {
>               close(INPUT);
>               $done = 1;
>            }
>         } else  {  # The server handle
>            unless (sysread($handle, $buffer, 1000))  {
>               &Comm'close($handle);
>               die "The connection to $SERVER was broken.";
>            }
>            print $buffer;
>         }
>      }
>   }
>   &Comm'close($Server_handle);
>}
>
>-------------------==== Posted via Deja News ====-----------------------
>      http://www.dejanews.com/     Search, Read, Post to Usenet


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

Date: 6 Mar 1997 00:04:42 GMT
From: stampes@xilinx.com (Jeff Stampes)
Subject: Re: Comparing various srtings in a database
Message-Id: <5fl1mq$liu@neocad.xilinx.com>

Andrew (psaltis@cris.com) wrote:
: Hi all, just a real quick question...

: I am trying to write a perl script that will open a specific file (a sybase
: database file on a RS6000 running AIX ) read in a line of data and then
: compare it to all of the other lines of data in the file. And then repeat
: the process with the next line of data, thus moving down the file comparing
: each line to each other line and writing a file that lists all of the
: duplicate records

As you load in the file, make each entry the key to a hash, and 
increment the value for the key each time it's encountered.  When
you're done loading it, you just need to look at the values, and
any greater than one are your duplicates.


--
Jeff Stampes -- Xilinx, Inc. -- Boulder, CO -- jeff.stampes@xilinx.com


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

Date: Wed, 05 Mar 1997 17:34:03 -0700
From: Johnny Wang <johnnyw@novell.com>
Subject: Does Perl regular expression support other languages?
Message-Id: <331E10FB.4A9D@novell.com>

Hi,

I'm trying to write a Perl script that will search for strings (words to
be exact) in a double byte language such as Chinese or Japanese.  It
seems that the pattern matching in Perl would only work well in single
byte char sets, I may be wrong.  Here is a sample script that I wrote:

$testfile = "DBCS.TXT";
$word = "SOME_DOUBLE_BYTE_CHAR";
open testfile or die "Can't find file $dbcs: \n";
while (<dbcs>) {
  print if /$word/;
}

The above script works if I don't search using /\b$word/ or /\b$word\b/

So the question is Perl enabled?

Thanks


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

Date: Wed, 05 Mar 1997 22:57:59 GMT
From: reinoud@xs4all.nl (Reinoud van Leeuwen)
Subject: Re: error using system under NT
Message-Id: <331ffa52.1806137@news.xs4all.nl>

On Wed, 5 Mar 1997 19:48:52 GMT, cutt@netcom.com (Paul S. Cutt) wrote:

>When I use the system command under NT say system "dir xxx";
>the print messages returned give me an error under a web page. Is the a perl
>command I can give to avoid this ?

Does the account under which the WWW server runs have sufficient
rights to read the directory?

__________________________________________________
Reinoud van Leeuwen       reinoud@xs4all.nl
http://www.xs4all.nl/~reinoud
I specifically DO NOT give anyone permission to use my email adress
for any commercial or non commercial mailings. I will bill everyone 
who sends me this kind of mail for wasting my time. Under Dutch law, 
people who don't let me know they disagree with such a bill are obliged 
to pay it.


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

Date: Wed, 05 Mar 1997 15:41:46 -0800
From: Devin Ben-Hur <dbenhur@egames.com>
To: tph@rmii.com
Subject: Re: Filehandles and subroutines
Message-Id: <331E04BA.122@egames.com>

Tom Harrington wrote:
> How can I return a filehandle from a subroutine?
>         open(LOGFILE,">$logfile_name");
  hey, where's the or die(...) bit?  tsk. :)
>         $filehandle = &openlog(.....);
>         print $filehandle "Log timestamp: ",$date,"\n";
> 
> I've tried just returning the filehandle that open() creates, but it
> doesn't work, and I'm not sure why:
> 
>         return LOGFILE;

Change the return line to:
   return \*LOGFILE;
and all the rest of your usage will work fine.
This works for passing filehandles as parameters to
subroutines too:
   sub foo { my $fh = shift; print $fh "some stuff\n"; }
   &foo(\*FILE);	# print some stuff to FILE

You might also want to look into the FileHandle.pm 
module which supplies an OO interface to filehandles.

HTH
--
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: 6 Mar 1997 00:11:18 GMT
From: tph@longhorn.uucp (Tom Harrington)
Subject: Re: Filehandles and subroutines
Message-Id: <5fl236$1hj6@eccws1.dearborn.ford.com>

Tom Harrington (tph@longhorn.uucp) wrote:

: How can I return a filehandle from a subroutine?

I should probably add that I'm trying to do this with Perl 4.0.1.8.
Further research indicates that I was nearly right for Perl 5.x
(I just needed to make it "return \*LOGFILE;").

If necessary I may finally move up to Perl 5.  But you know how
intertia can be with that kind of change (especially as what I'm
writing here is a toolkit of subroutines to be used by people who
are on Perl 4; if it were just for my use, I'd go ahead and switch).

--
Tom Harrington ------- tph@rmii.com ------- http://rainbow.rmii.com/~tph
      "Rock 'n' Roll, as a sound, is what grandparents listen to."
                       -Fraser Clark, Mondo 2000
-> Fractal Kit:  http://rainbow.rmii.com/~tph/fractalkit/fractal.html <-


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

Date: 6 Mar 1997 01:04:09 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Filehandles and subroutines
Message-Id: <5fl569$7mv$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, tph@rmii.com writes:
:How can I return a filehandle from a subroutine?

    use FileHandle;
    my $fh = FileHandle->new();

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com

    "Just because something is obviously happening doesn't mean something obvious
    is happening." --Larry Wall


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

Date: Wed, 5 Mar 1997 13:45:30 -0600
From: "James L. McGill" <fishbowl@fotd.netcomi.com>
To: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: flock quandary
Message-Id: <Pine.LNX.3.95.970305134201.3261A-100000@fotd.netcomi.com>



On Wed, 5 Mar 1997, Tom Christiansen wrote:

>Open it read/write: +<
>
>--tom

Ah thank you guru.  __ 
I remember something you wrote about GDBM_File..
That there is no way to lock these.  Do you have a 
recommendation?  The way I am working arond it now
is to open a file and attempt to lock it, then open
the dbm.  I wish I could lock the dbm itself...


------------------------+----------------------------------------------
   James L. McGill      |              NETCOM  Interactive
 Programmer / Analyst   |                 Dallas, Texas  
 <fishbowl@netcom.com>  | -=[ http://www.conservatory.com/~fishbowl ]=-
------------------------+----------------------------------------------



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

Date: 6 Mar 1997 00:29:35 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: flock quandary
Message-Id: <5fl35f$7dl$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    fishbowl@fotd.netcomi.com (James L. McGill) writes:
:I need to open a file for ">" overwriting
:but only if I can get an exclusive lock on it.
:
:Here's the dilemma though.  If I open it so that I 
:can pass the filehandle to flock(), the file is 
:destroyed anyway.  If I open it for reading,
:lock it, then close and reopen it for writing, the 
:lock is gone!

Open it read/write: +<

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com

    "It is easier to port a shell than a shell script."
		--Larry Wall


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

Date: Wed, 05 Mar 1997 20:02:54 -0500
From: inoculation@lorge.com (Tim Lorge)
Subject: FREE Virus Alert Newsletter
Message-Id: <inoculation-0503972002540001@lorgecom.ppp.cyberenet.net>

FREE Virus Alert Newsletter

Did you know that:

 ...6 to 9 NEW computer viruses are discovered EVERY SINGLE DAY??

 ...That between August of last year and February of this year there have
been 217 documented NEW macro viruses alone?

How can you win the battle against computer viruses? Subscribe to Lorge
Technology Publishing's newest publication Inoculation!.

Inoculation! is debuting on Wednesday, March 19th. Whenever we find out
about a new virus, you9ll find out! Within 2 hours of our notification,
you will receive an email from us with all the details. 

This is a free service of Lorge Technology Publishing, Publishers of the
LARGEST publication on groupware and messaging, Groupware News.

To subscribe, all you have to do is send an email to i_sub@lorge.com. In
the subject and body enter 3Subscribe2 and you will be all set.

I9m looking forward to having you as a subscriber!

Cheers!

Tim Lorge
Editor & Publisher


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

Date: 05 Mar 1997 20:57:02 -0500
From: Tom.Horsley@worldnet.att.net (Thomas A. Horsley)
Subject: Re: garbage collection
Message-Id: <uwwrlkck1.fsf@worldnet.att.net>

>If it does work,
>how hard would it be to turn off perl's own reference counting?

Might be kinda tricky to get object destructors called if there is
no reference counting (although I'm not sure how all this stuff ties
together).


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

Date: Wed, 05 Mar 1997 15:37:53 -0800
From: youd1@llnl.gov (David Youd)
Subject: HELP!  (interpreted pattern matching problem)
Message-Id: <youd1-0503971537530001@dyoud.llnl.gov>

P73 of the Camel book (2nd edition) shows that
"s/\d+/$&*2/e;" should double any numbers found in $_.

My code is "$input_text =~ s/\d+/$&*2/e;", but nothing happens!  Grrr..

I know I doing something stupid.  All help greatly appreciated!  Please
send all responses to youd1@llnl.gov.

David Youd
youd1@llnl.gov
"I put the 'fun' in fundamentalism"

-- 
David Youd (youd1@llnl.gov)  "I put the 'fun' in fundamentalism"

#include <dsclaimr.h>
"My views do not necessarily represent those of LLNL"


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

Date: Wed, 5 Mar 1997 18:13:28 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: HELP!  (interpreted pattern matching problem)
Message-Id: <872lf5.hg4.ln@localhost>

David Youd (youd1@llnl.gov) wrote:
: P73 of the Camel book (2nd edition) shows that
: "s/\d+/$&*2/e;" should double any numbers found in $_.

: My code is "$input_text =~ s/\d+/$&*2/e;", but nothing happens!  Grrr..
                                             ^^^^^^^^^^^^^^^^^^^

Works fine for me.

Are you _sure_ there are some digits in $input_text? (print it out
right before the s///)


: I know I doing something stupid.  All help greatly appreciated!  

: Please send all responses to youd1@llnl.gov.
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

How come?


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


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

Date: Wed, 05 Mar 1997 21:27:30 -0500
From: Bill Cowan <billc@tibinc.com>
To: David Youd <youd1@llnl.gov>
Subject: Re: HELP!  (interpreted pattern matching problem)
Message-Id: <331E2B92.2C4F@tibinc.com>

David Youd wrote:
> 
> P73 of the Camel book (2nd edition) shows that
> "s/\d+/$&*2/e;" should double any numbers found in $_.
> 
> My code is "$input_text =~ s/\d+/$&*2/e;", but nothing happens!  Grrr..
> 
> I know I doing something stupid.  All help greatly appreciated!  Please
> send all responses to youd1@llnl.gov.
> 
> David Youd
> youd1@llnl.gov
> "I put the 'fun' in fundamentalism"
> 
> --
> David Youd (youd1@llnl.gov)  "I put the 'fun' in fundamentalism"
> 
> #include <dsclaimr.h>
> "My views do not necessarily represent those of LLNL"

Your code appears to work!

  DB<10> $input_text = 'aaa 22 bbbb'

  DB<11> $input_text =~ s/\d+/$&*2/e;

  DB<12> print $input_text;
aaa 44 bbbb
  DB<13>

Am I missing something in above text case?

-- Bill
-----------------------------------------------------------------------
Bill Cowan <billc@tibinc.com>    Voice:919-490-0034   Fax:919-490-0143
Tiburon, Inc./3333 Durham-Chapel Hill Blvd Suite E-100/Durham, NC 27707


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

Date: Wed, 05 Mar 1997 19:21:54 -0600
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: HELP!  (interpreted pattern matching problem)
Message-Id: <331E1C32.7CAE599E@gpu.srv.ualberta.ca>

David Youd wrote:
> 
> P73 of the Camel book (2nd edition) shows that
> "s/\d+/$&*2/e;" should double any numbers found in $_.
> 
> My code is "$input_text =~ s/\d+/$&*2/e;", but nothing happens!  Grrr..
> 
> I know I doing something stupid.  All help greatly appreciated!  Please
> send all responses to youd1@llnl.gov.

hmm well what was the rest of your code?
I just ran the following:

$input_text="abc123xyz";
$input_text =~ s/\d+/$&*2/e;
print $input_text;

and received as output:

abc246xyz

although, $input_text =~ s/(\d+)/$1*2/e;
would be a little better.

regards
andrew


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

Date: Wed, 05 Mar 1997 03:53:05 -0800
From: Imants <imantsb@hotmail.com>
Subject: HELP!!! I need your help with .pl files!
Message-Id: <331D5EA1.2F12@hotmail.com>

ANYBODY WHO COULD HELP ME!!!

I believe I need your help and would greatly appreciate if you could
assist me.

I'm trying to control visitors access to one of my sites. I downloaded
register.pl and htpasswd.pl, but I can't make them work.

First of all, on the page I downloaded them from they were referred to
as .pl files, but downloaded documents had .txt ending. I placed them
both in cgi-bin of my main directory, but every time i try to use
register.html, i'm getting reply: /cgi-bin/register.pl is not found.
I tried to use .pl files as they were supplied /ie with .txt endings/
and 
i tried to rename them giving them .pl endings, but results were the
same.

Is there any guide for 'dummies' like me online that would explain
plainly exactly what to do after you download files like register.pl
and htpasswd.pl? If there's none, can you possibly advise me on what
should I do to secure access to my site?

Yours Faithfully,

Imants


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

Date: 5 Mar 1997 23:41:39 GMT
From: "iljamar" <flash@winning.com>
Subject: I am new to perl
Message-Id: <01bb0a24$d35fec40$c1db0a26@flashweb.net>

Does anyone know of any books or instructional videos on perl? I preffer
videos, possibly a trainig course in the Connecticut area. Thanks

-Jason Felber
flash@winning.com


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

Date: Wed, 05 Mar 1997 21:37:22 -0500
From: Bill Cowan <billc@tibinc.com>
To: eliot@dg-rtp.dg.coml
Subject: Re: Initializing array contents to all zeros
Message-Id: <331E2DE2.83A@tibinc.com>

really_eliot@dg-rtp.dg.com_but_mangled_to_stop_junk_email wrote:
> 
> I need to create a lot of arrays and initialize their elements to zero.
> I want to initialized them explicitly because I may well read various
> elements before writing them, and perl -w burps out many screenfuls of
> warnings about using uninitialized values.
> Since I generally create several arrays of the same size at the same time,
> I have written a routine that takes one size parameter, and references
> to one or more arrays.  It is:
> 
> sub InitializeArrays {
>    my $size = shift @_;
>    my $firstarray = shift @_;
>    my $otherarray;
> 
>    $#$firstarray = $size - 1;
>    foreach $index (0 .. ($size - 1)) {
>       $firstarray -> [$index] = 0;
>    }
> 
>    foreach $otherarray (@_) {
>       $#$otherarray = $size - 1;
>       @$otherarray = @$firstarray;
>    }
> }
> 
> I kept thinking that surely there would be a slicker way of doing this,
> but I can't come up with one.  Any suggestions?
> 
> Please note that my email address is mangled in the header.
> 
> Topher Eliot                           Data General Unix Core Development
> (919) 248-6371                                        eliot at dg-rtp.dg.com
> Obviously, I speak for myself, not for DG.
> Visit misc.consumers.house archive at http://www.geocities.com/Heartland/7400
> "I like to get the chicks messy."
>         -- Peter, age 4, on why he likes the barnyard-scene cereal bowl.

Perhaps the following...

  DB<21> $array_size = 5

  DB<22> @array = (0) x $array_size
                  ^^^^^^^^^^^^^^^^^
  DB<23> p scalar(@array)
5
  DB<24> p join(',', @array)
0,0,0,0,0
  DB<25>

Main feature (aka trick) is "x" operator in a list context (not scalar)
to yield a list of five array elements (value of zero).

-- Bill
-----------------------------------------------------------------------
Bill Cowan <billc@tibinc.com>    Voice:919-490-0034   Fax:919-490-0143
Tiburon, Inc./3333 Durham-Chapel Hill Blvd Suite E-100/Durham, NC 27707


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

Date: Wed, 05 Mar 1997 13:28:41 -0700
From: Dana Jacobsen <dana@boi.hp.com>
Subject: Re: Interface to BibTeX
Message-Id: <331DD779.5F26@boi.hp.com>

Guido Kanschat wrote:
> 
> Has anybody written an interface to read
> BibTeX files into Perl?

  Take a look at
<http://www.ecst.csuchico.edu/~jacobsd/bib/bp/index.html>.  This is a
perl package that works under both perl4 and perl5.  It will read BibTeX
files and parse them for you, as well as a number of other formats.  It
will even convert between formats and character sets for you.

  Here's an example from the distribution that will sort by a given
field:

#!/usr/bin/perl
unshift(@INC, $ENV{'BPHOME'})  if defined $ENV{'BPHOME'};
require "bp.pl";

# parse BP's arguments, like informat, outformat, etc.
@ARGV = &bib'stdargs(@ARGV);

# walk through the arguments.
while (@ARGV) {
  $_ = shift @ARGV;
  last if /^--$/;
  /^-f/   && do { $field = shift @ARGV; next; };
  push (@filelist, $_);
}
push(@filelist, @ARGV)  if @ARGV;

die "You must specify a sort field with -f <field>.\n" unless defined
$field;

# With no files, we read from stdin
unshift(@filelist, '-')  unless @filelist;

foreach $file (@filelist) {
  next unless &bib'open($file);
  while ($record = &bib'read) {
    %entry = &bib'explode($record);
    $allrecs{"$entry{$field}"} .= "$record\n";
  }
  &bib'close;
}
foreach $rec (sort keys %allrecs) {
  print $allrecs{$rec};
}


  The function &bib'read will handle reading a record (which also
unstringifies BibTeX).  If you had given the option "-informat=refer" or
given a filename ending with .ref, it would read a refer record. 
Similarly for procite, medline, inspec, rfc1807, cstra, etc. 
&bib'explode will turn the text record into an associative array with
each field in it's own entry.  This program really ought to have better
error checking in case $field isn't a valid field...

  If you want to hack up the BibTeX stuff, it's all in it's own module. 
The parts dealing with string substitution are particularly ugly, partly
because I wanted to avoid relying on perl5's minimal string matching,
and mostly because it's something better handled by a real parser rather
than regex's.

  I'm still trying to find time to finish up the latest version, which
adds Unicode, a much more robust rfc1807, NASA's ADS format, some
improvements to the BibTeX string parser, BibTeX crossrefs (these last
two are in 0.2.97).

  BTW, the Bib.pm module on CPAN is for refer files, not BibTeX.
--
Dana Jacobsen
dana@acm.org


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

Date: Wed, 05 Mar 1997 17:44:53 -0800
From: Conrad Damon <damon@netserver.stanford.edu>
Subject: making large perl CGIs run faster
Message-Id: <331E2194.41C6@netserver.stanford.edu>

I'm working on a fairly large forms-processing CGI script which uses
five modules, some of them big. That makes the setup for the script
pretty expensive - I can watch the process grow from 1 to 4 megs in
size. Once it gets everything loaded it does okay. It uses CGI, Safe,
Time::Local, URI::Escape, and Net::SMTP (from 5.003 distribution). It
also has a few required files, none of them very big.

Are there things I could do that would help in more than an incremental
way? Am I missing something obvious? I could try CGI Lite. There's also
the perl compiler (in alpha, right?), but I'm not sure how well it deals
with modules.

I've looked at a few ways to make things more efficient and was
wondering if there's any general consensus, words of advice, etc. The
most interesting possibilities are FastCGI (run a script as a daemon)
and mod_perl (perl interpreter within Apache). Do people have a
preference, or does it depend on what the script is doing?

It looks like both of those will be a lot easier with a perl that has
the sfio library. Will 5.004 have that by default? The questions I have
about FastCGI and mod_perl are:

Will scripts need to be rewritten?
Can perl modules be accessed easily?
Do I need to build a special version of perl?

TIA for any guidance,

Conrad


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

Date: Wed, 05 Mar 1997 15:49:14 -0600
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: mathematically correct?
Message-Id: <331DEA5A.62275157@gpu.srv.ualberta.ca>

Thomas A. Loser wrote:
! 
!  The PERL (camel) book gives an example for selecting a random line
! from a file of unknown length with a single pass through the file:
! 
!   (paraphrased from page 246)
! 
!   "This procedure selects a line at random from a file, using just
! one pass over the file and without knowing in advance the number of
! lines. It works by calculating the probability that the current line
! would be selected with a probability of 100%, but the second line
! has a 50% chance of replacing the first one, the third line a 33%
! chance of replacing one of the first two, and so on."
! 
!   srand;
!   rand($.) < 1 && ($it = $_) while <>;
!   
! 
! 
!   I'm no math genius but if I assume just 3 lines it appears that line
! 2 will replace line 1 once every other time (1 out of 2) and line 3
! will replace 1 *or* 2 every third time (1 out of 3) leaving line 1 as
! the selected line just 1 out of every six times. (1/2 + 1/3 = 5/6
! chance of line 1 being replaced). Is my logic faulty or does this
! routine heavily favor lines later in the file? I'm attracted to its
! simplicity but not if it's way skewed.
! 
!   -Tom Loser

your addition of probabilities is in error, they are not
additive in the manner you show  ie; what about four lines:
1/2 + 1/3 + 1/4 = 1.08333 ??

at line 1, the selection of line 1 is guaranteed ---
probability =1.  

Then at line 2, the probability of line 1's
replacement is 1/2 so the probability of line 1's
continued existence (as the selected line) is: 
1 - (1/2 * 1) = 1/2

when we begin line 3, line 1's probability of existence is
1/2, and the probability of its replacement here is 1/3
thus the probability of line 1's continued existence at the
end of the third iteration is: 
1/2 - (1/3 * 1/2) = 1/3

and, of course, since line 2's chance of existence was also
1/2, its chance now is also 1/3. and at line 4:
1/3 - (1/4 * 1/3) = 1/4    etc etc.

thus, the logic of the method is not skewed to later lines
in the file: However, whether the pseudo-random number
generator might be biased is another question altogether :-)

regards,
andrew


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

Date: Wed, 05 Mar 1997 18:45:01 -0800
From: tim@dierks.org (Tim Dierks)
Subject: Re: mathematically correct?
Message-Id: <tim-ya02408000R0503971845010001@nntp.best.com>

In article <tloser-0503971240210001@168.133.124.5>,
tloser@valdemar.microserve.com (Thomas A. Loser) wrote:
[ Selecting a line from a file at random; Camel p. 246 ]
>
>  srand;
>  rand($.) < 1 && ($it = $_) while <>;
>  
>  I'm no math genius but if I assume just 3 lines it appears that line
>2 will replace line 1 once every other time (1 out of 2) and line 3
>will replace 1 *or* 2 every third time (1 out of 3) leaving line 1 as
>the selected line just 1 out of every six times. (1/2 + 1/3 = 5/6
>chance of line 1 being replaced). Is my logic faulty or does this 
>routine heavily favor lines later in the file? I'm attracted to its
>simplicity but not if it's way skewed.

Your logic is faulty:
  After line 1, $it will contain line 1 100% of the time
  After line 2, $it will be replaced by line 2 50% of the time:
                $it will contain line 1 50% of the time
                $it will contain line 2 50% of the time
  After line 3, $it will be replaced by line 3 33% of the time:
                $it will contain line 1 33% of the time (50% x (1-33%))
                $it will contain line 2 33% of the time (50% x (1-33%))
                $it will contain line 3 33% of the time
  After line 4, $it will be replaced by line 4 25% of the time:
                $it will contain line 1 25% of the time (33% x (1-25%))
                $it will contain line 2 25% of the time (33% x (1-25%))
                $it will contain line 3 25% of the time (33% x (1-25%))
                $it will contain line 4 25% of the time

For each following line, the new line has an proportionate chance of
replacing any the previously selected one, and the probablities of any
particular previous line will be reduced appropriately.

 - Tim

-- 
______________Tim Dierks - Software Haruspex - tim@dierks.org_______________
Shreveport, LA was named after Captain Henry Miller Shreve, whose claim to
fame was that he cleared a 160 mile long logjam on the Red River. Before you
mess with Americans, remember that we have logjams that wouldn't even fit
inside many countries.  And men like Henry Shreve, to handle them. - E. Rice


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

Date: 5 Mar 1997 23:20:58 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Newbie question: perl, OS/2, and #!
Message-Id: <5fkv4q$lps$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Joel Earl
<earl@shadowfax.rchland.ibm.com>],

> If you can't run UNIX, then OS/2 is actually a pretty nice platform for
> perl. 

[1]
>	You'll preserve your remaining hair by switching to Ilya Zakharevich's
> port at:
> 
> //www.perl.com/CPAN/modules/by-module/OS2/ILYAZ/os2/perl.500301.os2.bin.zip

[2]

> #!perl doesn't work under OS/2. 

[3]

>				  Instead, name the file whatever.cmd, so that
> OS/2 thinks it's a batch file, and put this incantation on the first line:
> 
> extproc perl -x -s

[4]

4 wrongs out of the first 4! Good count!

Ilya

P.S. 
[1] OS/2 _may_ be good for you even if you run *nix. (ducking! ;-)
[2] "Current" version is 3_05 (and I may release _91 in a couple of days).
[3] If you use broken shells only
[4] make -s into -S, and you need the usual #! as the next line (this
	changes in _90, so watch out - just -S may be enough)


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

Date: Wed, 05 Mar 1997 16:56:18 -0500
From: "Kevin A. Miller" <kmiller@mail.cheta.net>
Subject: Perl & Win 95
Message-Id: <331DEC02.FF0@mail.cheta.net>

Someone please help; I am looking for Perl5 that will run on my P-166
system using Win95.  I have tried to use Perl for Win32 from various
sources (CD's from books), but it does not install fully or well enough
to run.  Does anybody have any ideas or means to get the info to run it
on my OS.  Thank you,
		K. Miller  kmiller@cheta.net


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

Date: Wed, 05 Mar 1997 16:39:57 -0800
From: Rohit Sherman <rohit@ebs330.eb.uah.edu>
Subject: Perl Question
Message-Id: <331E125D.AE@ebs330.eb.uah.edu>

I am a relative newbee to the versatile powers of perl. 

My question is:

What is the purpose of salt in crypt function usage. How does it work ?

Thanks for any insight provided.

Monish.....


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

Date: Wed, 05 Mar 1997 20:28:07 -0500
From: "Mark A. Mandel" <mark@dragonsys.com>
Subject: Perl/Win32 seems to choke on high bits
Message-Id: <331E1DA7.1F0D@dragonsys.com>

I'm trying to deal with PC-DOS text that involves characters > 127, and I can't get Perl 
for Win32 to accept them all the places that I need them. (Those characters won't 
transit the Internet and won't show up consistently in news readers, so I will have to 
write around them.) The specific use is:

	$pr =~ tr/blahblahblah/okayokayokay/g;

where "blahblahblah" begins with 
	name            decimal codes
	c-cedilla       135 
	plain old x     120
	superscript n   252
	n-tilde         164

and "okayokayokay" contains only characters <= 127, but '{' is one of them and ASCII 
code 6 is another (ctrl-F).

I was getting errors on this line under a release whose doc says
                "BIGPERL"
         Perl 4.0M2 patchlevel 36
         Wed May 19 22:19:30 1993

I installed Perl for Perl for Win32, version 5 build 110, and while I'm still getting an 
error, the message is more detailed... but it's not helping me any. It says
	Bare word found where operator expected at ger2g49.pl line 131, near "tr/ 
		[and then it quotes the line accurately]
	Syntax error in file xxx at line 131,
	next 2 tokens "tr/x|$ejdt@ 
		[replacing each high-bit character with itself -128]

Some of these resulting "-128" characters are control characters. Others are syntactic 
characters, like '|' and '$'.

I've tried replacing all the weird characters, both high-bit and control, with their hex 
equivalents: e.g., c-cedilla -> \x87. Then the messages show the escapes accurately, as 
\x87 and so on, but the error message is the same.

Help, anyone?

-- 

       Mark A. Mandel : Senior Linguist : mark@dragonsys.com 
    Dragon Systems, Inc. : speech recognition : +1 617 965-5200 
 320 Nevada St., Newton, MA 02160, USA : http://www.dragonsys.com/


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

Date: Wed, 05 Mar 1997 16:17:36 -0600
From: Eryq <eryq@enteract.com>
To: Rand Simberg <simberg@interglobal.org>
Subject: Re: Problem Calling Sendmail From Script
Message-Id: <331DF100.291318C3@enteract.com>

Rand Simberg wrote:
> 
> I'm not sure if this is a Perl or a server problem, but when I try to
> execute the following line, the script dies.
> 
> open(MAIL,"|/usr/sbin/sendmail -t") || die "Can't open sendmail";
> 
> I've tried running a similar script from the command line as "nobody",
> and it runs OK, but when I try it with a CGI script it crashes.  Any
> ideas?

Well, I'd start by saying:

	|| die "can't open sendmail: $!"

to at least find out what Perl thinks the problem is.

I'd also make sure that /usr/sbin/sendmail exists AND is executable
by world.  BTW, a more universal path is /usr/lib/sendmail 
on many Unixes (although under Linux I had to put a link in myself). 
That is:

	ls -l /usr/sbin/sendmail

Probably you'll want "-rwsr-sr-x" or similar.
Finally, depending on your installation, you probably want:

	/usr/lib/sendmail -t -oi -oem

See the man pages for the meanings of -oi and -oem.
Hope that helps, 
 
-- 
  ___  _ _ _   _  ___ _   Eryq (eryq@enteract.com)
 / _ \| '_| | | |/ _ ' /  Hughes STX, NASA/Goddard Space Flight Cntr.
|  __/| | | |_| | |_| |   http://www.enteract.com/~eryq
 \___||_|  \__, |\__, |___/\  Visit STREETWISE, Chicago's newspaper by/
           |___/    |______/ of the homeless: http://www.streetwise.org


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

Date: 6 Mar 1997 02:04:46 GMT
From: dmercer@pulsar.wku.edu (Daniel L. Mercer)
Subject: Solaris 2.5.1 & gethostbyname
Message-Id: <5fl8nu$j56@news.wku.edu>

Hello folks,

	I am new at Perl socket programming and am attempting to work
through a number of examples in the Camel book. I am working on a 
Sparcstation running Solaris 2.5.1, and while a good number of my
experiments work, any using 'gethostbyname' fails with the following 
error:

Unsupported socket function "gethostbyname" called at ./list.pl line 4.

Perhaps this is just my failure to understand sockets, and if so I 
apologize for my stupidity in advance. :) Otherwise, are there any 
tips/fixes/rtfms to work around this?

	Thanks so much in advance,

					Dan Mercer
					Western Kentucky University
					dmercer@wku.edu



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

Date: Wed, 05 Mar 1997 15:17:16 GMT
From: daniel.sundin@engelholm.se (Daniel Sundin)
Subject: Re: Timer which can handle milliseconds..
Message-Id: <331d8dc2.3111549@skarjeke.ind.mh.se>

>> I need to be able to measure short periods of times, 
>> less than a second. Preferably as small as milliseconds.
>> 
>
>Which platform are you using?
>
Linux (2.0.29), Latest Perl 
>
>What are you trying to do?  If you are trying to benchmark some
>code, the best way by far is to run the code repeatedly a number
>of times -- there are some standard modules for this, check CPAN.
>
Benchmarking a search, and timing how long it takes to send a file.
But since this is done while the user is waiting (and every time the
search is performed) I cant run it several times. I dont need to 
know how long it takes myself. 

So, both benchmarking a (onweb) search, and timing a file
transfer.

Daniel



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

Date: 5 Mar 1997 23:32:12 GMT
From: stampes@xilinx.com (Jeff Stampes)
Subject: Re: Which one is the best (pattern matching)
Message-Id: <5fkvps$liu@neocad.xilinx.com>

Dylan Northrup (northrup@chem.ufl.edu) wrote:
: An infinite number of monkeys in the guise of Tad McClellan <tadmc@flash.net> wrote:
: =:Abigail (abigail@ny.fnx.com) wrote:
: =:: On 03 Mar 1997 18:04:38 GMT, Jeffrey wrote in comp.lang.perl.misc:
: =:: ++ 
: =:: ++ Comments on this point from perl.gods would be appreciated here,
: =:
: =:: Are you trying to start a religion?
: =:
: =:Too late.   ;-)

: alt.religion.perl anyone?

the ten commandments:

1) Thou shall use -w
2) thou shall not ask cgi programming questions
3) Thou shall RTFM
4) Thou shall not try to validate e-mail addresse
5) Thou shall not use perl4
6) Thou shall heed the latro warning
7) Thou shall have a bible handy at all times (Programming Perl, 2nd Ed)
8) Thou shall not write obfuscated code for others to maintain
9) Thou shall check return stati of functions
10) Thou shall use -w

Do we get to offer up violaters of #2 and #4 as human sacrifice?

--
Jeff Stampes -- Xilinx, Inc. -- Boulder, CO -- jeff.stampes@xilinx.com


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

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

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