[7246] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 871 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Aug 15 07:17:22 1997

Date: Fri, 15 Aug 97 04:00:22 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 15 Aug 1997     Volume: 8 Number: 871

Today's topics:
     .htgroup files and HTTPD:GroupAdmin:Text.pm <jwyates@netcom.com>
     Begginner need simple script <henrywolff@hatsoftnevada.lovelock.nv.us.nospam>
     Re: Begginner need simple script (Lars Gregersen)
     Re: CGI: Forms RADIO BUTTONS <petri.backstrom@icl.fi>
     Re: Enabling MS Personal Web Server to run Perl. <petri.backstrom@icl.fi>
     hel: enviroment vars <gyorfi@mediaport.org>
     help with starting CPAN <xuchu@iscs.nus.edu.sg>
     How can I check repeated URL? <citas@hotmail.com>
     Re: I can't make my sentence appear when I want <petri.backstrom@icl.fi>
     Indexing search engine? (Michael Schuerig)
     New Module List Posted (Andreas Koenig)
     NT, PerlIS, and dbm problems <khown@imap1.asu.edu>
     Re: Perl.exe vs PerlIS.dll on NT S 4.0 <petri.backstrom@icl.fi>
     perl5 regexes slower than perl4? (Andrew Dalke)
     Re: perl5 regexes slower than perl4? (Ilya Zakharevich)
     Problems with eval. <joel@uptimecomputers.com>
     Question of using stat function <jxia@worldnet.att.net>
     Socket problem. Works once only... <w.stanton@auckland.ac.nz>
     THANX (was: Re: perl-5.004 on UW prob (was: Re: perl-5. <schludi@syscomp.de>
     Re: Uninitialized Value? Really? (Andrew M. Langmead)
     Re: Why doesn't sort take a reference any more? (Andrew M. Langmead)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Fri, 15 Aug 1997 06:06:17 GMT
From: "John W. Yates" <jwyates@netcom.com>
Subject: .htgroup files and HTTPD:GroupAdmin:Text.pm
Message-Id: <33F3F1D9.6A34@netcom.com>

Hi,

  I'm coding some stuff using HTTPD::GroupAdmin and think it has
a bug, or at least and incompatability with in "Text" mode Apache:  
It creates .htgroup files comma delimited.  I believe Apache is 
interpreting the comma as part of the logon name in the group list 
and thus all but the last name in the list fail authentication when 
I try to use group authentication.

  If I had control over the files (they are "owned" by the ISP),
I would change the code in HTTPD::GroupAdmin::Text.pm to not add
the comma, but I can't.  Can anyone confirm that this is a problem,
at least, so that I can set the admin people at the ISP at ease
that it IS indeed a problem?

Thanks,

John
-- 
John W. Yates    mailto:jwyates@netcom.com     \
home page: ftp://ftp.netcom.com/pub/jw/jwyates/jwyates.html


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

Date: 15 Aug 1997 09:46:02 GMT
From: "Henry Wolff" <henrywolff@hatsoftnevada.lovelock.nv.us.nospam>
Subject: Begginner need simple script
Message-Id: <01bca95f$93e559c0$b11de4cf@hatsoftnevada.lovelock.nv.us>

When it comes to programming in other languages, even PC assembler, I do
fairly well, but this Perl is killing me.
I need a real simple little script that does the following:

opens a file that contains:
variable1a
variable1b
variable2a
variable2b
etc...

then reads the file data in, then does this test
if (variable1a contains testVar) {
   foundVar = variable1b
}

I thought that this would work
open (COUNT,"$file");
@lines = (COUNT);
close (COUNT);
($var1, $var2) = @lines;
foreach ($line(@lines) (
 if (var1 eq testVar) {
   foundVar = var2;
 }
}

As simple as that is I can't seem to get it to work right!
Can anyone please help me!

Thanks,
Henry Wolff
Star Trek Collectibles Trading Post
Free4All Classifieds, Clipart, Animations, Sounds, Fonts, Pictures and
more...
http://www.hatsoft.com/newtrek/index.html



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

Date: Fri, 15 Aug 1997 10:41:11 GMT
From: lg@kt.dtu.dk (Lars Gregersen)
Subject: Re: Begginner need simple script
Message-Id: <33f42e26.83873741@130.228.3.8>

On 15 Aug 1997 09:46:02 GMT, "Henry Wolff"
<henrywolff@hatsoftnevada.lovelock.nv.us.nospam> wrote:

>When it comes to programming in other languages, even PC assembler, I do
>fairly well, but this Perl is killing me.
>I need a real simple little script that does the following:
>
>opens a file that contains:
>variable1a
>variable1b
>variable2a
>variable2b
>etc...
>
>then reads the file data in, then does this test
>if (variable1a contains testVar) {
>   foundVar = variable1b
>}

 ...and I assume the same goes on for variable2a and variable2b and so
on...???

>I thought that this would work
>open (COUNT,"$file");

Always check your open statements to see if everything's OK. Somthing
like open(COUNT,"$file") or die("We can't open the file, sorry");

>@lines = (COUNT);

This should be @lines = <COUNT>;

This is very inefficient if you have many lines in your file.

>close (COUNT);
>($var1, $var2) = @lines;

This I don't get, sorry

>foreach ($line(@lines) (

Here we seem to have two ( too many and a { too few. Anyway I wouldn't
do it like this

> if (var1 eq testVar) {

if testVar is a variable you must enter it as $testVar

>   foundVar = var2;

and of course a lot of $'s are missing here, too.

> }
>}
>

OK! You have tried. Here is my version of the code.

# first open the file, but check for errors
open (COUNT, "t.dat") or die("OOPS!");

# run a while loop though the file. This way we only 
# have two lines in memory at a time. We chomp the 
# variables to delete the end of line character.
while (chomp($line1 = <COUNT>))
{
  # Here we read the line below the line we want to test.
  # This line is chomped too.
  $line2 = <COUNT>;
  chomp($line2);

  # OK, If we have a match...
  if ($line1 eq $testVar)
  {
    #  ...save the variable into another variable
    $foundVar = $line2;
    # if you know that only one line can match or that
    # you want to only find the first mathing line you
    # can simply delete this comment and write the
    # command: "last" instead
  }
}

# close the file
close COUNT;

In this programme I'm assumeing that the number of lines is even. If
it isn't I expect that the programme will do OK anyway(!)

  I hope this helps!

    Lars

Lars Gregersen, M.Sc., Chem. Eng.
Technical University of Denmark
Department of Chemical Engineering
E-mail  : lg@kt.dtu.dk
Homepage: http://www.gbar.dtu.dk/~matlg/


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

Date: Fri, 15 Aug 1997 09:44:06 +0300
From: Petri Backstrom <petri.backstrom@icl.fi>
Subject: Re: CGI: Forms RADIO BUTTONS
Message-Id: <33F3FAB6.79D0@icl.fi>

Shaun O'Shea wrote:
> 
>   I hve just started trying to use forms and I'm having a bit of
> trouble:
> 
> I have some radio buttons and a text form on one page and I'm having
> trouble trying to get the state of the radio buttons in the resulting
> perl script.
>
[snip - HTML and stuff]

For starters, switch over to using the CGI.pm module to
do the dirty work for you.

Then you can get the value for your radio button or any
other form element with somehting like:

   use CGI;
   my $query = new CGI;
   $value_of_radio_button_named_X = $query->param('X');

See more about CGI.pm at:

   http://www-genome.wi.mit.edu/ftp/pub/software/WWW/cgi_docs.htm

regards,
 ...petri.backstrom@icl.fi
    ICL Data Oy
    Finland


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

Date: Fri, 15 Aug 1997 09:03:07 +0300
From: Petri Backstrom <petri.backstrom@icl.fi>
Subject: Re: Enabling MS Personal Web Server to run Perl.
Message-Id: <33F3F11B.CFF@icl.fi>

box16@usa.net wrote:
> 
> Does anybody know if the MS Personal Web Server can run Perl scripts,
> and if so how does one enable the server to do so?

Yes, and amongst other places, it is documented in
the Perl for Win32 Frequently Asked Questions (FAQ)
list:

 http://www.endcontsw.com/people/evangelo/Perl_for_Win32_FAQ.html

Search for "Personal Web Server" in the document,
and you'll have your answer.

I also recommend you take a look at services such
as 

 http://www.dejanews.com
 http://altavista.digital.com

to learn to search for existing discussions of
things you want to know about.

regards,
 ...petri.backstrom@icl.fi
    ICL Data Oy
    Finland


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

Date: Wed, 13 Aug 1997 12:39:26 +0200
From: Gabor Gyorfi <gyorfi@mediaport.org>
Subject: hel: enviroment vars
Message-Id: <33F18EDE.8DDDAE38@mediaport.org>

Hi,

I tried to install perl on an nt system, now I can run a perl script
from a HTML form, but I can't pass any data , it seems there is no
enviroment variamles are visible from the perl script, and ther is
nothing at stdin.

Can anibody help how to fix this.

Thanks for any help,
Gabor Gyorfi




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

Date: 15 Aug 1997 06:59:31 GMT
From: Xu Chu <xuchu@iscs.nus.edu.sg>
Subject: help with starting CPAN
Message-Id: <5t0uoj$t0k@nuscc.nus.sg>

i just started to learn perl this week and so pls help newbie. the adminitrator
has installed the perl5.004 and CPAN 5.003. Now i am trying to test the web 
techniques by Randal L. Schwartz (Column 3) for getting URLs from altavista 
search engine. the output, however, frustrates me much: i cant even get it 
run! the screen is like this after i run the program with 
"perl geturl.pl computer".

<pre>
http://altavista.digital.com/cgi-bin/query?what=web&fmt=c&pg=q&q=computer&stq=0
failed: <HTML>
<HEAD>
<TITLE>
An Error Occurred
</TITLE>
</HEAD>
<BODY>
<H1>An Error Occurred</h1>
500 - Could not connect to altavista.digital.com:80
</BODY>
</HTML>

can someone help me point out why that http failed? i am using a proxy of my
university.

wings
------
You cannot learn anything unless you almost know it already.



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

Date: Fri, 15 Aug 1997 11:46:56 +0200
From: Aitor <citas@hotmail.com>
Subject: How can I check repeated URL?
Message-Id: <33F4258B.14A8@hotmail.com>

Hi ,

I'm working on a free for all links cgi.
I've beginning with Perl. I'm improving a free script. 

The script adds  new links & descriptions. Now works fine, but how can I
check
if the URL is already added?

I've seen next lines in the links.pl by Matt


# Suck previous link file into one big string
open(FILE,"$filename");
@lines = <FILE>;
close(FILE);

$i=1;
foreach $line (@lines) {    
    if ($line =~ /\<li\>\<a href\=\"([^\"]+)\">([^<]+)<\/a>/) {
        if ($FORM{'url'} eq $1) {
            &repeat_url;
        }
        $i++;
    }
}

I've tried to add it but I get an error, any idea?

Also ho w can I keep. for example the last 100 links, so if you add
another link the oldest one gets deleted?

Thans in advance.

the script is running at:
http://www.dmedia.net/superlinks


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

Date: Fri, 15 Aug 1997 09:36:17 +0300
From: Petri Backstrom <petri.backstrom@icl.fi>
Subject: Re: I can't make my sentence appear when I want
Message-Id: <33F3F8E1.692B@icl.fi>

C E Havlioglu wrote:
> 
> Hi,
> I have written something like:
>     print "Reading URL...";
>       :
>     some stuff about sockets, reading the URL and processing it
>       :
>     print "done \n";
> 
> I wan't it to write
>     Reading URL...
> do the sockets stuff (which takes seconds) and when finished write
>                                                     ^^^^^^^^
>     done
> 
> However, when I run it, instead of doing this it waits until the
> socket stuff is finished and then writes
>     Reading URL...done
> all at once.
> 
> Any ideas how I can solve this problem?

Search your Perl documentation for "$|" or "buffered" (it is
in the perlvar part).

regards,
 ...petri.backstrom@icl.fi
    ICL Data Oy
    Finland


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

Date: Fri, 15 Aug 1997 12:03:07 +0200
From: uzs90z@uni-bonn.de (Michael Schuerig)
Subject: Indexing search engine?
Message-Id: <19970815120307409215@rhrz-isdn3-p16.rhrz.uni-bonn.de>


I'm looking for an indexing search engine. It has to be written in Perl
as CGIs in other languages aren't allowd on the server. I've found some
on-the-fly search scripts (Matt's simple search, WebSearch, Randall
Schwartz' WebTechniques 4/1997), but they proved to be just a bit too
slow.

Michael

--
Michael Schuerig                        Airtight arguments have
mailto:uzs90z@uni-bonn.de                  vacuous conclusions.
http://www.uni-bonn.de/~uzs90z/                -Amelie O. Rorty


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

Date: 15 Aug 1997 06:52:19 GMT
From: andreas.koenig@franz.ww.tu-berlin.de (Andreas Koenig)
Subject: New Module List Posted
Message-Id: <5t0ub3$o3p$1@brachio.zrz.TU-Berlin.DE>
Keywords: FAQ, Perl, Module, Software, Reuse, Development, Free


The Perl 5 Module List, v2.44
=============================

Just in time for the Perl Conference in San Jose a new revision of the
module list is on it's way around USENET and CPAN. It has been posted
to

    news:comp.lang.perl.modules

and uploaded to

    http://www.perl.com/CPAN/modules/00modlist.long.html

The recent changes are appended below.

If you have not seen the module list before, please let us clarify
what it's for: it tries to be *the* comprehensive guide for perl
modules that lists each and every module that is available on the
net. We're trying to bring the perl modules' namespace in shape to
make it easier to find modules, to avoid namespace clashes and to
prevent duplication of effort as early as possible.

Please take a look at the list and check if your modules are listed,
if your favorite modules are listed, if the details given about these
modules are correct, and send additions and corrections to us at
modules@perl.org. If you're in doubt about the appropriateness of an
entry, please notify us and/or the author. THANK YOU! You're helping
to safe the world.

But above all: use them modules and enjoy them. That's what they are
here for.


Recent Changes in the modules database
--------------------------------------

2) Perl Core Modules, Perl Language Extensions and Documentation Tools
----------------------------------------------------------------------
B::
::Graph        adpr  Perl Compiler backend to diagram OP trees    SMCCAM +


3) Development Support
----------------------
ExtUtils::
::DynaGlue     adcr  Methods for generating Perl extension files  DOUGM !
::Embed        Sdpf  Utilities for embedding Perl in C/C++ apps   DOUGM !
::GDBinit      i     Create a .gdbinit file                       JASONS +


4) Operating System Interfaces
 ------------------------------
Mac::Apps::
::PBar         RdpO  AppleEvent module for Progress Bar           CNANDOR +

Sys::
::Sysconf      bdpf  Defines constants for POSIX::sysconf()       NI-S +


5) Networking, Device Control (modems) and InterProcess Communication
---------------------------------------------------------------------
Net::
::IRC          cdpO  Internet Relay Chat interface                DSHEPP !
::LDAPapi      Rdcf  Interface to UMICH and Netscape LDAP C API   CDONLEY +
::Pcap         adcr  An interface for LBL's packet capture lib    PLISTER +


6) Data Types and Data Type Utilities (see also Database Interfaces)
--------------------------------------------------------------------
Data::
::Locations    RdpO  Store data in "drawers", nest these at will! STBEY +

Tie::
::Handle       RdpO  Base class for implementing tied filehandles STBEY +

Time::
::gmtime       Supf  A by-name interface for gmtime               TOMC !
::localtime    Supf  A by-name interface for localtime            TOMC !

Tree::
::Balanced     cdpO  Internally sorted hash-like ADT              MSCHWERN +
::Base         cdpO  Defines a basic binary search tree           MSCHWERN +
::Smart        cdpO  Sorted hash-ish, becomes faster with use     MSCHWERN +


7) Database Interfaces (see also Data Types)
--------------------------------------------
DBD::
::mSQL         amcO  Msql Driver for DBI                          ANDK !

ObjStore       ad+O  ObjectStore DBMS Interface                   JPRIT !


8) User Interfaces (Character and Graphical)
--------------------------------------------
X11::
::Auth         adpO  Read and handle X11 '.Xauthority' files      SMCCAM +
::Keysyms      adpf  X11 key symbols (translation of keysymdef.h) SMCCAM +
::Protocol     adpO  Raw interface to X Window System servers     SMCCAM +
::Wcl          cdcO  Interface to the Widget Creation Library     JHPB +


