[6601] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 226 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Apr 3 10:16:38 1997

Date: Thu, 3 Apr 97 07:00:28 -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           Thu, 3 Apr 1997     Volume: 8 Number: 226

Today's topics:
     Re: 480/100 != 4.8? Help!!!!!!!!! (I R A Aggie)
     Re: Basic procedure(merge 2 files) (Tad McClellan)
     Re: db_file, hash and segv (Paul Marquess)
     Re: db_file, hash and segv (Paul Marquess)
     Discount PERL Books (Shinu Gupta)
     Re: File Locking & dbmopen <pfdemp@ark.ship.edu>
     Re: Filter: Latex to SGML problem (regular expressions) (Andreas Olsson)
     Help doing a FORK type process <allenm@lexis-nexis.com>
     Help doing a print from an array <allenm@lexis-nexis.com>
     HELP with perl array <anna@water.ca.gov>
     Re: HELP with perl array <seay@absyss.fr>
     Re: J.A.F.O. (Simon Hyde (aka Jeckyll))
     Re: J.A.F.O. <seay@absyss.fr>
     Re: MacPerl and BBedit <njoe@sbi.com>
     Re: Multiple Page Forms????? (Tad McClellan)
     Perl CGI Problem <roger@acm.vt.edu>
     Perl send warnings <msvd@pluto.mscc.huji.ac.il>
     Re: Perl send warnings <seay@absyss.fr>
     Re: Perl vs. C/C++ <seay@absyss.fr>
     Simple array question by newbie... (Alan Weiner)
     Re: Simple array question by newbie... <seay@absyss.fr>
     Re: The theoretically fastest way to iterate through al <tom@eiscat.uit.no>
     Re: Type glob/ max # of files (Tad McClellan)
     Visual Perl++????? <siuwl@acm.org>
     Where is the FAQ list? <allenm@lexis-nexis.com>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Wed, 02 Apr 1997 22:15:26 -0500
From: fl_aggie@hotmail.com (I R A Aggie)
Subject: Re: 480/100 != 4.8? Help!!!!!!!!!
Message-Id: <fl_aggie-ya02408000R0204972215260001@news.fsu.edu>

In article <33431DDD.1F6E@globalserve.net>, orange@globalserve.net wrote:

+ print 480/100;

printf "%.2f\n", 480/100;

James - this isn't a perl problem per se, but a significant digits problem

-- 
Consulting Minster for Consultants, DNRC

To cure your perl CGI problems, please look at:
<url:http://www.perl.com/perl/faq/idiots-guide.html>


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

Date: Thu, 3 Apr 1997 06:31:12 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Basic procedure(merge 2 files)
Message-Id: <gu70i5.1l.ln@localhost>

Yoshiaki Murakami (rty333@email.sps.mot.com) wrote:
: Hello!
: I just start to learn Perl.
: I can creare very simple procedure for make report from tab 
: delimitted flat type file. 
: Next, I tried to merge 2 files by 2 or more key items as below. 
: Does anybody create procedure for me?
: I don't have any sample procedure alound me. 

: (File-1)                             (File-2)
: BookName(Key);Price         BookName(Key);Auther;Volume
: Perl Basic       ;$10            Perl Basic       ;Mr.A    ;100 pages
:                              
: (Merge File-1 and File-2)
: BookName;Auther;Volume     ;Price
: --------- ------ --------- -----
: Perl Basic Mr.A    100 pages  $10


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

$f1 = 'Perl Basic       ;$10';
$f2 = 'Perl Basic       ;Mr.A    ;100 pages';

($name1, $price) = split /\s*;/, $f1;
($name2, $author, $volume) = split /\s*;/, $f2;

if ($name1 eq $name2) {
   printf("%-20s %-12s %-12s %6s\n", $name1, $author, $volume, $price);
}
-----------------------


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


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

Date: 3 Apr 1997 13:14:57 GMT
From: pmarquess@bfsec.bt.co.uk (Paul Marquess)
Subject: Re: db_file, hash and segv
Message-Id: <5i0agh$4q6@pheidippides.axion.bt.co.uk>

[Posted & Mailed]
Peter Lees (peter@junior.next.com.au) wrote:
: g'day - i'm having a problem with a hash table generated from 
: a db_file database. here is one of the programs:


: #!/usr/local/bin/perl5 -w

: use FileHandle;
: use DB_File;
: use Fcntl;

: $db1 = tie(%DB1,DB_File,"mydb1",O_RDONLY,$DBACCESS_MODE,$DB_HASH) || die($!);

: $db2 = tie(%NEWDB,DB_File,"newdb",(O_RDWR|O_CREAT),$DBACCESS_MODE,$DB_HASH) || die($!);

: STDERR->autoflush(1);

: $count = 0;
: while (($key,$val) = each %DB1)
:   {
:   $count++;
:   
:   if (! defined($key) || !defined($val))
:     {
:     print STDERR '!' ;
:     next;
:     }

This test is not needed. None of the tied DBM interfaces can store an
undefined key or value.


:   $NEWDB{$key} = $val;
:   print STDERR '.';

:   if ($count > 100)
:     { $count = 0; $db2->sync ; }
:   }

: $db2->sync;
: untie(%DBNEW);
: untie(%DB1);

