[13839] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1249 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Nov 2 00:07:17 1999

Date: Mon, 1 Nov 1999 21:05:09 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <941519109-v9-i1249@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 1 Nov 1999     Volume: 9 Number: 1249

Today's topics:
    Re: Another 'or'? was [perl double-split] <ltl@rgsun40.viasystems.com>
    Re: Another 'or'? was [perl double-split] (Ilya Zakharevich)
        Anyone know of a perl script that ... <daltonhunter@hotmail.com>
    Re: Can this be made faster? (Kragen Sitaker)
    Re: Can this be made faster? (Kragen Sitaker)
        dbi database handle error with Fcgi ! ! ! ! !  ! !  (BLIMP8)
    Re: Don't we have POINTERS on Perl? <douglasgarstang@ozemail.com.au>
        Extract string ? <Achin@inprise.com>
    Re: Extract string ? <mj.stevenson@auckland.ac.nz>
    Re: Extract string ? <lr@hpl.hp.com>
        Extract string <Achin@inprise.com>
        How can I store/print a variable containing a DISPLAY I <maurice.maltbia@intel.com>
    Re: It is always like this here? (Abigail)
    Re: It is always like this here? (Abigail)
    Re: making a variable length string <uri@sysarch.com>
    Re: making a variable length string <lr@hpl.hp.com>
    Re: mod_perl installation problem (Kragen Sitaker)
    Re: parsing a directory content (Kragen Sitaker)
        perl JS interpreter? counting keywords? <itti@klab.caltech.edu>
    Re: Perl4 and Y2K <lr@hpl.hp.com>
    Re: Premature End Of Script Headers (Kragen Sitaker)
    Re: Problem with File Handles using CGI.pm (Kragen Sitaker)
    Re: Problem with perl and MSIE5 (Kragen Sitaker)
        Range operators: two dots v.s. three dots <johnlin@chttl.com.tw>
    Re: Sending html email (Kragen Sitaker)
    Re: string number conversion <lr@hpl.hp.com>
    Re: string number conversion <jeffp@crusoe.net>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 2 Nov 1999 02:18:49 GMT
From: lt lindley <ltl@rgsun40.viasystems.com>
Subject: Re: Another 'or'? was [perl double-split]
Message-Id: <7vlhm9$7ls$1@rguxd.viasystems.com>

Ilya Zakharevich <ilya@math.ohio-state.edu> wrote:
:>[A complimentary Cc of this posting was sent to lt lindley 
:><lee.lindley@bigfoot.com>],
[snip]
:>> so the "usefulness"  of ?? is not in dispute, though I can and will
:>> argue that "need" is too strong a word.  I can get by with a single
:>> "or" operator quite well.

:>Fine with me.  If you want to explain to your customer "do not try to use
:>this script with a file named C<0>", well, it is your problem.

If the customer actually complains that the program doesn't work with
a file named '0', I tell them not to use a file with that name.  :-)

But I must admit that there was a time when I refused to help my
"customers" who wanted to name a file with a space character in the
middle of it.  MS made that so easy that I could not maintain my
position.  Nowadays our ftp server receives files with all kinds of
bizarre names that confuse honest Unix utilities like ftp, mv and rm
and the shells that invoke them.  So I guess it is possible that one
of my customers will one day name a file '0' and I will have to bite
my tongue and deal with it.  :-)

:>(See many recipes in the Perl CookBook, which would do something like

:>  $name = shift || 'file.txt';

:>It is the Perl CookBook which made the need absolutely clear (to me).)

$name = shift;
$name = 'file.txt' unless defined $name;
# vs.
$name = shift ?? 'file.txt';

All that to handle the extremely odd case of a file named '0'?

Ilya, I can see  that there may be an elegant use for a short circuit
"or" operator that differentiates Perl truth from definedness.  But I
respectfully submit that your example sucks.  If you are going to
argue the case for this operator without making me laugh, try
something like:

sub build_file_name {
	my $dirname = shift;
	my $filename = shift;
	# optional extension argument.  Could be '' for no extenstion
	my $ext = shift ?? '.txt';
	...
}
# Of course, I would just write that as
my ($dirname, $filename, $ext) = @_;
$ext = '.txt' unless defined $ext;