10) File Names, File Systems and File Locking (see also File Handles)
---------------------------------------------------------------------
File::
::stat         Supf  A by-name interface for the stat function    TOMC !


11) Text Processing, Parsing and Searching
------------------------------------------
Text::
::CSV          adpO  Manipulate comma-separated value strings     ALANCITT !


13) Internationalization and Locale
-----------------------------------
Locale::
::Msgcat       RdcO  Access to XPG4 message catalog functions     CHRWOLF +


14) Authentication, Security and Encryption (see also Networking)
-----------------------------------------------------------------
PGP::
::Sign         adpr  Create and check PGP signatures, securely    RRA +


15) World Wide Web, HTML, HTTP, CGI, MIME etc (see Text Processing)
-------------------------------------------------------------------
Apache         RdcO  Interface to the Apache server API           DOUGM !


18) Images, Pixmap and Bitmap Manipulation, Drawing and Graphing
----------------------------------------------------------------
RenderMan      a     Manipulate RenderMan objects                 GMLEWIS +


21) File Handle, Directory Handle and Input/Output Stream Utilities
-------------------------------------------------------------------
IO::
::Tee          RdpO  Multiplex output to multiple handles         CCSHAN +


Recent Changes in the users database
------------------------------------
+  ALANCITT Alan Citterman <alan@mfgrtl.com>
+  ASHTED   Ted Ashton <ashted@southern.edu>
+  CDONLEY  Clayton Donley <donley@cig.mcel.mot.com>
+  CHRWOLF  Christophe Wolfhugel <wolf@pasteur.fr>
+  CMASON   Chris Mason <cmason@ros.res.cmu.edu>
+  DBONNER  David Bonner <dbonner@cs.bu.edu>
+  GMLEWIS  Glenn M. Lewis <glenn@gmlewis.com>
+  JASONS   Jason E. Stewart <jasons@cs.unm.edu>
+  JGLICK   Jesse N. Glick <jglick@sig.bsh.com>
+  JHPB     Joseph H. Buehler <jhpb@sarto.gaithersburg.md.us>
+  JWIED    Jochen Wiedmann <wiedmann@neckar-alb.de>
+  KENSHAN  Chung-chieh Shan <ken@digitas.harvard.edu>
!  MSCHILLI Michael Schilli <mschilli@blacksun.com>
+  MSCHWERN Michael G Schwern <schwern@envirolink.org>
+  PLISTER  Peter Lister <p.lister@cranfield.ac.uk>
+  RNAIMA   Reza Naima <reza@reza.net>