If this code is part of a bigger script, you should write the unite
lines like this:


  undef $db1 ;
  undef $db2 ;
  untie(%DBNEW);
  untie(%DB1);

Read the section "The untie() Gotcha" in a newer copy of DB_File.pm to
find out why.

Also, I don't think you are gaining anything by sync'ing. 

: after about 11000 records, the program aborts with a message: Out of memory!
: this appears to happen on the READ of the database, since commenting out
: the $NEWDB{$key} = $val; had no effect.

: similarly, in another program adding a new key/value to the existing
: database (DB1) caused a segmentation violation (core was dumped).
: i wasn't sure how to examine the corefile, so i have left that for now.

: the system is IRIX 5.3 and IRIX 6.3, db file is 1.85, perl is 5.003.

: the mydb1 file is 8368128 bytes - quite large, but the system has 64MB RAM
: and 238MB swap...

: can anyone suggest what the problem could be?

There are a few problems with Berkeley DB 1.85, that have been fixed in
1.86 (available from http://www.bostic.com/db). The problem you are
having sounds like one of them. Before you decide whether to upgrade
here are a few words taken from the db home page:

    DB version 1.86 includes a new implementation of the hash access
    method that fixes a variety of hashing problems found in DB version
    1.85. We are making it available as an interim solution until DB
    2.0 is available.

    PLEASE NOTE: the underlying file format for the hash access method
    changed between version 1.85 and version 1.86, so you will have to
    dump and reload all of your databases to convert from version 1.85
    to version 1.86. If you do not absolutely require the fixes from
    version 1.86, we strongly urge you to wait until DB 2.0 is released
    before upgrading from 1.85.


DB_File 1.10 or greater supports Berkeley DB 1.86 (the latest
deveopment copy of Perl is the best place to get the most up to date
DB_File. Alternatively Perl 5.004 should be released fairly soon if you
would prefer to wait).

Once version 2 of Berkeley DB is finished, DB_File will support it as
well.

Paul


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

Date: 3 Apr 1997 13:17:16 GMT
From: pmarquess@bfsec.bt.co.uk (Paul Marquess)
Subject: Re: db_file, hash and segv
Message-Id: <5i0aks$4q6@pheidippides.axion.bt.co.uk>

[Posted & Mailed]
Armin Faltl (armin.faltl@siemens.at) wrote:
: Peter Lees wrote:
: > 
: > g'day - i'm having a problem with a hash table generated from
: > a db_file database. here is one of the programs:
: > 
: > #!/usr/local/bin/perl5 -w
: > 
: > use FileHandle;
: > use DB_File;
: > use Fcntl;
: > 
: > $db1 = tie(%DB1,DB_File,"mydb1",O_RDONLY,$DBACCESS_MODE,$DB_HASH) || die($!);
: > .......
:  
: > after about 11000 records, the program aborts with a message: Out of memory!
: > this appears to happen on the READ of the database, since commenting out
: > the $NEWDB{$key} = $val; had no effect.
: > 
: > similarly, in another program adding a new key/value to the existing
: > database (DB1) caused a segmentation violation (core was dumped).
: > i wasn't sure how to examine the corefile, so i have left that for now.
: > 
: > the system is IRIX 5.3 and IRIX 6.3, db file is 1.85, perl is 5.003.
: > 
: > the mydb1 file is 8368128 bytes - quite large, but the system has 64MB RAM
: > and 238MB swap...
: > 
: > can anyone suggest what the problem could be?
: > 

: To my knowledge, Berkely DB has a bug. It occured in our application,
: when we used large records. My solution was to switch to GDBM (GNU-DB).
: According to the rating in (in the camel book?) its somewhat slower,
: BUT IT WORKS!

The probme with large records has been fixed in Berkeley DB 1.86

Paul


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

Date: 3 Apr 1997 12:19:32 GMT
From: shinu@gti.net (Shinu Gupta)
Subject: Discount PERL Books
Message-Id: <5i078k$cj7@gti.gti.net>

         ---------------------------------------------------------
         A1Books - The Mega Discount Online Bookstore (15-30% Off)

           If you ever buy books check out http://www.a1books.com
         ---------------------------------------------------------


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

Date: Wed, 02 Apr 1997 09:46:57 -0500
From: Paul Dempsey <pfdemp@ark.ship.edu>
Subject: Re: File Locking & dbmopen
Message-Id: <33427161.5C9@ark.ship.edu>

Rex Fowler wrote:
> 
> Been there and also examined the FAQ.  Didn't quite get all I need to know.
> How do I flock() a file I don't have a handle for?  ie a dbm file that
> wasn't explicitly open()'d.
> 
>         dbmopen(%A,"/home/a/data", 0660);
>         # need to flock() something here..
>         %A{$name} = $number;
>         dbmclose(%A);
> 
I have the same problem, but I think I have a simple solution. Wouldn't
it work to flock a dummy file before you open the dbm file? Such as:

	open(INF,"dummy.txt");
	flock(INF,2);
	dbmopen(%APPT,"appts",undef);
	# write something to dbm file
	dbmclose(%APPT);
	close(INF);
	flock(INF,8);    # is this necessary if I close?

I haven't tried this yet, but it seems like it would work if all my
calls to the dbm file were done the same way. The flock would hold the
program until there was no lock on the dummy file, and then open the dbm
file.

Paul Dempsey
Shippensburg University of PA
pfdemp@ark.ship.edu
http://www.ship.edu/~pfdemp


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

Date: Thu, 03 Apr 97 15:56:17 GMT
From: cie95aol@lustudat.student.lu.se (Andreas Olsson)
Subject: Re: Filter: Latex to SGML problem (regular expressions)
Message-Id: <5i0gev$s7d$1@news.lth.se>

Hi again!

Thanks for your answers. They all worked!

As I am rather new at Perl I would really apprechiate if someone would answer 
this simple question on the same theme:

This is my input in $src:

<title>Introduction</title>
text1
<para>
text2
</para>
</chapter>
<chapter><title>Chapter 1</title>
<section><title>Chapter 2</title>
text3
<para>
text4
</para>

Now I want to insert a pair of <para>*</para> that wraps around 'text1' and 
'text2'. I use the following expression:

$src =~ s#</title>(.*?)(?!<section>)(?=(<para>)|(</chapter>)|(</section>))
         #</title><para>$2</para>\n#gsx;

The problem is that this pattern matches the </title> after 'Chapter 1' and 
the <para> after 'text3', so I get a <para> inserted between </title> and 
<section>, i.e. I wan't not the pattern to match if a <section> follows 
directly after a </title>. 

Thanks again

/Andreas Olsson
cie95aol@lustudat.student.lu.se


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

Date: Thu, 03 Apr 1997 08:37:33 -0500
From: Allen May <allenm@lexis-nexis.com>
Subject: Help doing a FORK type process
Message-Id: <3343B29D.5BFA@lexis-nexis.com>

I am trying to build a program which creates an xterm window in
UNIX as a user interface.  It prints to the xterm a list for
the user to choose from.

Can someone help me figure out hoe to run the perl code in the
forked xterm window?

Below is what I got so far.. It brings up the XTERM(c-shell) but
how do I get the print statements to come up inside the new XTERM 
window?

Thanks

-Allen

#!/serve/bin/perl -w
while (`xterm -g =60x20+350+88 -ut +sf -T 'Solaris'`) {
	system ("clear");
	$MY_MACHINE=`hostname`;
	print "Your current host workstation is: $MY_MACHINE";
	print "\n";
	print "Give me a SUN OS workstation to log into..\nThe lab machines
are:";
	print "\n";
	print "\talleyoop\n";
	print "\tduplicate\n";	
	print "\n";
	print "Remember, you need a .rhost file to run this..\n";
	print "New host: ";
	chop($NEW_HOST = <STDIN>);
	system ("xhost $NEW_HOST");
	system ("xrsh $NEW_HOST dispatch_tool");
	break;
}
     +---------------------------------------------------------------+
     |                                                 ____       _  |
     |Allen H. May                                   |__\_\_o____/_| |
     |LEXIS-NEXIS Help Desk Engineer	            <[___\_\_-----<  |
     |email - Allen.May@lexis-nexis.com              |  o'           |
     |		                                                     |
     +---------------------------------------------------------------+


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

Date: Thu, 03 Apr 1997 08:52:11 -0500
From: Allen May <allenm@lexis-nexis.com>
Subject: Help doing a print from an array
Message-Id: <3343B60B.7229@lexis-nexis.com>

I think I am making this more difficult than I should but
it's not workin'.

I have a list of users in a file called user_list. I want
to open the file as an array then get a print of each user
on the list.

I will then build on this to eventually use as an administrative
tool.  I want to audit the members of my departments' .cshrc 
files to see if they have the most current pointers.

Below is what I have so far..

Any suggestions would be appreciated.

Thanks

-Allen

 #!/serve/bin/perl
unless (open(USERS,"/home/achilles/allenm/perl/user_list")) {
        die "Sorry, can't open /home/achilles/allenm/perl/user_list\n";
}
$count=0;
@TESTS = USERS;
while (<USERS>) {
        chop;
        print (@TESTS[$count]);
        @TESTS[$count++];
}
     +---------------------------------------------------------------+
     |                                                 ____       _  |
     |Allen H. May                                   |__\_\_o____/_| |
     |LEXIS-NEXIS Help Desk Engineer	            <[___\_\_-----<  |
     |email - Allen.May@lexis-nexis.com              |  o'           |
     |		                                                     |
     +---------------------------------------------------------------+


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

Date: 2 Apr 1997 23:00:03 GMT
From: anna <anna@water.ca.gov>
To: anna@water.ca.gov
Subject: HELP with perl array
Message-Id: <5huodj$9gp$1@galileo.water.ca.gov>

Hi,
I was wondering if you could help me.

I have a large flatfile which I can open in perl.  I would like to set up 
the data in an array, so I can search the data.  The file has many 
lines.  Each line has 5 elements separated by tabs.  I would like to 
search for a particular value in element 2 and then if the value of 
element 2 is the right one, perform a calculation on element 4.

The data file has the following format:
B12345	10/01/95	00:00	2.56	85
B12345	10/01/95	12:00	4.32	85
B12345	10/05/95	00:00	5.96	85
B12345	10/05/95	12:00	3.16	85

My attempt at building an array doesn't produce the right results.  
Rather than printing  a singular value, it prints all the values for 
element 4.  See code below.

I would appreciate any help you can offer.

Thanks in advance,
Anna

anna@water.ca.gov


_____

#!/usr/local/bin/perl
$infile = B12345.txt
open(DATA,"$infile") || die "Can't open data file. \n";
@lines = <DATA>;
close(DATA);
foreach $line (@lines) {
  ($id, $date, $time, $cost, $code) = split(/\t/, $line);
	print $calc;
}





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

Date: Thu, 03 Apr 1997 15:27:23 +0100
From: Douglas Seay <seay@absyss.fr>
To: anna <anna@water.ca.gov>
Subject: Re: HELP with perl array
Message-Id: <3343CC5B.185B@absyss.fr>

anna wrote:
> 
> Hi,
> I was wondering if you could help me.
> 
> I have a large flatfile which I can open in perl.  I would like to set up
> the data in an array, so I can search the data.  The file has many
> lines.  Each line has 5 elements separated by tabs.  I would like to
> search for a particular value in element 2 and then if the value of
> element 2 is the right one, perform a calculation on element 4.
> 
> The data file has the following format:
> B12345  10/01/95        00:00   2.56    85
> B12345  10/01/95        12:00   4.32    85
> B12345  10/05/95        00:00   5.96    85
> B12345  10/05/95        12:00   3.16    85
> 
> My attempt at building an array doesn't produce the right results.
> Rather than printing  a singular value, it prints all the values for
> element 4.  See code below.
> 
> I would appreciate any help you can offer.
> 
> Thanks in advance,
> Anna
> 
> anna@water.ca.gov
> 
> _____
> 
> #!/usr/local/bin/perl
> $infile = B12345.txt
> open(DATA,"$infile") || die "Can't open data file. \n";
> @lines = <DATA>;
> close(DATA);
> foreach $line (@lines) {
>   ($id, $date, $time, $cost, $code) = split(/\t/, $line);
>         print $calc;
> }

Bug number 1 - you are not running with -w,
but that is really the fault of the Perl
development team.  it should be the default
and something like -i_want_painful_errors
to turn it off.

Bug number 2 - DATA is already a magical file
handle in Perl, don't use if for this.

Bug number 3 - this code doesn't do anything
interesting because $calc is not initialized,
nor do you use any of the data that you read
in ($date and $cost from your comments above).
When you snipped the useless stuff, you got
some good stuff too.

Bug number 4 - you don't check your close, nor do you
print the error message ($!) with die() for open().

basically that should be

#!/usr/local/bin/perl -w
use strict; # a personal favorite of mine
open(BFILE, "<B12345.txt") || die "can't open data file: $!";
my @lines = <BFILE>;
close(BFILE) || die "error with closing BFILE: $!";

my $line;
foreach $line ( @lines )
	{
	my ($id, $date, $time, $cost, $code) = split(/\t/, $line);
	if ( &interesting_day($date) )
		{ print &computation($cost), "\n"; }

	# just to avoid warnings about $id, $time and $code
	$id = 0; $time = 0; $code = 0;
	}


- doug


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

Date: Thu, 03 Apr 1997 12:19:46 GMT
From: shyde@poboxes.com (Simon Hyde (aka Jeckyll))
Subject: Re: J.A.F.O.
Message-Id: <3342f1f1.1004656@news.uni-stuttgart.de>

On Tue, 01 Apr 1997 16:31:39 -0800, James Whetstone
<james_whetstone@hp-roseville-om2-om.hp.com> wrote:

>Just Another Forking Obstacle.
>
>Yea.  I'm writin' a script as a cgi and I's needs to fork my script. 
>The problem is that I'm on a Windows NT 4.o platform and fork is not a
>supported function.  So..any ideas on how I can use the exec function
>and still allow the parent program to execute without interuption and
>without waiting for the exec'd process to terminate?

I don't know about NT 4.0 but under win 95 you can just do:
system('start perl other script');
This will wait for a while for the program to fire up (say a couple of
seconds) before returning, but is a lot better than waiting for the
program to end


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

Date: Thu, 03 Apr 1997 14:54:24 +0100
From: Douglas Seay <seay@absyss.fr>
Subject: Re: J.A.F.O.
Message-Id: <3343C4A0.1704@absyss.fr>

James Whetstone wrote:
> 
> Just Another Forking Obstacle.
> 
> Yea.  I'm writin' a script as a cgi and I's needs to fork my script.
> The problem is that I'm on a Windows NT 4.o platform and fork is not a
> supported function.  So..any ideas on how I can use the exec function
> and still allow the parent program to execute without interuption and
> without waiting for the exec'd process to terminate?

Easy.  Trash NT and install Linux :-)

I think that the hip.com folks made a thread class
so you can launch something as a separate thread
and the parent will continue.  Look around CPAN
for the module list.  Win32::Process or something
like that.

- doug

PS - I first tried mailing you, but it bounced.
Your return address is screwed up.  Your system
"hp-roseville-om2-om.hp.com" doesn't exist.
You are using misconfigured news software.


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

Date: Thu, 03 Apr 1997 09:42:24 -0500
From: Nam-June Joe <njoe@sbi.com>
To: David Goldenberg <goldenberg@bioscience.utah.edu>
Subject: Re: MacPerl and BBedit
Message-Id: <3343C1D0.36DD@sbi.com>

There is a public domain package which will facilitate a number of the
operations you need.  It is called something like BBEdit extensions
for MacPerl, and is available at any of the info-mac mirrors.
You may want to poke around at: ftp://mirror.apple.com/mirrors/info-mac
Hope this helps.

Nam

David Goldenberg wrote:
> 
>    I would like to use BBedit to write Perl scripts on the Macintosh, and
> then run them with MacPerl.  Is there a way to make BBedit and MacPerl
> interact so that it is easy to try out new versions of the script?  As
> things stand, I have to save the script and open it in MacPerl.  Since the
> script utilizes a file specified by @ARGV[], I also have to save the
> script as a dropplet and then execute it from the finder.  This is
> starting to feel a lot like compiling a C or Fortran program and then
> executing it!
>    I suspect that there is a way to use AppleScript to make all of this
> much easier, but I don't have any experience with AppleScript.
>    Also, is there a way to direct a file to STDIN with MacPerl?
> 
>    Any suggestions would be greatly appreciated.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Nam-June Joe                                 (201) 896-7784
Salomon Brothers, Inc.                       njoe@sbi.com
US Support - Applications Development

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Note: Any opinions expressed above are solely mine and do not represent
those of Salomon Brothers, Inc.


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

Date: Thu, 3 Apr 1997 06:48:25 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Multiple Page Forms?????
Message-Id: <pu80i5.pn.ln@localhost>

[
   comp.lang.perl does not exist. Please ask your sysadmin to
   remove it.

   This has nothing to do with neither Modules nor Tk. Don't abuse
   Usenet by posting to off-topic newsgroups.

   As you would pass the information exactly the same way regardless
   of what language you have used to implement your CGI program,
   this is not a perl question. It is a CGI/HTML question.

   c.l.p.m is not related to CGI nor HTML. These groups are:

   comp.infosystems.www.authoring.cgi
   comp.infosystems.www.authoring.html

]


Jonathan S Hardiman (emperor@Pathway1.pathcom.com) wrote:
: How would I go about performing the task of multiple page Web Forms???

: Here's the deal:

: On the first page I require people's Stats (i.e. address, name, e-mail,
: company, type of order and the likes). The second page informs the person
: of  how much the order they have selected costs, including shipping, and
: asks the person to verify the information that they have sent. The third
: page thanks them for the order and sends all the information to my database
: so the order can be filled.

: I know how to send the information to the database, and script the capture
: of the data.

: I guess my real question is: Do I need two scripts or can it be done with
: one?
: And, if it requires two scripts, how do I pass the information from the
: first form into hidden fields in the second?


<INPUT TYPE="hidden" NAME="price" VALUE="$100">


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


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

Date: 3 Apr 1997 14:51:57 GMT
From: "Roger Bodnar Jr." <roger@acm.vt.edu>
Subject: Perl CGI Problem
Message-Id: <01bc403e$28761ab0$8cf2ad80@iddserver>

I am running IIS 2.0 on NT 4.0 server and using perl 5.001 build 110 I
believe....I am trying to run perl scripts as cgi scripts but every time I
go to do that the brower goes to download the requested perl file instead
of executing it.  

Any thoughts?  The perl install did place a mapping for .pl files to the
perl binary in the registry..

Thanks,
Roger


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

Date: Thu, 03 Apr 1997 15:54:22 +0200
From: "Dr. Vladimir Dubnikov" <msvd@pluto.mscc.huji.ac.il>
Subject: Perl send warnings
Message-Id: <3343B68E.41C6@pluto.mscc.huji.ac.il>

Hi, everyone.
I installed PERL 5.002 on IBM RISC6000 (AIX 4.1).
However I receive warnings like:

warning: setlocale(LC_CTYPE, "") failed.
warning: LC_ALL = "(null)", LC_CTYPE = "(null)", LANG = "En_US",
warning: falling back to the "C" locale.

everytime I start PERL.


I would be very appreciate for help and advice.


     Vladimir Dubnikov.


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

Date: Thu, 03 Apr 1997 15:35:56 +0100
From: Douglas Seay <seay@absyss.fr>
To: "Dr. Vladimir Dubnikov" <msvd@pluto.mscc.huji.ac.il>
Subject: Re: Perl send warnings
Message-Id: <3343CE5C.52A2@absyss.fr>

Dr. Vladimir Dubnikov wrote:
> 
> Hi, everyone.
> I installed PERL 5.002 on IBM RISC6000 (AIX 4.1).
> However I receive warnings like:
> 
> warning: setlocale(LC_CTYPE, "") failed.
> warning: LC_ALL = "(null)", LC_CTYPE = "(null)", LANG = "En_US",
> warning: falling back to the "C" locale.
> 
> everytime I start PERL.
> 
> I would be very appreciate for help and advice.
> 
>      Vladimir Dubnikov.


I had the same thing until I got around to
defining all the LC variables.  Now my
 .bashrc contains

export  LANG=C
export  LC_ALL=C
export  LC_COLLATE=C
export  LC_CTYPE=C
export  LC_MESSAGES=C
export  LC_MONETARY=C
export  LC_NUMERIC=C
export  LC_TIME=C

at least I think that is what fixed it for me,
it has been a while.

- doug


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

Date: Thu, 03 Apr 1997 14:05:00 +0100
From: Douglas Seay <seay@absyss.fr>
To: Dan Corbett <dcorbett@jcaho.org>
Subject: Re: Perl vs. C/C++
Message-Id: <3343B90C.70D9@absyss.fr>

Dan Corbett wrote:
> 
> I am evaluating languages to use for creating a program to basically
> read in a file, parse out some text, and rewrite the file. Eventually
> this data will be uploaded into a database. Obviously, this can be done
> in C/C++. Perl got thrown into the into the mix (this will be written on
> an HP-9000), and I was wondering if anyone could help me with selling
> points of Perl, such as:
> 
>         1) How easy is it to learn?