But having '??' available might cause people to think about these
potential pitfalls more, and ....  Oh.  I see from a search on
p5p archives that you guys have already flogged this thing
to death.  Resurrecting that disussion here might get me labeled
a troll.  :)


-- 
// Lee.Lindley   /// I used to think that being right was everything.
// @bigfoot.com  ///  Then I matured into the realization that getting
////////////////////   along was more important.  Except on usenet.


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

Date: 2 Nov 1999 03:21:54 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Another 'or'? was [perl double-split]
Message-Id: <7vllci$8tm$1@charm.magnus.acs.ohio-state.edu>

[A complimentary Cc of this posting was sent to lt lindley 
<lee.lindley@bigfoot.com>],
who wrote in article <7vlhm9$7ls$1@rguxd.viasystems.com>:
> :>(See many recipes in the Perl CookBook, which would do something like
> 
> :>  $name = shift || 'file.txt';
> 
> :>It is the Perl CookBook which made the need absolutely clear (to me).)
> 
> $name = shift;
> $name = 'file.txt' unless defined $name;
> # vs.
> $name = shift ?? 'file.txt';

Designing a programming language is an exercise in psychology.  As you
see, it is *a lot* of work comparing to the result: changing
99.9%-correct behaviour to correct behaviour.  Those nasty creatures
they call "programmers" are lazy, and need much more incentive than
fixing 0.1% of cases to add an extra statement to a program.

Ilya


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

Date: Mon, 1 Nov 1999 18:19:52 -0800
From: "Dalton Hunter" <daltonhunter@hotmail.com>
Subject: Anyone know of a perl script that ...
Message-Id: <s1sijj1n24287@corp.supernews.com>

 ... will send an email to someone when an IP addresses is accessing a site X
amount of times a minute so that one can look into it and decide if they
want to add the IP to their .htaccess's deny list? Thanks!

Dalton








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

Date: Tue, 02 Nov 1999 02:26:12 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Can this be made faster?
Message-Id: <8ZrT3.18558$23.1017431@typ11.nn.bcandid.com>

In article <x3yg0yqt78j.fsf@tigre.matrox.com>,
Ala Qumsieh  <aqumsieh@matrox.com> wrote:
>kragen@dnaco.net (Kragen Sitaker) writes:
>> In article <381CD0D5.7B879432@sympatico.ca>,
>> Ala Qumsieh  <qumsieh@sympatico.ca> wrote:
>> >PB wrote:

 . . .

>I hadn't paid close attention. For some reason I thought his line:
>
>	if ($line =~ /\s$string\s/oi) {$count++;}
>
>was really
>
>	while ($line =~ /\s$string\s/goi) {$count++}
>
>which *might* be faster than my:
>
>	$count += () = /\s$string\s/goi;

I'd expect yours to be faster than his, because the iteration is done
in the regex engine instead of in Perl.

>> One solution to making it faster might be this:
>> 
>> #!/usr/bin/perl -w
>> use strict; my $string = 'you'; my @files = @ARGV;
>> my $count = 0;
>> for my $file (@files) {
>> 	open F, "<$file" or die "Opening $file: $!\n";
>> 	$_ = do {local $/; <F>};
>
>I really doubt this would make things faster. Reading the whole file
>into memory can have undesirable effects.

Like running out of memory and thrashing, you mean?  :)  I'm hoping his
file isn't bigger than his virtual memory.

> It all depends on the
>application, and I should benchmark if I want to backup any claims I
>am making :-)

Sometimes reading the whole file into memory -- so you can scan big
areas of the file with the regex engine instead of perl while(<>){} --
can make things faster.

I would benchmark before I made any claims one way or the other for
this particular case. :)

>> 	$count += () = /^.*\s$string\s.*$/goim;
>
>Why do you bother with all of that? Why not simply:
>
>	$count++ if /\s$string\s/goi;
>
>since you are trying to match only once per line.

Because I am matching on the whole file, so "$count++ if ..." would
make $count be the number of files that matched, not the number of
lines that matched. :)

The ^.* and .*$ are to ensure that the match chomps the whole line, so
a line with two occurrences of $string doesn't yield two matches.  I
guess I could have gotten away with just the .*$, now that I think
about it, and I probably should have.

