[11845] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5445 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Apr 21 20:07:34 1999

Date: Wed, 21 Apr 99 17:00:15 -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           Wed, 21 Apr 1999     Volume: 8 Number: 5445

Today's topics:
    Re: Arrays problem <ebohlman@netcom.com>
        can't locate Sybase/DBLIB in @INC (Alan)
    Re: cookies & perl <cassell@mail.cor.epa.gov>
    Re: elegant way of assembling array of arrays? (Tramm Hudson)
    Re: FAQ 4.9: Why aren't my random numbers random? <cassell@mail.cor.epa.gov>
        Help! Error message when using C-comment stripper from  (James R. Goodfriend)
    Re: How to join <jglascoe@giss.nasa.gov>
        How to make an array name to be a variable? du_bing@my-dejanews.com
    Re: How to make an array name to be a variable? <tchrist@mox.perl.com>
    Re: how to merge? <gellyfish@gellyfish.com>
    Re: last item in associative array. <juex@my-dejanews.com>
    Re: Perl 'split' function in C?? (Krusty276)
        Please help!! <cuksa@cuksa.monisys.ca>
    Re: string -> Create SQL Statements? <ebohlman@netcom.com>
    Re: Tell where lib file is <cassell@mail.cor.epa.gov>
    Re: Verifying text in a string <jglascoe@giss.nasa.gov>
    Re: Verifying text in a string (Larry Rosler)
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Wed, 21 Apr 1999 23:06:49 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Arrays problem
Message-Id: <ebohlmanFAKAvD.E82@netcom.com>

[followups limited to comp.lang.perl.modules]

Greg Griffiths <greg2@surfaid.org> wrote:
: 	I've just been forced into a corner over the use of the mailserver for
: my project, i.e. I must use the Unix SendMail command for my project due
: to server security issues, however my system using the Windows ODBC.pm
: package. So I am going to call the send mail routine on teh server from
: a Windows server, to do this I need help.

Couldn't you just use SMTP (using Net::SMTP, of course) to talk to the 
sendmail on the Unix box?  (note: I'm *not* talking about using SMTP to 
talk to the final destination systems directly.)



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

Date: Wed, 21 Apr 1999 23:33:29 GMT
From: arich@u.washington.edu (Alan)
Subject: can't locate Sybase/DBLIB in @INC
Message-Id: <371e6020.28032658@news.u.washington.edu>

I'm a Sybperl newbie and just copied the latest Sybperl to my NT, but
when I tried to run a script, I get a "can't locate Sybase/DBLIB in
@INC" error.  Is there some config I need to do?


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

Date: Wed, 21 Apr 1999 16:14:03 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: cookies & perl
Message-Id: <371E5BBB.65BD42AB@mail.cor.epa.gov>

Lars Plessmann wrote:
> 
> is it possible to read the cookies of a browser by perl?
> if so, how can I do that? (larsplessmann@gmx.de)

Even with the words "by perl" in your post, this is not
really a Perl question.  It can be done in any language
using the CGI spec.

That said, you might be interested to know that the CGI.pm
module will do this and a lot of other nice stuff for you.
So will several other modules, all of which are available
at CPAN.

For further information on reading cookies and related topics,
try asking at comp.infosystems.www.authoring.cgi .

HTH,
David
-- 
David Cassell, OAO                               
cassell@mail.cor.epa.gov
Senior Computing Specialist                          phone: (541)
754-4468
mathematical statistician                              fax: (541)
754-4716


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

Date: 21 Apr 1999 13:21:53 -0600
From: hudson@swcp.com (Tramm Hudson)
Subject: Re: elegant way of assembling array of arrays?
Message-Id: <7fl8gh$5p@llama.swcp.com>

[cc'd to cited author, even though he is so rude as to not include
 instructions with his trivially scrambled address]

Burton Kent  <burton.not.spam@lucent.com> wrote:
> I have a list of strings, such as:
>   @stringlist = [ "one two three", "eleven twelve thirteen", "twentyone"];
                  ^
                  |
                  +--- Probably not what you want:

DB<3> x @list = ['foo','bar']
0  ARRAY(0x80cf1ac)
   0  'foo'
   1  'bar'