Thanks for reading that far :-)
andreas kvnig


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

Date: Thu, 14 Aug 1997 22:44:20 -0700
From: Otis Nettles <khown@imap1.asu.edu>
Subject: NT, PerlIS, and dbm problems
Message-Id: <33F3ECB4.4EA5CB@imap1.asu.edu>

Hello,

I've been using dbm files under NT with perl.exe without any problems. 
Now I've switched to using PerlIS though, and I'm encountering some
strange problems.  

The Problem:
Program exits with an error "no such file or directory" when I try to
provide a path to the dbm file to open.  If I don't provide a path, but
simply a dbm file name, then it works fine.  I discovered that when I
did not provide a path, PerlIS created the new dbm file in the
windows\system32 directory!

I certainly hope someone can help me with this one.  Thanks,

Here the code (straight from the Perl 32 FAQ)

# --------   DBM ACCESS EXAMPLE ---------#

$html_header =  "HTTP/1.0 200 OK\r\nContent-type: text/html\n\n";
print $html_header;

$ROOT		= "D:/export/web5/25mb/appdes";
$BIN_ROOT	= "$ROOT/cgi-bin/bulgarian";
$DB_Root	= "$BIN_ROOT/database";

# Needed for dbm usage
use SDBM_File;
use AnyDBM_File 'SDBM_File';