>> }
>> print "count: $count\n";
>> 
>> The first couple of lines and the last line are just there to help me
>> test it.  This will read in the whole file, just as before, but will
>> pattern-match on the whole file all at once instead of on each line.
>> The pattern will match a whole line, so you'll only get one match per
>> line, just as in your original script (but unlike Ala's.)  If that's
>> not what you want, of course you can take the ^.* and .*$ out.
>
>or change the if() to a while() ;-)

Well, the if you inserted, you mean?  That would change it from
matching once per file to matching once per occurrence of the string.
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Mon Nov 01 1999
7 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Tue, 02 Nov 1999 02:34:55 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Can this be made faster?
Message-Id: <j5sT3.18819$23.1019000@typ11.nn.bcandid.com>

In article <7vkomr$iau$1@fir.prod.itd.earthlink.net>,
PB <22pb22@excite.com> wrote:
>Ala Qumsieh <qumsieh@sympatico.ca> proposal:
>
>my $count = 0;
>for my $file (@files) {
>open F, $file or die $!;
>while (<F>) {
>$count += () = /(\s$string\s)/goi;
>}
>close F or die $!;
>}
>
>$count:                   8
>Execution time:     0.016 seconds

I am completely mystified how this happened.  I can see how Ala's code
might return *more* hits, but not *less*.  And I can see how Ala's code
could be quicker than the original code, since he's not allocating huge
arrays containing the whole file, but I can't understand how he could
read 100MB of files from disk in 0.016 seconds.  That's faster than you
can read 100MB of data from RAM on a fast PC!

>Kragen Sitaker <kragen@dnaco.net> proposal:
>
>#!/usr/bin/perl -w
>use strict; my $string = 'you'; my @files = @ARGV;
>my $count = 0;
>for my $file (@files) {
>open F, "<$file" or die "Opening $file: $!\n";
>$_ = do {local $/; <F>};
>$count += () = /^.*\s$string\s.*$/goim;
>}
>print "count: $count\n";
>
>
>$count:                   5423
>Execution time:     2.172 seconds

I'm a little surprised this took longer, but it's certainly not
implausible.  I wonder if removing the ^.* would help; I suppose I
could test that myself.
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Mon Nov 01 1999
7 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: 02 Nov 1999 03:16:23 GMT
From: blimp8@aol.com (BLIMP8)
Subject: dbi database handle error with Fcgi ! ! ! ! !  ! ! 
Message-Id: <19991101221623.11282.00001442@ng-fi1.aol.com>

how can i use Fcgi and not get a database handle destroyed without explicit
disconnect (in the server error log)and not make an explicit disconnect???

for example:::

use Fcgi;
use DBI;

my $dbh = DBI->connect('dbi:bla:bla','bla','bla');

while(FCGI::Accept()>=0){
    do stuff
}

i don't wanna disconnect explicitly 'cause then what's the point of using
Fcgi...
anyone help then thanks!!!
blimp8@aol.com



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

Date: Tue, 2 Nov 1999 14:05:47 +1100
From: "Douglas Garstang" <douglasgarstang@ozemail.com.au>
Subject: Re: Don't we have POINTERS on Perl?
Message-Id: <%xsT3.258$Q3.2198@ozemail.com.au>

God Noooooooo!

Landim wrote in message <180b7585.359e475e@usw-ex0103-019.remarq.com>...
>Hi all...
>
>
>I want to know if we have or not pointers on perl, and
>if we have, how to declarate? To manipulate?
>
>
>landim2@brhs.com.br
>
>
>* Sent from AltaVista http://www.altavista.com Where you can also find
related Web Pages, Images, Audios, Videos, News, and Shopping.  Smart is
Beautiful




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

Date: Tue, 02 Nov 1999 10:58:38 +0800
From: Adrian Chin <Achin@inprise.com>
Subject: Extract string ?
Message-Id: <381E535E.7EB1630B@inprise.com>


--------------4B020E2D1E2CF4AF2D1398B7
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hi

I have :

vol1/extract/inst/sum.C:1:2:3
vol2/extract/algo.h:2:3:4
vol3/extr/rol/rojak/bunga/fungi.sh:1:2:3

in a file call file.txt.  How do I extract the colored string out to a
variable in perl ?