See the perllol POD page for more info.


> which I would like to convert to a list of lists such as:
>   @stringlistlist [ ["one", "two", "three"], ["eleven", "twelve", "thirteen"],
> ["twentyone"] ];

So you want to map split // onto each element of @stringlist and return
a list of each of those lists.

#!/usr/bin/perl -w
use strict;

my @stringlist = ( "one two three", "elevent twelve thirteen", "twentyone");
my @lol = map { [split / / => $_] } @stringlist;
__END__

Share and enjoy!
Tramm
-- 
  o   hudson@swcp.com                 tbhudso@cs.sandia.gov   O___|   
 /|\  http://www.swcp.com/~hudson/          H 505.266.59.96   /\  \_  
 <<   KC5RNF @ N5YYF.NM.AMPR.ORG            W 505.284.24.32   \ \/\_\  
  0                                                            U \_  | 


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

Date: Wed, 21 Apr 1999 15:26:14 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
To: orwant@media.mit.edu
Subject: Re: FAQ 4.9: Why aren't my random numbers random?
Message-Id: <371E5086.B8EE6908@mail.cor.epa.gov>

[cc to Jon Orwant re his code at the bottom]

Tom Christiansen wrote:
> 
> [snip of text I like]

>     If you want numbers that are more random than `rand' with `srand'
>     provides, you should also check out the Math::TrulyRandom module
>     from CPAN. It uses the imperfections in your system's timer to
>     generate random numbers, but this takes quite a while.
      The Math::TrulyRandom module has not been fully evaluated for
      randomness, and may only produce a sequence of chaotic numbers.
      Caveat utor.

>                                                            If you want
>     a better pseudorandom generator than comes with your operating
>     system, look at ``Numerical Recipes in C'' at http://www.nr.com/ .
      This may be a serious problem, since many OSes use as their rand()
      the mediocre generator put forth by the ANSI C committee as an
      example.  This can be evaluated using the following code
      written for The Perl Journal by Jon Orwant:

#!/usr/bin/perl -w

use Config;

print "Your random number generator repeats itself after\n";
print "no more than ", 2 ** $Config{randbits}, " numbers.\n";

srand(1);

if (int(rand() * (2 ** $Config{randbits})) == 16838) {
    print "Uh oh!  Looks like your computer uses the ANSI example.\n"
    print "I bet the next three numbers are 5758, 10113, and 17515.\n";
    foreach (1,2,3) {
        print rand() * (2 ** $Config{randbits}), "\n";
    }
}


[And my apologies if Jon doesn't want his code inserted into the FAQ]

David
-- 
David Cassell, OAO                               
cassell@mail.cor.epa.gov
Senior Computing Specialist                          phone: (541)
754-4468
mathematical statistician                              fax: (541)
754-4716


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

Date: 21 Apr 1999 23:04:37 GMT
From: GoodfriB@jntf.osd.mil (James R. Goodfriend)
Subject: Help! Error message when using C-comment stripper from perlfaq
Message-Id: <7flli5$5k2$1@news1.rmi.net>

Greetings,

	I'm using the massive regular expression listed in perlfaq6 to strip 
out the comments from a C file.  (I won't repeat my code here since mine 
exactly the same).  When I run this using -w I get the following error message:

Use of uninitialized value at (program) line 19, <CFILE> chunk 1.

	...this shows up about 20 times.  Can anyone tell me what I can do to 
suppress this damn message?  It's driving me slowly insane...

	Email preferred.  Thanks!

				-Bob

ps. I'd copy a code chunk, but all my code is on a (government) secret machine 
and I don't feel like manually typing it out...it really does look exactly like 
the faq.





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

Date: Wed, 21 Apr 1999 18:23:51 -0400
From: Jay Glascoe <jglascoe@giss.nasa.gov>
Subject: Re: How to join
Message-Id: <371E4FF7.F9F1CD7F@giss.nasa.gov>

This is how we join, say, NY Perl Mongers:

echo 'subscribe ny' | mail majordomo@lists.pm.org


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

Date: Wed, 21 Apr 1999 21:59:55 GMT
From: du_bing@my-dejanews.com
Subject: How to make an array name to be a variable?
Message-Id: <7flhop$tsd$1@nnrp1.dejanews.com>

Hi,

I want an array name to be a variable.  For example, in the following code,
$array could be either 'test1' or 'test2' depending on the input to the code.

%test1 = (one,1,two,2);
%test2 = (three, 3, four, 4);

foreach $key (keys %$array)
  {
   print "$key: $($array){$key}\n";
                ---------
  }
}