sub O_CREAT { 0x0100 }
sub O_BINARY { 0x8000 }
sub O_RDWR { 0x0002 }

tie( %nicknames, "SDBM_File", "$dir/nicknames", O_RDWR | O_CREAT |
O_BINARY, 0666 )
	or print "Can't tie $dir/nicknames: $!";
if ($nicknames{'otis'}){
	print "Nickname already exists, choose another . . .<P>\n";
	print "Nickname = otis<BR>Full Name = $nicknames{'otis'}<P>\n";
}

else{
	$nicknames{'otis'} = "Otis Nettles";
}



-- 

Otis Nettles
Interactive Applications
webmaster@appdesign.com
(602) 786 - 3224


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

Date: Fri, 15 Aug 1997 09:46:32 +0300
From: Petri Backstrom <petri.backstrom@icl.fi>
Subject: Re: Perl.exe vs PerlIS.dll on NT S 4.0
Message-Id: <33F3FB48.2793@icl.fi>

Pinne wrote:
> 
> Hi again Perlgurus !
> 
> Trying to run Perl.exe 5.003 bld 307 on NT S 4.0 w IIS 3.0.
> BUT IT JUST WON'T WORK.
> PerlIS seems to work ok, but the bloody exe just won't catch.
> Any suggestions ?