--------------4B020E2D1E2CF4AF2D1398B7
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Hi
<p>I have :
<p>vol1/extract/inst/<font color="#993300">sum.C</font>:1:2:3
<br>vol2/extract/<font color="#CC6600">algo.h</font>:2:3:4
<br>vol3/extr/rol/rojak/bunga/fungi.sh:1:2:3
<p>in a file call file.txt.&nbsp; How do I extract the colored string out
to a variable in perl ?</html>

--------------4B020E2D1E2CF4AF2D1398B7--



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

Date: Tue, 02 Nov 1999 17:05:17 +1300
From: Matthew Stevenson <mj.stevenson@auckland.ac.nz>
Subject: Re: Extract string ?
Message-Id: <381E62FD.3859650C@auckland.ac.nz>

Adrian Chin wrote:

> I have :
> 
> vol1/extract/inst/sum.C:1:2:3
> vol2/extract/algo.h:2:3:4
> vol3/extr/rol/rojak/bunga/fungi.sh:1:2:3
> 
> in a file call file.txt.  How do I extract the colored string out to a
> variable in perl ?

This works, may not be the best...

#!/usr/bin/perl -w

while(<STDIN>){
   print "$2\n" if ( m#(\w+/)*(\w+\.\w+):# );
}


echo "inst/sum.C:1:2:3\nvol2/extract/algo.h:2:3:4\nblahblah" | pro.pl
sum.C
algo.h

Matthew

-- 

Matthew Stevenson
University of Auckland
mj.stevenson@auckland.ac.nz


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

Date: Mon, 1 Nov 1999 20:50:54 -0800
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Extract string ?
Message-Id: <MPG.12880d84a0aeb54098a180@nntp.hpl.hp.com>

In article <381E535E.7EB1630B@inprise.com> on Tue, 02 Nov 1999 10:58:38 
+0800, Adrian Chin <Achin@inprise.com> says...
 ... 
> vol1/extract/inst/sum.C:1:2:3
> vol2/extract/algo.h:2:3:4
> vol3/extr/rol/rojak/bunga/fungi.sh:1:2:3
> 
> in a file call file.txt.  How do I extract the colored string out to a
> variable in perl ?

In neither of your almost identical posts do I see any colored strings.  
It all seems black and white to me.

Without urther details, I assume you need to use either split() or a 
regex.

perldoc -f split

perldoc perlre 

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


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

Date: Tue, 02 Nov 1999 11:16:35 +0800
From: Adrian Chin <Achin@inprise.com>
Subject: Extract string
Message-Id: <381E5793.C249CE1E@inprise.com>


--------------B24A020C53939178C79185F2
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit


Hi

I have :

vol1/extract/inst/sum.C:1:2:3
vol2/extract/algo.h:2:3:4
vol3/extr/rol/rojak/bunga/fungi.sh:1:2:3

in a file call file.txt.  How do I extract the colored string out to a
variable in per

--------------B24A020C53939178C79185F2
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
&nbsp;
<br>Hi
<p>I have :
<p>vol1/extract/inst/<font color="#CC6600">sum.C</font>:1:2:3
<br>vol2/extract/<font color="#CC6600">algo.h</font>:2:3:4
<br>vol3/extr/rol/rojak/bunga/<font color="#993300">fungi.sh</font>:1:2:3
<p>in a file call file.txt.&nbsp; How do I extract the colored string out
to a variable in per</html>

--------------B24A020C53939178C79185F2--



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

Date: Mon, 1 Nov 1999 19:14:05 -0800
From: "Maurice Maltbia" <maurice.maltbia@intel.com>
Subject: How can I store/print a variable containing a DISPLAY IP address?
Message-Id: <7vlkt9$irl@news.or.intel.com>

I am trying the store the commands for Exceed (by Hummingbird) to a
variable.
The first command sets the DISPLAY environment variable and the second runs
X windows.
The print statement seems to be interpreting the IP address numbers and the
colon.

here is my code:
sub x_windows {
       my $home = 'C:\\Progra~1\\Exceed';
       my $startmeth = '-m RLOGIN';
       my $hostname = "-h $host";
       my $userid =    "-u $username";
       my $password = "-p abcdefg";
      $IP_address = '111.222.333.64;
       my $cmnd = "-c setenv DISPLAY ${IP_address}".':0.0; runx -nt&';
       print "$cmnd\n";
       system("$home\\xstart $startmeth $hostname $password $userid $cmnd");
       ...

the print statement shows:
    :0.0; runx -nt&AY  111.222.333.64

Thanks, in advance.




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

Date: 1 Nov 1999 22:57:09 -0600
From: abigail@delanet.com (Abigail)
Subject: Re: It is always like this here?
Message-Id: <slrn81srnv.66b.abigail@alexandra.delanet.com>

Jon Shemitz (jon@midnightbeach.com) wrote on MMCCLIII September MCMXCIII
in <URL:news:381DE10A.292FD25C@midnightbeach.com>:
() Martien Verbruggen wrote:
() 
() > > To be quite honest, and I know you'll probably disagree with this,
() > > enough regulars here *enjoy* the situation as it stands so much
() > > that it will never change.
() > 
() > And this is what I disagree with most. The fact that the most
() > knowledgeable of people keep dropping off this newsgroup should show you
() > that they are not happy at all with the situation. The fact that these
() > discussions keep appearing should show you that as well. Nobody is happy
() > with the situation as it is. And nobody knows how to fix it, if it's
() > fixable at all.
() 
() Perhaps this suggestion comes up a lot, too: Split the group.

Yes it does. Apparently, you seem to suffer from the same disease
many people being flamed suffer from to: the inability to read.

It's been suggested here, oh, about 12 times a week?

Read the frigging group, and you would have known.

() Maybe what is needed is a comp.lang.perl.arcana, or c.l.p.details, or
() even c.l.p.way-geeky. People always cite the Unix wizards group as an
() example of why this won't work. But if you name it in a way that will
() really only appeal to those who belong there - and you find a moderator
() - this shouldn't be a problem. A moderator, I think, is key. I think
() that if the moderator filters out little more than the sort of questions
() that get answered here as "FAQ" or "RTFM", the arcana group will be a
() very pleasant place to be, and it will leave misc as a pleasant place,
() too. Who would have time to moderate the new group? Why, I would think
() that anyone who has the time to respond "FAQ" to FAQ's has more than
() enough time to say Yeah or Nay to each thread.


Apparently, you are unware of c.l.p.moderated.

Please do your homework, and come back if you have something new.



Abigail
-- 
package Just_another_Perl_Hacker; sub print {($_=$_[0])=~ s/_/ /g;
                                      print } sub __PACKAGE__ { &
                                      print (     __PACKAGE__)} &
                                                  __PACKAGE__
                                            (                )


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: 1 Nov 1999 23:00:25 -0600
From: abigail@delanet.com (Abigail)
Subject: Re: It is always like this here?
Message-Id: <slrn81sru3.66b.abigail@alexandra.delanet.com>

Art Cohen (upsetter@shore.net) wrote on MMCCLIII September MCMXCIII in
<URL:news:zlmT3.378$Yr1.80207@news.shore.net>:
@@ Abigail <abigail@delanet.com> wrote:
@@ : We know that, and if you think "flamers" think it will keep that off-topic
@@ : poster away, you're wrong. But it will keep *others* away.
@@ 
@@ Utter nonsense. The off-topic posters don't bother to read the newsgroup
@@ before posting, so what on earth makes you think they'll see all your
@@ witty flames?


It doesn't give the impression off-topic postings are welcome to
does who do read.



Abigail
-- 
perl5.004 -wMMath::BigInt -e'$^V=Math::BigInt->new(qq]$^F$^W783$[$%9889$^F47]
 .qq]$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W]
 .qq]98$^F76777$=56]);$^U=substr($]=>$|=>5)*(q.25..($^W=@^V))=>do{print+chr$^V
%$^U;$^V/=$^U}while$^V!=$^W'


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: 01 Nov 1999 22:55:07 -0500
From: Uri Guttman <uri@sysarch.com>
Subject: Re: making a variable length string
Message-Id: <x7k8o1a6p0.fsf@home.sysarch.com>