The underlined part gave me the syntax error?  Any ideas?
Thank you,

Bing


-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: 21 Apr 1999 16:42:49 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: How to make an array name to be a variable?
Message-Id: <371e5469@cs.colorado.edu>

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

In comp.lang.perl.misc, du_bing@my-dejanews.com writes:
:I want an array name to be a variable.  

No, you don't.  You think you do.  And you're wrong.  Those are
the meanest words anyone can ever say to you, and I am sure the
shutters of your mind have just slammed shut.  You will not
hear a word I say.

Ok, I'll try again....

"Easy!  Just use a hash!".

There?  Is your mind open again?

By the way, you're also using a funny name for a hash.

For example, in the following code,
:$array could be either 'test1' or 'test2' depending on the input to the code.
:
:%test1 = (one,1,two,2);
:%test2 = (three, 3, four, 4);
:
:foreach $key (keys %$array)
:  {
:   print "$key: $($array){$key}\n";
:                ---------
:  }
:}
:
:The underlined part gave me the syntax error?  Any ideas?

Because it is not valid syntax.  Of course.

Listen: what you want is a hash of hashes.  Nothing more.  Watch.

    %hash = (
	test1 => {
	    one => 1,
	    two => 2,
	}, 
	test2 => {
	    three => 3,
	    four  => 4,
	}, 
    );

$hash{test1}{one} is 1.  $hash{test2}{three} is 2.  Bingo.  End of story.
Facilmsimo.

I don't know why people are always thinking about this problem in a
broken way.  I really don't.  This question is asked every day around
here.  And no, I am not exaggerating. 

If you know why people want to do the wrong thing, tell me.  Meanwhile,
read the long answer from the FAQ.

=head2 How can I use a variable as a variable name?

Beginners often think they want to have a variable contain the name
of a variable.

    $fred    = 23;
    $varname = "fred";
    ++$$varname;         # $fred now 24

This works I<sometimes>, but it is a very bad idea for two reasons.

The first reason is that they I<only work on global variables>.
That means above that if $fred is a lexical variable created with my(),
that the code won't work at all: you'll accidentally access the global
and skip right over the private lexical altogether.  Global variables
are bad because they can easily collide accidentally and in general make
for non-scalable and confusing code.

Symbolic references are forbidden under the C<use strict> pragma.
They are not true references and consequently are not reference counted
or garbage collected.

The other reason why using a variable to hold the name of another
variable a bad idea is that the question often stems from a lack of
understanding of Perl data structures, particularly hashes.  By using
symbolic references, you are just using the package's symbol-table hash
(like C<%main::>) instead of a user-defined hash.  The solution is to
use your own hash or a real reference instead.

    $fred    = 23;
    $varname = "fred";
    $USER_VARS{$varname}++;  # not $$varname++

There we're using the %USER_VARS hash instead of symbolic references.
Sometimes this comes up in reading strings from the user with variable
references and wanting to expand them to the values of your perl
program's variables.  This is also a bad idea because it conflates the
program-addressable namespace and the user-addressable one.  Instead of
reading a string and expanding it to the actual contents of your program's
own variables:

    $str = 'this has a $fred and $barney in it';
    $str =~ s/(\$\w+)/$1/eeg;		  # need double eval

Instead, it would be better to keep a hash around like %USER_VARS and have
variable references actually refer to entries in that hash:

    $str =~ s/\$(\w+)/$USER_VARS{$1}/g;   # no /e here at all

That's faster, cleaner, and safer than the previous approach.  Of course,
you don't need to use a dollar sign.  You could use your own scheme to
make it less confusing, like bracketed percent symbols, etc.

    $str = 'this has a %fred% and %barney% in it';
    $str =~ s/%(\w+)%/$USER_VARS{$1}/g;   # no /e here at all