You need to tell IIS where you have your bloody exe, and
how it recognizes that it should be run.

Start by reading the Perl for Win32 Frequently Asked
Questions (FAQ) list:

  http://www.endcontsw.com/people/evangelo/Perl_for_Win32_FAQ.html

Search for "IIS" there. Additional hint: "Script Map".

regards,
 ...petri.backstrom@icl.fi
    ICL Data Oy
    Finland


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

Date: 15 Aug 1997 05:30:36 GMT
From: dalke@ks.uiuc.edu (Andrew Dalke)
Subject: perl5 regexes slower than perl4?
Message-Id: <5t0phs$ks8$1@vixen.cso.uiuc.edu>


  I am doing a large number of regex matches against a single large
string.  I tested perl5.004 regex speed against perl4.036 and found
that perl4 was significantly faster.  Can anyone tell me why this
performance difference exists or what I can do to improve my regex
speeds?


THE DETAILS:

The regexes are in a file where each line (there are about 1000)
is of the form 'id regex' as in:

PS00009; .G[RK][RK]
PS00889; [LIVMF]GE.[GAS][LIVM].{5,11}R[STAQ]A.[LIVMA].[STACV]

I read the string of length about 3000 from stdin into a variable
then do a scan like this:

open(INFILE, 'regex.dat');
while(<INFILE>) {
    ($ident, $regex) = split;
    while ($seq =~ /$regex/g) {
	$start = length($');
	$len = length($&);
	print "ID $ident starts at $start (+1) for length $len\n";
    }
}

The perl5 time was worse than the perl4 time, so I generated a table
comparing them over a range of lengths (generated at random):
        perl 5         perl 5       perl4        perl4
#    without study   with study  without study  with study
1          0.66           0.80        0.40       0.45
10         0.66           0.71        0.47       0.46
30         0.67           0.74        0.47       0.47
100        0.69           0.83        0.47       0.48
300        0.78           0.89        0.52       0.54
1000       1.08           1.12        0.76       0.75
3000       2.04           2.10        1.32       1.41
10000      5.36           6.09        3.48       3.65
30000     16.10          16.01        9.84      10.28
100000    62.21          61.35       33.71      34.80
300000   271.03         282.10      103.51     102.58
1000000 2038.90           n/a         n/a      361.31   

The ratio of perl5/perl4 times ranges from a factor of 1.4 to
5.6.  The FAQ suggests that $` and $& cause a performance
hit but didn't say if that was a new perl5 problem.  Without
them the performace for unstudied perl5 is 
30000     15.08
100000    49.76
300000   148.75
which doesn't bring it into the perl4 range.

  I checked the back newgroups on altavista and found no mention
of this problem, but I find it highly unlikely no one else knows
about it.

						Andrew Dalke
						dalke@ks.uiuc.edu


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

Date: 15 Aug 1997 09:31:08 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: perl5 regexes slower than perl4?
Message-Id: <5t17ks$lit@agate.berkeley.edu>

In article <5t0phs$ks8$1@vixen.cso.uiuc.edu>,
Andrew Dalke <dalke@ks.uiuc.edu> wrote:
> The perl5 time was worse than the perl4 time, so I generated a table
> comparing them over a range of lengths (generated at random):
>         perl 5         perl 5       perl4        perl4
> #    without study   with study  without study  with study
> 1          0.66           0.80        0.40       0.45
> 10         0.66           0.71        0.47       0.46
> 30         0.67           0.74        0.47       0.47
> 100        0.69           0.83        0.47       0.48
> 300        0.78           0.89        0.52       0.54
> 1000       1.08           1.12        0.76       0.75
> 3000       2.04           2.10        1.32       1.41
> 10000      5.36           6.09        3.48       3.65
> 30000     16.10          16.01        9.84      10.28
> 100000    62.21          61.35       33.71      34.80
> 300000   271.03         282.10      103.51     102.58
> 1000000 2038.90           n/a         n/a      361.31   
> 
> The ratio of perl5/perl4 times ranges from a factor of 1.4 to
> 5.6.  The FAQ suggests that $` and $& cause a performance
> hit but didn't say if that was a new perl5 problem.  Without
> them the performace for unstudied perl5 is 
> 30000     15.08
> 100000    49.76
> 300000   148.75
> which doesn't bring it into the perl4 range.

A table of $&/no-$& vs. perl5/perl4 would be handy to recognize
problems.  Also the exact version of Perl would be interesting.  From
your table it looks like 300000 iterations gives pretty good view of
things, so you do not need to vary this number.

Chip managed to slow down RE a lot from 5.002_01 time (by making them
less buggy, there was no easy way to correct bugs without slowing
things down).  So you may want to compare
perl4/perl5.002_01/perl5.004_03 speed.  I do not think the "jumbo RE
patch" may help here, I do not recognize any optimization which may
help in your case.

You problem is that you recompile your RE each time in the loop, and
the compilation time *is* going to be slower and slower as new
optimizations are enabled.  It may be feasible to autogenerate a giant
body of while(<>) loop and evaluate it.  This would allow running your
RE without recompilation.

Hope this helps,
Ilya













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

Date: Thu, 14 Aug 1997 23:14:28 -0700
From: "Joel B. Stalder" <joel@uptimecomputers.com>
Subject: Problems with eval.
Message-Id: <33F3F3C4.C0504987@uptimecomputers.com>

Hello all,

As the subject implies, I seem to be having trouble with eval().

To cut to the chase, this is the idea:

 I have perlcode in a database that is loaded and evaled something like
this:

 my $result = eval( "package $class;\n".
                      "sub " . $class->mangle($app) . " \{\n".
                      '  my $self = shift; my $class = ref($self) ||
$self; '.
                      $fmt .
                      "\};\n1;" 
                    );
 
and then when I wish to send execution to it, I'm using:


  eval "\$self->$fmt( \$permit, \@_ );";

 
Here's the thing: Perl is treating this latter eval as if I have used
the block method, hence, its not re-compiling each time as it should.
The second time that this eval is called, its using the variable values
from the first time called, exactly as if I had used {}.


Has anyone ran across this or something similar??? I simply do not
understand it and would appreciate any thoughts that anyone might have.

thanks for your time,

joel



Summary of my perl5 (5.0 patchlevel 4 subversion 1) configuration:
  Platform:
    osname=linux, osvers=2.0.28, archname=i486-linux
    uname='linux rain.uptimecomputers.com 2.0.28 #2 fri may 23 13:24:06
pdt 1997 i486 '
    hint=recommended, useposix=true, d_sigaction=define
    bincompat3=y useperlio= d_sfio=
  Compiler:
    cc='cc', optimize='-O2', gccversion=2.7.2
    cppflags='-Dbool=char -DHAS_BOOL -I/usr/local/include'
    ccflags ='-Dbool=char -DHAS_BOOL -I/usr/local/include'
    stdchar='char', d_stdstdio=define, usevfork=false
    voidflags=15, castflags=0, d_casti32=define, d_castneg=define
    intsize=4, alignbytes=4, usemymalloc=n, randbits=31
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lndbm -lgdbm -ldb -ldl -lm -lc
    libc=/lib/libc.so.5.3.12, so=so
    useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=, ccdlflags='-rdynamic'
    cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'


Characteristics of this binary (from libperl): 
  Built under linux
  Compiled at Jun 29 1997 22:10:23
  @INC:
    /usr/lib/perl5/i486-linux/5.00401
    /usr/lib/perl5
    /usr/lib/perl5/site_perl/i486-linux
    /usr/lib/perl5/site_perl
    .


Linux rain.uptimecomputers.com 2.0.28 #2 Fri May 23 13:24:06 PDT 1997
i486


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

Date: 15 Aug 1997 05:23:19 GMT
From: "Jerry Xia" <jxia@worldnet.att.net>
Subject: Question of using stat function
Message-Id: <01bca93b$93903f40$2386410c@default>

Hi, there.

I tried to get the access permission for a file. I got file mode(big
integer number) by using stat() function. But how can I interpret that mode
in Perl? If somebody has the answer, please post it.

Thanks,
Jerry


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

Date: 15 Aug 1997 16:53:50 +1300
From: Worik Macky Stanton <w.stanton@auckland.ac.nz>
Subject: Socket problem. Works once only...
Message-Id: <wkd8nggkz5.fsf@auckland.ac.nz>

This should be very straight forward but I cannot get it to work.

I am using the client and server from the camel book.  I have two
scripts that I run in seperate dos boxes (on Win95) on the same
machine (or with the slight obvious modification on two connected
machines) and I get odd behaviour.

The first message goes fine.  I recieve "This is the message".  But I
do not get the reply. "This is the reply".

What is it that I am doing wrong?  
The server and client both work once, but not again.
This is consistent, and a show stopper!

I have included the code below

# Script 1

require "cnt.pl";
use strict;
for(;;){
    my $c;
    while(!defined $c){$c = &client;}
    my @a = ("This is the reply");
    &server(\@a);
}

# Script 2

require "cnt.pl";
use strict;
for(;;){
    my @a = ("This is the message");
    &server(\@a);
    my $c;
    while(!defined $c){$c = &client;}
}

    
#cnt.pl

use Socket;
use strict;
1;
sub client {
    my($remote, $port, $iaddr, $paddr, $proto, $line);
    $remote = shift || 'localhost';
    $port = shift || 2345;
    if($port =~ /\D/){ $port = getservbyname($port, 'tcp')}
    die "no port" unless $port;
    $iaddr = inet_aton($remote) or die "No host: $remote";
    $paddr = sockaddr_in($port, $iaddr);
    socket(SOCK,PF_INET, SOCK_STREAM, $proto) or die "socket: $!";
    connect(SOCK, $paddr) or return undef;
    while($line = <SOCK>){
	print $line;
    }
    close SOCK or die "close $!";
    return $line;
}

sub server {
    my $data = shift;
    !defined $data and die "Server created without data";
    my $port = shift || 2345;
    my $proto = getprotobyname('tcp');
    socket(Server, PF_INET, SOCK_STREAM, $proto) or die "socket: $!";
    setsockopt(Server, SOL_SOCKET, SO_REUSEADDR, pack("l",1)) 
	or die "setsockopt: $!";
    bind(Server, sockaddr_in($port, INADDR_ANY)) or die "bind: $!";
    listen(Server, SOMAXCONN) or die "listen: $!";
    my $paddr;
    print "Waiting...port $port ";
    $paddr = accept(Client, Server); 
    my($pt, $iaddr) = sockaddr_in($paddr);
    my $name = gethostbyaddr($iaddr, AF_INET);
    print "Connection from $name " . inet_ntoa($iaddr) 
	. " at port $pt\n";
    foreach(@$data){
	print Client "$_\n";
    }
    close Client;
    print "closed $name " . inet_ntoa($iaddr) . " at port $port\n";
    return 1;
}



Worik Stanton
w.stanton@auckland.ac.nz


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

Date: 15 Aug 1997 08:55:22 +0200
From: Wolfgang Schludi <schludi@syscomp.de>
Subject: THANX (was: Re: perl-5.004 on UW prob (was: Re: perl-5.003 on UW: 'make test' fails))
Message-Id: <nooh70ue91.fsf@ra.syscomp.de>


first of all: THANK YOU!!!

I got it work some days ago. Unfortunately, I have problems with
posting since some days, so I couldn't state what my (now fixed)
problem was. What I did (and what was right) was:

	sh ./Configure -dsE -Dprefix=/usr/tools
	rm -f config.old
 	mv -f config.sh config.old
 	sed -e "s/d_csh='define'/d_csh='undef'/" \
 	    -e "s/d_select='undef'/d_select='define'/" config.old > config.sh
 	rm -f config.old
	sh ./Configure -S
	LD_LIBRARY_PATH=`pwd` make depend	# necessary?
	LD_LIBRARY_PATH=`pwd` make
	LD_LIBRARY_PATH=`pwd` make test
	LD_LIBRARY_PATH=`pwd` make install

History:
=======
1) update to perl-5.004
2) fix the `d_csh' problem (found in the FAQ and thanks to Stefano Gobbo)
3) fix the `d_select' problem (thanks to Curtis K. Wong 
				     and Christopher Michael Ward)