>>>>> "LR" == Larry Rosler <lr@hpl.hp.com> writes:

  LR> my $string = 1 x $num_ones . 0 x ($initial_length + 5 - $num_ones);

i know this will make for a worse golf score, but i would quote the 1
and 0 as they are being used as strings (and x will stringify numbers)
so why not quote them so the maintainer will see them as strings too.

i don't know if the compiler will convert the 1 and 0 to strings instead
of x converting them at runtime. if runtime then quoting might even make
it run a mite faster but who really cares?

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Mon, 1 Nov 1999 20:47:25 -0800
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: making a variable length string
Message-Id: <MPG.12880cbadc496acd98a17f@nntp.hpl.hp.com>

In article <x7k8o1a6p0.fsf@home.sysarch.com> on 01 Nov 1999 22:55:07 -
0500, Uri Guttman <uri@sysarch.com> says...
> >>>>> "LR" == Larry Rosler <lr@hpl.hp.com> writes:
> 
>   LR> my $string = 1 x $num_ones . 0 x ($initial_length + 5 - $num_ones);
> 
> i know this will make for a worse golf score, but i would quote the 1
> and 0 as they are being used as strings (and x will stringify numbers)
> so why not quote them so the maintainer will see them as strings too.

As if I didn't make a conscious choice of how to show it!  (They were 
explicit strings in the original post.)  You have reinforced the 
pedagogic intent, about interchangeability of numbers and strings.