Another reason that folks sometimes think they want a variable to contain
the name of a variable is because they don't know how to build proper
data structures using hashes.  For example, let's say they wanted two
hashes in their program: %fred and %barney, and to use another scalar
variable to refer to those by name.

    $name = "fred";
    $$name{WIFE} = "wilma";     # set %fred

    $name = "barney";           
    $$name{WIFE} = "betty";	# set %barney

This is still a symbolic reference, and is still saddled with the
problems enumerated above.  It would be far better to write:

    $folks{"fred"}{WIFE}   = "wilma";
    $folks{"barney"}{WIFE} = "betty";

And just use a multilevel hash to start with.

The only times that you absolutely I<must> use symbolic references are
when you really must refer to the symbol table.  This may be because it's
something that can't take a real reference to, such as a format name.
Doing so may also be important for method calls, since these always go
through the symbol table for resolution.

In those cases, you would turn off C<strict 'refs'> temporarily so you
can play around with the symbol table.  For example:

    @colors = qw(red blue green yellow orange purple violet);
    for my $name (@colors) {
        no strict 'refs';  # renege for the block
        *$name = sub { "<FONT COLOR='$name'>@_</FONT>" };
    } 

All those functions (red(), blue(), green(), etc.) appear to be separate,
but the real code in the closure actually was compiled only once.

So, sometimes you might want to use symbolic references to directly
manipulate the symbol table.  This doesn't matter for formats, handles, and
subroutines, because they are always global -- you can't use my() on them.
But for scalars, arrays, and hashes -- and usually for subroutines --
you probably want to use hard references only.
-- 
BTL didn't really have a distribution policy in the early days,
you got a disk with a note: Here's your rk05, Love Dennis.  If UNIX
crapped on your rk05, you'd write to Dennis for another.
 --Andy Tannenbaum, "Politics of UNIX," Washington, DC USENIX Conference, 1984


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

Date: 21 Apr 1999 22:13:31 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: how to merge?
Message-Id: <7fliib$v7$1@gellyfish.btinternet.com>

On Wed, 21 Apr 1999 19:39:07 GMT bing-du@tamu.edu wrote:
> Hello,
> 
> I know how to use 'split' to cut a string.  How to merge all the elements (but
> seperated by space) of a list?
> 

Whilst generally you will want to use join you should also bear in mind
that when an array is interpolated into a double quoted string the elements
will be separated by the value of $" (the default is a single space).

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>


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

Date: Wed, 21 Apr 1999 15:16:20 -0700
From: "J|rgen Exner" <juex@my-dejanews.com>
Subject: Re: last item in associative array.
Message-Id: <7flil2$7pj@news.dns.microsoft.com>

Multimax <multimax@mulmax.com> wrote in message
news:multimax-2104991608420001@read-rfc1918-for-details.iana.net...
> How can I find the last item in an associative array?
>
> Is there an equivalent of $#myArray (the last item in @myArray)?

Do you mean a hash?
There is no last element. A hash is a mapping from domain to codomain.
Asking for the last element of a hash is just as useful as asking for the
last element of the faculty function.

Even in the actual implementation the elements of a hash are stored in a
random (although fixed) order.

jue
--
J|rgen Exner





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

Date: 21 Apr 1999 22:53:03 GMT
From: krusty276@aol.com (Krusty276)
Subject: Re: Perl 'split' function in C??
Message-Id: <19990421185303.27570.00000185@ng05.aol.com>

Yeah, thanks, I should have see strtok(), I've never used that funciton before.
 It looks like a good match.

As for the Perl is 10 times faster to write stuff.  C is more than 10 times
faster in run time, even if you use that perl to c thing, pcc or whatever that
thing is.
>
>You could always use strtok() from strings.h
>
>-Ken
>




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

Date: Wed, 21 Apr 1999 19:09:12 -0400
From: CUKSA <cuksa@cuksa.monisys.ca>
Subject: Please help!!
Message-Id: <371E5A97.5B729A3E@cuksa.monisys.ca>