Depends.  Is C easy to learn?  For me, the first two weeks of
using Perl were difficult.  After that, I understood what most
of the line noise ment.  Perl won't be too bad for any one who
already knows at least one shell and C.  General Unix background
such as lotsa shells, awk, sed, and so on go a long way with
Perl.  But even if your people have never touched Unix, Perl
isn't that bad.  The Camel (ISBN 1-56592-149-6) has a section
on known gotchas for newbies.


>         2) How well does it handle files and strings?

Best that I've seen.  While I have never used snobol, I have
used REXX (another scripting language).  One of the reasons
Perl was written was to avoid some of the file limitations
of awk.  BTW- you do know that Perl stands for Practical
Extraction and Report Language (or Pathelogically Eclectic
Rubbish Lister, take your pick).


>         3) What about support and documentation?

There is no "support" if you're thinking about paying someone
o help you (although I'll take your money if you want).  This
newsgroup answers any reasonable question and too many of the
unreasonable ones.  The docs are without exception the best
I've seen.  There is a great book from O'Reilly written by
the author of the language (L.Wall) and several of the top
gurus (R.Schwartz, T.Christiansen, S.Potter).  TomC has a web
site at www.perl.com that has lots of info.  Most anyone who
writes a useful library publishes/distributes it via CPAN
(details at www.perl.com).  Bug fixes are kinda rare because
of the excellent beta test program.  Most of the bugs in Perl
that get posted are followed up with "fixed in release 5.xxx",
and this find_bug/fix_bug cycle is faster than for any major
company's software release cycle.  I have never seen any
major (unusable) bug in a release of Perl.


>         4) What about all this CGI and webserver stuff, etc.