> i don't know if the compiler will convert the 1 and 0 to strings instead
> of x converting them at runtime. if runtime then quoting might even make
> it run a mite faster but who really cares?

If I recall correctly, once a number variable has been stringified, the 
string is remembered with the number.  So even at run time, even in a 
loop, there is no significant performance issue.  For a number constant, 
obviously this would be done at compile time.

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


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

Date: Tue, 02 Nov 1999 02:15:40 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: mod_perl installation problem
Message-Id: <gPrT3.18432$23.1014807@typ11.nn.bcandid.com>

In article <381DC9B9.B1B431C1@pixelpark.com>,
ottmar deifke  <aboudeif@pixelpark.com> wrote:
>I am trying to compile apache with mod_perl using APACI on 2 machines,
>machine 1 is running Solaris 2.6 and machine 2 is running solaris 2.7.
>
>Both machines using the same configuration script, and the same
>apache-source
>and mod_perl-source through NFS. its not even a copy, its the same.
>
>Both machines have perl installed in /www/apps/perl. 
>Each Perl was configured and installed statically (libperl.a) (perl
>-V output is below), and differs only in their libpath directorys.
>NONE OF THE LIBDIRS CONTAIN EITHER LIBPERL.SO OR LIBPERL.A.
>
>Now the Problem:
>
>When configuring and making on machine 1, everything runs fine.
>When configuring and making on machine 2, (gnu-) make errors:
>ld.so.1: ./gen_test_char: fatal: libperl.so: open failed: No such file
>or directory

What do you get if you ldd gen_test_char on machine 1?  Does it mention
libperl.so?  If so, where is it getting it?

I'm pretty mystified by this, too.  I looked at your compile output,
and it looks like it's not finding libperl.so immediately after it
(presumably) found it during the compile.

-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Mon Nov 01 1999
7 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Tue, 02 Nov 1999 03:01:00 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: parsing a directory content
Message-Id: <MtsT3.19238$23.1022990@typ11.nn.bcandid.com>

In article <381E19C8.1D5051D0@club-internet.fr>,
davidh  <cle1dav@club-internet.fr> wrote:
>I am not a programmer but I need some help to build a function that
>parses the content of a directory.
>I am actually trying to build a cgi index file that would read the
>content of a directory, extract some data such as what is between the
><title> and <meta> tags, and finally parse a dynamic index.
>If anyone knew an existing program, it would be very helpful :)

This is a newsgroup for helping people learn Perl.  It is not a
suitable newsgroup for posting requests for someone else to find you
prewritten code, nor to post job offers, which is what your first
paragraph appears to be.
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Mon Nov 01 1999
7 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Mon, 01 Nov 1999 19:23:47 -0800
From: Laurent Itti <itti@klab.caltech.edu>
Subject: perl JS interpreter? counting keywords?
Message-Id: <381E5943.E6203019@klab.caltech.edu>

Hi All:

does anybody know of an interpreter for JavaScript in perl?

I am trying to write an exhaustive web bot in perl, which would go
through
most of the classical hoops used to keep bots away.  So far, using LWP,
HTTP
and HTML modules, I get something that can follow redirects,
collects/gives
cookies, can handle frames, can handle fake images which will actually
set
cookies when loaded, and a few other things.

But javascript interpretation is the one thing which looks absolutely
necessary and which I have not found so far (unix environment, linux).
Any advice would be greatly appreciated!