--------------BE34073096069B7DE41CF3F9
Content-Type: text/plain; charset=EUC-KR
Content-Transfer-Encoding: 7bit

hello!

I am using sendmail to send messages to our member.
but when I try to send messsage to just a couple of people then it works
fine
but as the members grow(about 50 people), now it doesn't send mail and
give me an
error message like below.
Here is part of my code and error msg..
Please Please help!
Thanks in Advance!!!



code:

tie (%myDB, DB_File, "mailinglist.db", O_CREAT, 0666, $DB_HASH)
                || die "Can\'t open db file\n";

@emails = (keys %myDB);

foreach $email (@emails){
$name = $myDB{$email};
$sub = param("subject");
$con = param("content");
$con =~ s/\$name/$name/g;
open (MAIL, "|/usr/lib/sendmail -t");
print MAIL "To: $_\n";
print MAIL "From: CUKSA <cuksa>\n";
print MAIL "subject: $sub\n";
print MAIL "\n$con\n";
print MAIL "======================================\n";
print MAIL "http://cuksa.monisys.ca/\n";
close (MAIL);

}
untie %myDB;



a part of Error msg

Cannot open hash database /etc/maps/naturalsmile.com.db: Too many open
files in
system
Cannot open hash database /etc/maps/playerexpo.com.db: Too many open
files in sy
stem
Cannot open hash database /etc/maps/digitalclassified.net.db: Too many
open file
s in system
Cannot open hash database /etc/maps/1for1.com.db: Too many open files in
system
Cannot open hash database /etc/maps/distinctmedical.com.db: Too many
open files
in system
Cannot open hash database /etc/maps/datanet.com.db: Too many open files
in syste
m
Cannot open hash database /etc/maps/advtech.org.db: Too many open files
in syste
m
Can't create transcript file xfTAA08287: Too many open files in system
Can't open /dev/null: Too many open files in system

--------------BE34073096069B7DE41CF3F9
Content-Type: text/html; charset=EUC-KR
Content-Transfer-Encoding: 7bit

<HTML>
<FONT SIZE=-1>hello!</FONT><FONT SIZE=-1></FONT>

<P><FONT SIZE=-1>I am using sendmail to send messages to our member.</FONT>
<BR><FONT SIZE=-1>but when I try to send messsage to just a couple of people
then it works fine</FONT>
<BR><FONT SIZE=-1>but as the members grow(about 50 people), now it doesn't
send mail and give me an</FONT>
<BR><FONT SIZE=-1>error message like below.</FONT>
<BR><FONT SIZE=-1>Here is part of my code and error msg..</FONT>
<BR><FONT COLOR="#FF0000"><FONT SIZE=+1>Please Please help!</FONT></FONT>
<BR><FONT COLOR="#FF0000"><FONT SIZE=+1>Thanks in Advance!!!</FONT></FONT>
<BR><FONT SIZE=-1></FONT>&nbsp;
<BR><FONT SIZE=-1></FONT>&nbsp;<FONT SIZE=-1></FONT>

<P><FONT SIZE=-1>code:</FONT><FONT SIZE=-1></FONT>

<P><FONT COLOR="#3333FF"><FONT SIZE=-1>tie (%myDB, DB_File, "mailinglist.db",
O_CREAT, 0666, $DB_HASH)</FONT></FONT>
<BR><FONT COLOR="#3333FF"><FONT SIZE=-1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
|| die "Can\'t open db file\n";</FONT></FONT><FONT COLOR="#3333FF"><FONT SIZE=-1></FONT></FONT>

<P><FONT COLOR="#3333FF"><FONT SIZE=-1>@emails = (keys %myDB);</FONT></FONT><FONT COLOR="#3333FF"><FONT SIZE=-1></FONT></FONT>