4) IT STILL DIDN'T WORK :-( (thank me?)
5) after 2) I decided to install this version  (is a perl with 1 failed
   test better than no perl???)
6) the next day I received the `d_select' hint from Curtis K. Wong, 
   tried it and the test failed even worse than the day before. 
   I even couldn't manage to get the same behaviour that I had the 
   day before (tried endless hours :-( )


prob+sol:
========
THANKS TO Christopher Michael Ward !!!!:

Chris> Also, if you have installed the perl with the broken test, you'll have to
Chris> remove it before you run the tests again, since they will use the shared
Chris> library built and installed the first time, and not the newly compiled
Chris> one.  This little "twist" had me scratching my head for a day!

that was the final point. I think this would be a nice hint in the FAQ
(unless I read the wrong version or missed something)?

again, thank YOU ([and] the USENET-community)

	Schludi
-- 
schludi@syscomp.de


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

Date: Fri, 15 Aug 1997 10:26:38 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Uninitialized Value? Really?
Message-Id: <EEyACE.H63@world.std.com>

stampes@xilinx.com (Jeff Stampes) writes:


>   if (@platforms == ()) {@platforms = keys %platforms} ## Line 317
>   return(\@platforms,$pkg,$ver,$rid);
>}

>When I run this, I get:
>Use of uninitialized value at patch_build line 317.

>Hmmm...Sure looks like I initialized the only two values mentioned
>in like 317.  Anyone have any idea what it's bitching about?

Comparison operators, like "==" operate on scalars, not arrays or
lists. Different operators do different things when they are given a
list in a scalar context. Arrays evaluate to the number of elements in
the array. For a general list, though, it might evaluate to the first
element, or the last element, anything else.

In this case, when you try to coerce "()" into a scalar context, it is
trying to grab either the first element, (which is undefined) or the
last one (which is also undefined).

I think what you want is something like:

   if (@platforms == 0) {@platforms = keys %platforms}
or
   @platforms = keys %platforms unless @platforms;

If the number of elements in @platforms is 0, fill platforms with the
keys of the hash %platforms.


-- 
Andrew Langmead


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

Date: Fri, 15 Aug 1997 09:59:27 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Why doesn't sort take a reference any more?
Message-Id: <EEy933.92K@world.std.com>

bernie@rev.net (Bernard Cosell) writes:

>I'd been struggling a bit to try to understand what this error meant:

>   not a GLOB reference at ./call_logs.pl line 96.

>which didn't seem to make much sense.  But upon looking at the
>perlfunc man page, I discovered an interesting change from Camel 2.
>Camel 2 says "SUBNAME may be a scalar variable name (unsubscripted) in
>which case the value provides the name of (or a reference to) the
>actual subroutine to use"  That has been -removed- from perlfunc.

No version of perl 5 has ever taken a hard reference to a subroutine
as a sort paramter, even though the second edition of "Programming
Perl" said it should. I did see this brought up in the perl5porters
mailing list well before 5.004 came out, but apparently, it was never
taken on. Copies of the man pages that I have around from 5.001 and
5.002 omit the mention of a subroutine reference.

You can get the same effect by dereferencing the subref in an
anonymous block:

    sort { &$compsub } (keys %hash)

Or if you use named (rather than anonymous) subroutines, you can use
the name of the subrotine to use as a parameter.

sub foo {}
sub bar {}

$compsub = 'foo';

sort $compsub

Or you can use typeglobs (which I guess in this case is just a way of
turning an anymous sub into a named sub):

*compsub = sub { ... };
sort compsub (keys %hash)

-- 
Andrew Langmead


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

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

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