What about CGI?  That is a protocol for web browsers and
web servers to exchange info.  Perl has a library for this.
But please don't start thinking that Perl and CGI are somehow
related.  I've used Perl for years and I've never touched
a single line of web stuff.  Yes, you can do CGI in Perl.
Perhaps Perl is the best CGI language around (I surely don't
know).  But Perl != CGI.


> I have looked quite a bit for this info (so you don't think I'm
> completely lazy), but was hoping to get an opinion from someone who has
> used Perl and C. Any help would be greatly appreciated.

You might not be lazy, but you didn't look too hard.  Most
every posting that isn't a quesiton has a reference to the
FAQ or www.perl.com somewhere in it.

C is a great language, but it sucks for strings.  If you
want to sling strings all day long and you picked C, I'd
say that you some sort of pain freak.  Perl has a great
supply of regular expressions for doing pattern manipulation
and so on.

There is a "Perl vs. the world" section at www.perl.com
that gives the strengths (and weakness) of Perl.  You might
want to read it.

- doug

PS - you earn brownie points for not trying ask if Perl is
better/worse than Java.


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

Date: 3 Apr 1997 13:28:10 GMT
From: alweiner@clark.net (Alan Weiner)
Subject: Simple array question by newbie...
Message-Id: <5i0b9a$qdt@clarknet.clark.net>