A second question is: is there any better/faster way to count how many
times
do various lists of keywords appear in a string than to loop over the
lists,
then loop over keywords for each list, then do a series of pattern
matches
for each keyword?

my keywords presently look like:

%sk = (
    'cool' => 'cool|nice|super|rad|kick-ass',
    'new'  => 'new|novel|state-of-the-art',
    ...
);
and I would like a compound word count for each of the categories
('cool',
'new', and so on).

thanks a lot!

  -- laurent itti


I include my current code for the keyword match:


sub score {                 # $data: string where to look for keywords
    my %s, $k;
    foreach $k (keys %sk) {
        $s{$k} = kwmatch($_[0], $sk{$k});
    }
   return %s;               # one count per keyword category
}

sub kwmatch {               # $data, $kwlist
    my @kw = split(/\|/, $_[1]), $k, $nb = 0;
    foreach $k (@kw) {
        my $d = " ".$_[0]." ";
        while ($d =~ / \Q$k /) { $nb ++; $d = $'; }
    }
    return $nb;
}

as you see, this is fairly brutal and as non-optimal as it gets ;-)




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

Date: Mon, 1 Nov 1999 19:27:34 -0800
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Perl4 and Y2K
Message-Id: <MPG.1287fa0285e8f56e98a17e@nntp.hpl.hp.com>

In article <Pine.GSO.4.10.9911011757140.29670-100000@user2.teleport.com> 
on Mon, 1 Nov 1999 18:02:33 -0800, Tom Phoenix <rootbeer@redcat.com> 
says...

 ...

> Don't you think that anyone who is worried about Y2K bugs in that old
> version of Perl should upgrade at once?

No.  As I said in another branch of this thread, I would continue offer 
Perl 4, and I would make Perl 5 available.  I would then publicize the 
desirability of application programmers switching from Perl 4 to Perl 5 
(along with the various pitfalls, such as "@" in double-quoted strings).

This puts the burden of upgrading where it belongs -- on the application 
programmers themselves.

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


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

Date: Tue, 02 Nov 1999 03:08:46 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Premature End Of Script Headers
Message-Id: <2BsT3.19253$23.1025206@typ11.nn.bcandid.com>

In article <7vl6n1$et6$1@gxsn.com>,
Martin Elliott <martin@mert.globalnet.co.uk> wrote:
>When I run my Perl CGI on server, having tested it with Perl Builder
>off-line, I get a 'Premature End Of Script Header' error in the error log.
>
>Does anyone know what this means and how to fix it as I am still learning
>Perl and trying to get to grips with it?

This means your script has a bug.  Look at Tom Christiansen's "Idiot's
Guide to Solving Perl/CGI Problems" at
http://www.perl.com/CPAN-local/doc/FAQs/cgi/idiots-guide.html.  Then
look at the server error log.

>p.s. sorry for the cgi content, but I can't approve any messages to
>comp.infosystems...cgi.

Why does it have to be our problem?  If you aren't able to post on an
appropriate newsgroup, why do you have to pick comp.lang.perl?
Couldn't you post your question on alt.lemurs or alt.tasteless or
something?
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Mon Nov 01 1999
7 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Tue, 02 Nov 1999 03:05:23 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Problem with File Handles using CGI.pm
Message-Id: <TxsT3.19247$23.1024599@typ11.nn.bcandid.com>

In article <fSoT3.18028$23.978170@typ11.nn.bcandid.com>, CS <@mdo.net> wrote:
>    $q=new CGI;
>    $FH=param('upload');
>
>    CGI open of C:\temp\CGItemp3360001: Permission denied
>
>And why on earth would the above script try to create a temporary file on
>the host without me wanting to do that?

CGI.pm writes the uploaded file to a temporary file, which is why it
can give you a file handle to read the data from.

Perhaps you don't have permission to write to C:\temp?  You can have
CGI.pm write the temp files in a different directory.
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Mon Nov 01 1999
7 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Tue, 02 Nov 1999 02:17:43 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Problem with perl and MSIE5
Message-Id: <bRrT3.18435$23.1012700@typ11.nn.bcandid.com>

In article <7vkim4$agr$1@nnrp1.deja.com>,  <apogee101@my-deja.com> wrote:
>Can anybody tell me what ... mistake I'm making?