<P><FONT COLOR="#3333FF"><FONT SIZE=-1>foreach $email (@emails){</FONT></FONT>
<BR><FONT COLOR="#3333FF"><FONT SIZE=-1>$name = $myDB{$email};</FONT></FONT>
<BR><FONT COLOR="#3333FF"><FONT SIZE=-1>$sub = param("subject");</FONT></FONT>
<BR><FONT COLOR="#3333FF"><FONT SIZE=-1>$con = param("content");</FONT></FONT>
<BR><FONT COLOR="#3333FF"><FONT SIZE=-1>$con =~ s/\$name/$name/g;</FONT></FONT>
<BR><FONT COLOR="#3333FF"><FONT SIZE=-1>open (MAIL, "|/usr/lib/sendmail
-t");</FONT></FONT>
<BR><FONT COLOR="#3333FF"><FONT SIZE=-1>print MAIL "To: $_\n";</FONT></FONT>
<BR><FONT COLOR="#3333FF"><FONT SIZE=-1>print MAIL "From: CUKSA &lt;cuksa>\n";</FONT></FONT>
<BR><FONT COLOR="#3333FF"><FONT SIZE=-1>print MAIL "subject: $sub\n";</FONT></FONT>
<BR><FONT COLOR="#3333FF"><FONT SIZE=-1>print MAIL "\n$con\n";</FONT></FONT>
<BR><FONT COLOR="#3333FF"><FONT SIZE=-1>print MAIL "======================================\n";</FONT></FONT>
<BR><FONT COLOR="#3333FF"><FONT SIZE=-1>print MAIL "<A HREF="http://cuksa.monisys.ca/\n">http://cuksa.monisys.ca/\n</A>";</FONT></FONT>
<BR><FONT COLOR="#3333FF"><FONT SIZE=-1>close (MAIL);</FONT></FONT><FONT COLOR="#3333FF"><FONT SIZE=-1></FONT></FONT>

<P><FONT COLOR="#3333FF"><FONT SIZE=-1>}</FONT></FONT>
<BR><FONT COLOR="#3333FF"><FONT SIZE=-1>untie %myDB;</FONT></FONT>
<BR><FONT COLOR="#3333FF"><FONT SIZE=-1></FONT></FONT>&nbsp;
<BR><FONT SIZE=-1></FONT>&nbsp;<FONT SIZE=-1></FONT>

<P><FONT SIZE=-1>a part of Error msg</FONT><FONT SIZE=-1></FONT>

<P><FONT COLOR="#009900"><FONT SIZE=-1>Cannot open hash database /etc/maps/naturalsmile.com.db:
Too many open files in</FONT></FONT>
<BR><FONT COLOR="#009900"><FONT SIZE=-1>system</FONT></FONT>
<BR><FONT COLOR="#009900"><FONT SIZE=-1>Cannot open hash database /etc/maps/playerexpo.com.db:
Too many open files in sy</FONT></FONT>
<BR><FONT COLOR="#009900"><FONT SIZE=-1>stem</FONT></FONT>
<BR><FONT COLOR="#009900"><FONT SIZE=-1>Cannot open hash database /etc/maps/digitalclassified.net.db:
Too many open file</FONT></FONT>
<BR><FONT COLOR="#009900"><FONT SIZE=-1>s in system</FONT></FONT>
<BR><FONT COLOR="#009900"><FONT SIZE=-1>Cannot open hash database /etc/maps/1for1.com.db:
Too many open files in system</FONT></FONT>
<BR><FONT COLOR="#009900"><FONT SIZE=-1>Cannot open hash database /etc/maps/distinctmedical.com.db:
Too many open files</FONT></FONT>
<BR><FONT COLOR="#009900"><FONT SIZE=-1>in system</FONT></FONT>
<BR><FONT COLOR="#009900"><FONT SIZE=-1>Cannot open hash database /etc/maps/datanet.com.db:
Too many open files in syste</FONT></FONT>
<BR><FONT COLOR="#009900"><FONT SIZE=-1>m</FONT></FONT>
<BR><FONT COLOR="#009900"><FONT SIZE=-1>Cannot open hash database /etc/maps/advtech.org.db:
Too many open files in syste</FONT></FONT>
<BR><FONT COLOR="#009900"><FONT SIZE=-1>m</FONT></FONT>
<BR><FONT COLOR="#009900"><FONT SIZE=-1>Can't create transcript file xfTAA08287:
Too many open files in system</FONT></FONT>
<BR><FONT COLOR="#009900"><FONT SIZE=-1>Can't open /dev/null: Too many
open files in system</FONT></FONT></HTML>

--------------BE34073096069B7DE41CF3F9--



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

Date: Wed, 21 Apr 1999 23:01:55 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: string -> Create SQL Statements?
Message-Id: <ebohlmanFAKAn8.DJC@netcom.com>

Jay J <SpamMeNOT.3pound@iname.com> wrote:
: Given a string: (perl and linux) or "fuzzy logic"

: Is there module that'll build the SQL statement?

: SELECT FROM mytable WHERE description LIKE ("%perl%" and "%linux%") OR
: description LIKE "%fuzzy logic%"

: I feel a little silly given the fact there are many open source products
: that do boolean processing, but I've failed to grep out the code I need for
: a non-brittle routine.

Take a look at the code for Text::Query::Advanced on CPAN.  It compiles a 
Boolean search expression into a regex.  The "code generation" methods 
are overridable, so you can replace them with ones that generate SQL code 
instead.  You won't have to do any of the parsing or tokenizing.



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

Date: Wed, 21 Apr 1999 15:52:12 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Tell where lib file is
Message-Id: <371E569C.A64B193E@mail.cor.epa.gov>

MHCA wrote:
> 
> Hello,
> 
> The standard for importing a library file seems to be:
> 
> require "process-lib.pl";
> 
> This assumes that the file exists in the directory for perl libraries.  I do
> not have access to that directory.  How do I tell perl where to find the
> file?
> 
> I tried:
> 
> require "/share/client/modularcenter.com/htdocs/form_test/process-lib.pl";

I hate to be the first to tell you, but this is a FAQ.

If you had used perldoc to search the FAQ [like this: `perldoc -q
library']
it would have returned the relevant information from perlfaq8.

"How do I keep my own module/library directory?"

"How do I add the directory my program lives in to the module/library
search path?"

The bottom line is that there are several recommended ways to do it.
You can use the -I command switch, or the PERL5LIB environment 
variable, or 'use lib', or 'use lib' with 'use FindBin'.

You can look each of these up in the docs.  And the clearest exposition
of this is probably in the Perl Cookbook.

HTH,
David
-- 
David Cassell, OAO                               
cassell@mail.cor.epa.gov
Senior Computing Specialist                          phone: (541)
754-4468
mathematical statistician                              fax: (541)
754-4716


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

Date: Wed, 21 Apr 1999 17:58:37 -0400
From: Jay Glascoe <jglascoe@giss.nasa.gov>
To: jharmor@my-dejanews.com
Subject: Re: Verifying text in a string
Message-Id: <371E4A0D.7070EAD5@giss.nasa.gov>

Jay Glascoe wrote:
>
> die unless $string =~ /^[a-z0-9]{3,}$/i;
				    ^
eek!			/^[a-z0-9]{3}$/i;


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

Date: Wed, 21 Apr 1999 16:45:54 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Verifying text in a string
Message-Id: <MPG.11880309de7c21e2989904@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <371E43E3.6EAD4BA4@giss.nasa.gov> on Wed, 21 Apr 1999 
17:32:19 -0400, Jay Glascoe <jglascoe@giss.nasa.gov> says...
> Larry Rosler wrote:
> > 
> > Ignore anyone who shows a regex solution (though I doubt they'll dare to
> > now :-).  It will be an order of magnitude slower.
> 
> mmmm. no.
> 
> It obviously depends on your input, e.g. a 3 character
> string will take a nano-second either way.
> 
> or consider a silly case where the "tr//" approach,
> counting the number of chars you don't like, is in
> fact a couple orders of magnitudes slower than a regex:
> 
> use strict;
> 
> my $string = join '', map { chr int rand 256 } (1..10000);
> my $lar = sub { $string =~ tr/A-Za-z0-9//c };
> my $jay = sub { $string =~ /[^a-z0-9]/i };
> 
> use Benchmark;
> timethese 10000, { lar => $lar, jay => $jay };

That is a cheat (because the regex sub doesn't count the characters), 
but it is instructive, I think.  In any case, it is a challenge!

In the code below, I replaced the case-independent (/i) regexes with 
their explicit equivalents, which makes things slightly faster (but 
nowhere near as much as I expected based on their horrible public 
relations in the docs).

#!/usr/local/bin/perl -w
use strict;

my $rand = join '', map { chr int rand 256 } (1..10000);
my $good = 'A' x 10000;

my $Bool0   = sub { $rand =~ /[^A-Za-z0-9]/ };
my $Bool1   = sub { $good =~ /[^A-Za-z0-9]/ };
my $Count0  = sub { my $x = 0; ++$x while $rand =~ /[^A-Za-z0-9]/g };
my $Count0a = sub { my $x = () = $rand =~ /[^A-Za-z0-9]/g };
my $Count1  = sub { my $x = 0; ++$x while $good =~ /[^A-Za-z0-9]/g };
my $Count1a = sub { my $x = () = $good =~ /[^A-Za-z0-9]/g };
my $Del0    = sub { (my $x = $rand) =~ s/[^A-Za-z0-9]//g };
my $Del1    = sub { (my $x = $good) =~ s/[^A-Za-z0-9]//g };
my $Tr0     = sub { $rand =~ tr/A-Za-z0-9//c };
my $Tr1     = sub { $good =~ tr/A-Za-z0-9//c };
my $Tr0_d   = sub { (my $x = $rand) =~ tr/A-Za-z0-9//cd };
my $Tr1_d   = sub { (my $x = $good) =~ tr/A-Za-z0-9//cd };

use Benchmark;
timethese 1000, { Bool0  => $Bool0,  Bool1   => $Bool1,
                  Count0 => $Count0, Count0a => $Count0a,
                  Count1 => $Count1, Count1a => $Count1a,
                  Del0   => $Del0,   Del1    => $Del1,
                  Tr0    => $Tr0,    Tr0_d   => $Tr0_d,
                  Tr1    => $Tr1,    Tr1_d   => $Tr1_d, };
__END__

Benchmark: timing 1000 iterations of Bool0, Bool1, Count0, Count0a, 
Count1, Count1a, Del0, Del1, Tr0, Tr0_d, Tr1, Tr1_d...
     Bool0:  0 wallclock secs (-0.01 usr +  0.00 sys = -0.01 CPU)
            (warning: too few iterations for a reliable count)
     Bool1:  1 wallclock secs ( 0.48 usr +  0.00 sys =  0.48 CPU)
    Count0: 26 wallclock secs (26.36 usr +  0.00 sys = 26.36 CPU)
   Count0a: 70 wallclock secs (66.84 usr +  1.66 sys = 68.50 CPU)
    Count1:  1 wallclock secs ( 0.50 usr +  0.00 sys =  0.50 CPU)
   Count1a:  0 wallclock secs ( 0.50 usr +  0.00 sys =  0.50 CPU)
      Del0: 11 wallclock secs (10.95 usr +  0.00 sys = 10.95 CPU)
      Del1:  1 wallclock secs ( 0.53 usr +  0.00 sys =  0.53 CPU)
       Tr0:  1 wallclock secs ( 1.08 usr +  0.00 sys =  1.08 CPU)
     Tr0_d:  1 wallclock secs ( 1.00 usr +  0.00 sys =  1.00 CPU)
       Tr1:  0 wallclock secs ( 0.81 usr +  0.00 sys =  0.81 CPU)
     Tr1_d:  1 wallclock secs ( 0.83 usr +  0.00 sys =  0.83 CPU)

So:

When one wants to know simply whether or not there is a bad character, 
the regex is superfast, because it stops as soon as it finds the first 
one.  It is fast even if there is no bad character.

When one wants to count the bad characters, the regex is horrible if 
there are many, and far worse using the array hack that has appeared 
occasionally.  It is fast if there is no bad character.

When one wants to delete the bad characters, the regex is bad if there 
are many.  It is fast if there is no bad character.

The tr() solution is more-or-less data independent, faster generally 
than the regex except for the Boolean case.  It is the Tortoise compared 
to the Hare.

I am really surprised that for the 'look at every character but don't do 
anything' cases (the ones with the '1' in their names), the regex is 
noticeably faster than the tr():  about 0.5 sec compared to 0.8 sec.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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

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