I've written a simple subroutine which inputs a month and returns the 
next month.  However, it doesn't seem to work :)  

1) Is there a better way to do this?
2) What am I doing wrong?

Here's what I've got:


@months=("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","No
v","Dec","Jan");

$nxtMonth=getNxtMonth("Mar");
print "$nxtMonth";

sub getNxtMonth {
local($thisMonth)=@_;
foreach (@months) {
    if($thisMonth == $_) {
            return ($months[$#months+1]);
            }
    }
}

Thanx for any help you can provide!  Pls post the answer here...




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

Date: Thu, 03 Apr 1997 15:33:28 +0100
From: Douglas Seay <seay@absyss.fr>
To: Alan Weiner <alweiner@clark.net>
Subject: Re: Simple array question by newbie...
Message-Id: <3343CDC8.7510@absyss.fr>

Alan Weiner wrote:
> 
> I've written a simple subroutine which inputs a month and returns the
> next month.  However, it doesn't seem to work :)
> 
> 1) Is there a better way to do this?
> 2) What am I doing wrong?
> 
> Here's what I've got:
> 
> @months=("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","No
> v","Dec","Jan");
> 
> $nxtMonth=getNxtMonth("Mar");
> print "$nxtMonth";
> 
> sub getNxtMonth {
> local($thisMonth)=@_;
> foreach (@months) {
>     if($thisMonth == $_) {
                 ^^^^^^^
You are doing numeric comparison on a non-numeric
field.  You should use "eq" and "-w" as an option.

>             return ($months[$#months+1]);
>             }
>     }
> }
> 
> Thanx for any help you can provide!  Pls post the answer here...


Another way would be to initialize a hash table
with current=>next pairs and just do a hash lookup

%nextmonth = 
	'Jan'	=> 'Feb',
	'Feb	=> 'Mar',
		.
		.

return $nextmonth{$thisMonth} || "couldn't find month '$thisMonth'";

- doug

PS - comp.lang.perl doesn't exist anymore,
although you have to be at least the third
person who has used it today.


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

Date: 03 Apr 1997 15:13:31 +0200
From: Tom Grydeland <tom@eiscat.uit.no>
Subject: Re: The theoretically fastest way to iterate through all bytes in a string...?
Message-Id: <trlo70w8p0.fsf@eiscat.uit.no>

Eryq <eryq@enteract.com> writes:

> Let's say I have a long string, and I want to perform a
> mathematical operation on each byte in the string (regarded
> as a 0-255 value)... no modification involved, just an update
> of a running total (no it's not a checksum, but something like
> that.)  What, in theory, is the fastest way to do this? 
> 
> 	* a "for" loop with substr()? or unpack()? 
> 	* a while (m/./s)?
> 	* others?

Try it out ... :-)

On an otherwise idle Ultra, I achieved the following bencmarks:

% cat tester
#!/usr/local/bin/perl -w

use Benchmark;


timethese(2000, {
    'while'      => '$tot = 0;$_ = "12345" x 200;
                    while(/(.)/g) {$tot += $1}',
    'for/unpack' => '$tot = 0;$_ = "12345" x 200;
                    for (unpack "C*", $_) {$tot += $_}',
    'for/match'  => '$tot = 0;$_ = "12345" x 200;
                    for (/./gs) {$tot += $_}',
    'for/split'  => '$tot = 0;$_ = "12345" x 200;
                    for (split //, $_) {$tot += $_}',
    'map/match'  => '$tot = 0;$_ = "12345" x 200;
                    map {$tot += $_} /./gs',
    'map/unpack' => '$tot = 0;$_ = "12345" x 200;
                    map {$tot += $_} unpack "C*", $_',
    'map/split'  => '$tot = 0;$_ = "12345" x 200;
                    map {$tot += $_} split //, $_',
});

timethese(200, {
    'while'      => '$tot = 0;$_ = "12345" x 2000;
                    while(/(.)/g) {$tot += $1}',
    'for/unpack' => '$tot = 0;$_ = "12345" x 2000;
                    for (unpack "C*", $_) {$tot += $_}',
    'for/match'  => '$tot = 0;$_ = "12345" x 2000;
                    for (/./gs) {$tot += $_}',
    'for/split'  => '$tot = 0;$_ = "12345" x 2000;
                    for (split //, $_) {$tot += $_}',
    'map/match'  => '$tot = 0;$_ = "12345" x 2000;
                    map {$tot += $_} /./gs',
    'map/unpack' => '$tot = 0;$_ = "12345" x 2000;
                    map {$tot += $_} unpack "C*", $_',
    'map/split'  => '$tot = 0;$_ = "12345" x 2000;
                    map {$tot += $_} split //, $_',
});

timethese(20, {
    'while'      => '$tot = 0;$_ = "12345" x 20000;
                    while(/(.)/g) {$tot += $1}',
    'for/unpack' => '$tot = 0;$_ = "12345" x 20000;
                    for (unpack "C*", $_) {$tot += $_}',
    'for/match'  => '$tot = 0;$_ = "12345" x 20000;
                    for (/./gs) {$tot += $_}',
    'for/split'  => '$tot = 0;$_ = "12345" x 20000;
                    for (split //, $_) {$tot += $_}',
    'map/match'  => '$tot = 0;$_ = "12345" x 20000;
                    map {$tot += $_} /./gs',
    'map/unpack' => '$tot = 0;$_ = "12345" x 20000;
                    map {$tot += $_} unpack "C*", $_',
    'map/split'  => '$tot = 0;$_ = "12345" x 20000;
                    map {$tot += $_} split //, $_',
});

% tester
Benchmark: timing 2000 iterations of for/match, for/split, for/unpack, map/match, map/split, map/unpack, while...
 for/match: 64 secs (36.11 usr  0.00 sys = 36.11 cpu)
 for/split: 70 secs (38.71 usr  0.00 sys = 38.71 cpu)
for/unpack: 29 secs (16.29 usr  0.00 sys = 16.29 cpu)
 map/match: 82 secs (45.56 usr  0.00 sys = 45.56 cpu)
 map/split: 86 secs (48.06 usr  0.00 sys = 48.06 cpu)
map/unpack: 44 secs (24.64 usr  0.00 sys = 24.64 cpu)
     while: 103 secs (57.40 usr  0.00 sys = 57.40 cpu)
Benchmark: timing 200 iterations of for/match, for/split, for/unpack, map/match, map/split, map/unpack, while...
 for/match: 66 secs (36.61 usr  0.02 sys = 36.63 cpu)
 for/split: 70 secs (39.22 usr  0.00 sys = 39.22 cpu)
for/unpack: 29 secs (16.17 usr  0.01 sys = 16.18 cpu)
 map/match: 89 secs (49.44 usr  0.03 sys = 49.47 cpu)
 map/split: 91 secs (51.14 usr  0.00 sys = 51.14 cpu)
map/unpack: 54 secs (29.70 usr  0.00 sys = 29.70 cpu)
     while: 104 secs (58.01 usr  0.00 sys = 58.01 cpu)
Benchmark: timing 20 iterations of for/match, for/split, for/unpack, map/match, map/split, map/unpack, while...
 for/match: 69 secs (36.83 usr  0.20 sys = 37.03 cpu)
 for/split: 75 secs (39.95 usr  0.00 sys = 39.95 cpu)
for/unpack: 31 secs (17.03 usr  0.02 sys = 17.05 cpu)
 map/match: 95 secs (50.54 usr  0.06 sys = 50.60 cpu)
 map/split: 97 secs (53.71 usr  0.00 sys = 53.71 cpu)
map/unpack: 54 secs (29.76 usr  0.00 sys = 29.76 cpu)
     while: 70 secs (57.82 usr  0.00 sys = 57.82 cpu)

%


(Don't know if that operation is representative of what you want to do,
but I tried keeping it simple to emphasize the time of the looping
construct.)

the unpack solutions are clearly superior to the (approximately equal)
m// and split solutions, and foreach seems to be better than map.

I would have expected the while() solution to gain the longer the string,
since it avoids the overhead of a gigantic temporary array.  And indeed,
the for/* and map/* solutions degrade on the longer (100k) strings, while
while() improves (!).  However, it's still worse than for/unpack.

OTOH, to avoid that temp. array, only the m//g will be usable, since it
keeps track of its position in the string.  This is slower than unpack.

Looking for the crossover point, I tried

% cat tester
#!/usr/local/bin/perl -w


use Benchmark;
 
timethese(20, {
    'while'      => '$tot = 0;$_ = "12345" x 200000;
                    while(/(.)/g) {$tot += $1}',
    'for/unpack' => '$tot = 0;$_ = "12345" x 200000;
                    for (unpack "C*", $_) {$tot += $_}',
});

% tester
Benchmark: timing 20 iterations of for/unpack, while...
for/unpack: 1450 secs (172.08 usr 11.48 sys = 183.56 cpu)
     while: 620 secs (615.73 usr  0.02 sys = 615.75 cpu)

So indeed, for these (1MB) strings, while() is better (due to paging,
notice how the cpu time is still a fourth of the while solution).
I guess the optimal solution for such long strings would be substr()ing
to managable chunks (optimal size depending on memory) and for/unpack.

YMMV,

>   ___  _ _ _   _  ___ _   Eryq (eryq@enteract.com)

-- 
//Tom Grydeland <Tom@nospam.eiscat.no>  # delete 'nospam.' for valid address
                The case of Randal Schwartz - http://www.lightlink.com/fors/


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

Date: Thu, 3 Apr 1997 06:41:14 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Type glob/ max # of files
Message-Id: <ah80i5.tm.ln@localhost>

Pat Doran (stcpjd@micro.lucent.com) wrote:
: Help me if you can.....

Help yourself with the free documentation that is included
with the perl distribution  ;-)


: I have a simple PERL script that uses a type glob to count the number of
                                          ^^^^^^^^^

You meant filename glob. Type glob is something else (symbol table magic).


: files in a directory older than certain age. It seems to work fine for all
: my directory's except one. This directory also has a HUGE amount of small
: files !!!! 

: Is there a limit to the number of files that perl can loop through (this
             ^^^^^        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

No. There _is_, however, a limit to how many files the csh (that
perl calls to do the globbing) can handle.

Word searching for 'glob' eventually leads to this in the perlop man page:

------------------
Because globbing invokes a shell, it's often faster to call readdir() yourself
and just do your own grep() on the filenames.  Furthermore, due to its current
implementation of using a shell, the glob() routine may get "Arg list too
long" errors (unless you've installed tcsh(1L) as F</bin/csh>).
------------------

So use opendir(), readdir(), and grep() instead.


: does not seem to make sense) or is my script messed up (I am hoping this is
: the case) ??? 


: please email me some help at stcpjd@micro.lucent.com

please read the newsgroup at comp.lang.perl.misc


: Below is my script......

[ snip code ]


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


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

Date: Thu, 03 Apr 1997 22:03:17 -0800
From: Josef Siu-wai Leung <siuwl@acm.org>
Subject: Visual Perl++?????
Message-Id: <334499A5.4A55@acm.org>

I saw a news message in this newsgroup that Microsoft is going to release 
a Perl++ product. BUT I failed to find the relevant news from 
www.microsoft.com.  Please post a note if you find any evidence to proof 
or disproof.  Thanks.


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

Date: Thu, 03 Apr 1997 08:29:05 -0500
From: Allen May <allenm@lexis-nexis.com>
Subject: Where is the FAQ list?
Message-Id: <3343B0A1.F32@lexis-nexis.com>

I just picked up the camel book and there is a reference to
a FAQ on comp.lang.perl.misc.  I didn't see it listed here...
I whent to www.perl.com/perl/faq and didn't have much luck.
Can someone re-post it so I can take a look?

Thanks

-Allen

     +---------------------------------------------------------------+
     |                                                 ____       _  |
     |Allen H. May                                   |__\_\_o____/_| |
     |LEXIS-NEXIS Help Desk Engineer	            <[___\_\_-----<  |
     |email - Allen.May@lexis-nexis.com              |  o'           |
     |		                                                     |
     +---------------------------------------------------------------+


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

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

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