1. asking for CGI help in a newsgropu that has nothing to do with CGI
2. forgetting to include the content-type header
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Mon Nov 01 1999
7 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Tue, 2 Nov 1999 11:58:08 +0800
From: "John Lin" <johnlin@chttl.com.tw>
Subject: Range operators: two dots v.s. three dots
Message-Id: <7vlnis$j0c@netnews.hinet.net>

Hi,
    I see the two dot operator '..' and three dot operator '...' in perlop.
Without examples, I can't understand the difference.

for(a..z) { print }
for(a...z) { print }    # the same!

while(<>) { print if 1..5 }
while(<>) { print if 1...5 }    # the same!

Would you help?  Thanks.




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

Date: Tue, 02 Nov 1999 03:03:42 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Sending html email
Message-Id: <iwsT3.19244$23.1024241@typ11.nn.bcandid.com>

In article <7vl5nj$p8c$1@nnrp1.deja.com>,  <traviscook@my-deja.com> wrote:
>I have a custom program that handles the smtp conversation on port 25.
>I had to do a custom one for a variety of reasons.  I can send a
>regular 'text/plain' email with no problems.  What isn't working
>correctly is sending out a 'text/html' email.  The email is arriving
>fine, but I see all the header info and the html tags.  So, obviously,
>the email type isn't being recognized.  Can anyone help me with this?

Read the MIME RFCs (RFCs 2045-2049), check to see if you think your
headers match the RFC-described headers, and if you still have
problems, post your question (including the incorrect header!) on a
newsgroup that has something to do with MIME.
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Mon Nov 01 1999
7 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Mon, 1 Nov 1999 18:03:47 -0800
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: string number conversion
Message-Id: <MPG.1287e65ed7625c1c98a17d@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <Pine.GSO.4.10.9911011723580.29670-100000@user2.teleport.com> 
on Mon, 1 Nov 1999 17:25:43 -0800, Tom Phoenix <rootbeer@redcat.com> 
says...
> On Fri, 29 Oct 1999, Brett W. McCoy wrote:
> 
> > sub frac2dec {
> >         my $fracnum = shift;
> >         (my $int, my $frac) = split(' ', $fracnum);
> >         my $decimal = eval $frac;
> >         return $int + $decimal;
> > }
> > 
> > print frac2dec('4 2/5');
> 
> That's an evil eval. Wouldn't this be better without it?

Argument "2/5" isn't numeric in add at ...

What am I missing?  How can one convert the string '2/5' to a number 
without 'eval' (or explicit parsing -- yecch!)?

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


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

Date: Mon, 1 Nov 1999 21:47:42 -0500
From: Jeff Pinyan <jeffp@crusoe.net>
Subject: Re: string number conversion
Message-Id: <Pine.GSO.4.10.9911012137310.2694-100000@crusoe.crusoe.net>

On Nov 1, Larry Rosler blah blah blah:

> > > sub frac2dec {
> > >         my $fracnum = shift;
> > >         (my $int, my $frac) = split(' ', $fracnum);
> > >         my $decimal = eval $frac;
> > >         return $int + $decimal;
> > > }
> > 
> > That's an evil eval. Wouldn't this be better without it?
> 
> What am I missing?  How can one convert the string '2/5' to a number 
> without 'eval' (or explicit parsing -- yecch!)?

How bad could explicit parsing be here?  Fractions come in a few flavors:

  A B/C
  A
  B/C

So you have three simple cases:

  sub frac2dec {
    my ($dec,$num,$den) = shift =~
      m!^([^\s/]+)?\s*(?:([^\s/]+)/(.*))?$!;
    return $dec unless $num;
    die "Illegal division by 0, etc..." unless $den;
    return $dec + $num/$den;
  }

Of course, this doesn't work on non-fraction input, like "foo bar/blat" or
something.  Be more elegant if you desire.  I tested mine, it appears to
be working.

-- 

  MIDN 4/C PINYAN, USNR, NROTCURPI
  jeff pinyan      japhy@pobox.com
  perl stuff       japhy+perl@pobox.com
  CPAN ID: PINYAN  http://www.perl.com/CPAN/authors/id/P/PI/PINYAN/



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

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

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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.

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 V9 Issue 1249
**************************************


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