[13698] in Perl-Users-Digest
Perl-Users Digest, Issue: 1108 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Oct 18 13:05:35 1999
Date: Mon, 18 Oct 1999 10:05:10 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <940266309-v9-i1108@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 18 Oct 1999 Volume: 9 Number: 1108
Today's topics:
Re: .htaccess (Kragen Sitaker)
Re: @ARGV ---- Arrrrgggghhhh! :-) (Sam Holden)
Re: @ARGV ---- Arrrrgggghhhh! :-) <gellyfish@gellyfish.com>
Re: @ARGV ---- Arrrrgggghhhh! :-) <rhomberg@ife.ee.ethz.ch>
Re: @ARGV ---- Arrrrgggghhhh! :-) (Kragen Sitaker)
Apache/mod_perl/ApacheDBI problem <dwb1@home.com>
Re: Do you now an affordable Perl editor for Windows NT (Brett W. McCoy)
Re: Do you now an affordable Perl editor for Windows NT <gellyfish@gellyfish.com>
equiv. of nice & simple ksh syntax <mark@artdigital.co.uk>
hpux perl oracle mark_f_edwards@my-deja.com
Need help -- How to display an existing web page <juntao@pan.as.utexas.edu>
Re: Need help -- How to display an existing web page (Kragen Sitaker)
Re: One bug with local and one bug with perlbug <uri@sysarch.com>
Re: Passing values to and from File::Find (Kragen Sitaker)
Perl Builder [Was "Do you now an affordable Perl editor <jon@midnightbeach.com>
Re: Perl parser / brackets in C language (Kragen Sitaker)
Problem w/ PERL and SQL mirak63@yahoo.com
Re: Problem w/ PERL and SQL <AgitatorsBand@yahoo.com>
PUT request in ftp? <eedjoes@eed.ericsson.se>
Re: Q: Truncate string length? (Larry Rosler)
Re: Range checking (Larry Rosler)
Re: Scalars with special characters (Tad McClellan)
Script result to Browser problem! <Tobias.Byron-Carlsson@ivf.se>
Re: slow regexp (Kragen Sitaker)
Re: Uses of # (Neko)
Re: variables on the right side of Reg Exp <rhomberg@ife.ee.ethz.ch>
Re: variables on the right side of Reg Exp (Larry Rosler)
what is SHTML ? <ewha95@shinbiro.com>
Re: Where is Benchmark.pm? <gellyfish@gellyfish.com>
Re: Why does this match take so long? <aperrin@demog.berkeley.edu>
Windows -> UNIX text problems <ralawrence@my-deja.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 18 Oct 1999 16:24:50 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: .htaccess
Message-Id: <mRHO3.14389$E_1.847826@typ11.nn.bcandid.com>
In article <380B1D86.7604A583@dcs.qmw.ac.uk>,
Johnny 'Loopy' Ooi <jjyooi@dcs.qmw.ac.uk> wrote:
>Sam Holden wrote:
>>
>> I searched for '.htaccess' which is pretty obvious, of course that
>> returned nothing. Then I searched for 'access'. That returned the module
>> above. You can search for yourself much more efficiently, since you actually
>> know what you are looking for...
>
>I searched for various things, but I didn't think of searching for
>"access" -- am I dumb or what?
Keyword searching is an acquired skill, not an inborn trait. It takes
a long time to learn to do it well -- so long that those of us who do
it well sometimes forget there was a time when we didn't do it as
well.
Also, it's deeply interwoven with domain knowledge. If you think of
.htaccess as being one of many mechanisms for access control, searching
for "access" seems relatively natural. But if "access control" doesn't
come to mind when you think of allow/deny rules, well, it's going to be
a little more difficult.
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Sun Oct 17 1999
23 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: 18 Oct 1999 15:15:53 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: @ARGV ---- Arrrrgggghhhh! :-)
Message-Id: <slrn80med9.dpn.sholden@pgrad.cs.usyd.edu.au>
On Mon, 18 Oct 1999 15:21:53 +0100,
Csaba Raduly <csaba.raduly@sophos.com> wrote:
<snip wildcard expansion by the shell or not?>
>At least Tad McClellan protected himself by specifying that this
>is the standard behaviour on Unix. Everybody else (whose posts
>I've seen up till now on this thread) speaks as if Perl hadn't
>been ported outside Unix :-)
That's because perl brings the best of Unix along with it when it gets
ported.
--
Sam
You can write Perl programs that resemble sed, or awk, or C, or Lisp, or
Python. This is Officially Okay in Perl culture.
--Larry Wall
------------------------------
Date: 18 Oct 1999 16:31:49 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: @ARGV ---- Arrrrgggghhhh! :-)
Message-Id: <380b3d65_2@newsread3.dircon.co.uk>
Csaba Raduly <csaba.raduly@sophos.com> wrote:
>
> Or if the shell doesn't do it, Perl does.
>
WRONG !
C:\WINDOWS\Desktop>perl test.pl *.*
*.*
C:\WINDOWS\Desktop>
C:\WINDOWS\Desktop>perl -v
This is perl, version 5.005_03 built for MSWin32-x86-object
(with 1 registered patch, see perl -V for more detail)
Copyright 1987-1999, Larry Wall
Binary build 520 provided by ActiveState Tool Corp. http://www.ActiveState.com
Built 17:55:54 Sep 28 1999
C:\WINDOWS\Desktop>cat test.pl
print @ARGV;
/J\
------------------------------
Date: Mon, 18 Oct 1999 18:02:10 +0200
From: Alex Rhomberg <rhomberg@ife.ee.ethz.ch>
Subject: Re: @ARGV ---- Arrrrgggghhhh! :-)
Message-Id: <380B4482.5AD5A0C2@ife.ee.ethz.ch>
Csaba Raduly wrote:
> Or if the shell doesn't do it, Perl does.
> On OS/2, the standard command interpreter (cmd.exe)
> does not expand wildcards (`echo.exe *` prints *), but
>
> perl -w test.pl *
>
> ends up with lots of arguments in @ARGV.
This can only happen for some perls that know perfectly well how
arguments are handled by the shell.
UNIX shells strip escape characters and quotes. If I want a literal *, I
write \* and perl gets * which I want as such, not passed to a glob.
I think perl doesn't do this on windows because many people using Perl
on win32 have something decent in $ENV{SHELL} which does argument
expansion
- Alex
------------------------------
Date: Mon, 18 Oct 1999 16:33:29 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: @ARGV ---- Arrrrgggghhhh! :-)
Message-Id: <tZHO3.14412$E_1.848965@typ11.nn.bcandid.com>
In article <slrn80m7gq.bns.sholden@pgrad.cs.usyd.edu.au>,
Sam Holden <sholden@cs.usyd.edu.au> wrote:
>(someone else wrote:)
>>feature" I'm struggling to think of an application where you would not
>>want the filenames expanded for you.
>
>Say the first argument to grep, those regexes tend get stuffed up when they
>get expanded to file names. ;)
The MS-DOS REN command. REN *.RAW *.DAT, which I did this morning,
renames a.raw to a.dat, b.raw to b.dat, etc.
The easy way to implement this in Unix is to use a different character:
ren %.raw %.dat.
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Sun Oct 17 1999
23 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Mon, 18 Oct 1999 16:45:58 GMT
From: "Daniel W. Burke" <dwb1@home.com>
Subject: Apache/mod_perl/ApacheDBI problem
Message-Id: <Pine.LNX.4.10.9910181134420.9788-100000@cc569157-a.warn1.mi.home.com>
Hello,
I seem to be running into a problem with the ApacheDBI module. When I
try to use the module in httpd.conf, on startup I get an error from
DynaLoader.pm, that it cannot load the DBI module.
When I built mod_perl, the "make test" gave me the similar error about
loading File::IO, but I can load use File::IO without any trouble in
a normal script, which is the confusing part. (And I do have other
scripts that communicate with our oracle database no trouble). This
is the error apache gives on bootup:
Syntax error on line 867 of /opt1/apache/conf/httpd.conf:
Can't load '/usr/local/lib/perl5/site_perl/5.005/sun4-solaris/auto/DBI/DBI.so' for module DBI: ld.so.1: /opt1/apache/bin/httpd: fatal: relocation error: symbol
not found: main: referenced in /usr/local/lib/perl5/site_perl/5.005/sun4-solaris/auto/DBI/DBI.so at /usr/local/lib/perl5/5.00503/sun4-solaris/DynaLoader.pm line 169.
at /usr/local/lib/perl5/site_perl/5.005/sun4-solaris/DBI.pm line 156
BEGIN failed--compilation aborted at /usr/local/lib/perl5/site_perl/5.005/sun4-solaris/DBI.pm line 156.
BEGIN failed--compilation aborted at /usr/local/lib/perl5/site_perl/5.005/Apache/DBI.pm line 4.
And here is my mod_perl specific lines in httpd.conf:
Line 867 is the Apache::DBI line.
Alias /perl-bin/ "/opt1/apache/perl-bin/"
PerlWarn On
PerlModule Apache::StatINC
PerlModule Apache::DBI
PerlTaintCheck On
<Location /perl-bin>
SetHandler perl-script
PerlHandler Apache::Registry
Options ExecCGI
PerlSendHeader Off
PerlInitHandler Apache::StatINC
PerlSetVar StatINCDebug On
</Location>
<perl>
unshift(@INC, "/opt1/apache/perl-bin");
unshift(@INC, "/etc");
</perl>
Any help, or a push in the right direction would be greatly appreciated.
Dan.
------------------------------
Date: Mon, 18 Oct 1999 15:14:33 GMT
From: bmccoy@foiservices.com (Brett W. McCoy)
Subject: Re: Do you now an affordable Perl editor for Windows NT
Message-Id: <slrn80mej3.9kr.bmccoy@moebius.foiservices.com>
Also Sprach Tom Dominico, Jr. <news@tomd.org>:
>Personally I use UltraEdit when on Windows. This topic often comes up in c.l.pm., and I recommend you check:
>www.perl.com/reference/query.cgi?editors+index
I use Emacs under Windows myself -- I use Emacs everywhere else so when I
try to use a different editor, I forget that I am doing so and hit an
Emacs keystroke and only the Gods know what will happen then. :-) And
Emacs is free.
To be really clever, I start up smbsh under Linux and then edit my Windows
files using Xemacs.
--
Brett W. McCoy bmccoy@foiservices.com
Computer Operations Manager (Alpha Geek) http://www.foiservices.com
FOI Services, Inc./DIOGENES 301-975-0110
---------------------------------------------------------------------------
------------------------------
Date: 18 Oct 1999 16:56:20 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Do you now an affordable Perl editor for Windows NT
Message-Id: <380b4324_2@newsread3.dircon.co.uk>
Brett W. McCoy <bmccoy@foiservices.com> wrote:
> Also Sprach Tom Dominico, Jr. <news@tomd.org>:
>
>>Personally I use UltraEdit when on Windows. This topic often comes up in c.l.pm., and I recommend you check:
>>www.perl.com/reference/query.cgi?editors+index
>
> I use Emacs under Windows myself
>
Personally I recommend either searching Deja News for this subject or
looking at <http://www.perl.com/reference/query.cgi?editors> ...
/J\
--
"Most big companies don't like you very much, except hotels, airlines
and Microsoft, which don't like you at all" - Bill Bryson
------------------------------
Date: Mon, 18 Oct 1999 17:58:06 +0100
From: "Mark Hamlin" <mark@artdigital.co.uk>
Subject: equiv. of nice & simple ksh syntax
Message-Id: <7ufjjh$11m$1@pheidippides.axion.bt.co.uk>
Below is the Korn script outline, how do I achieve this in Perl. I want to
keep
the simplicity of the Korn method, ie :
1) no external requirements such as modules - no DBI!,
2) readability,
Here is the Korn version.
#!/bin/ksh
# korn business, assign variables
sqlplus -s user/pass << END_OF_SQL | tee -a $log
#sql business, maybe using variable assigned by korn
commit;
END_OF_SQL
# a bit more korn stuff
1) I know how to use backsticks, can I have a multiline thingy?
2) should I store the script as a multiline variable or as an array, with
variables for interpolation embedded in the string (nasty.. ugghhh) then
'$out = `sqlplus -s $myscript`
3) tie sqlplus into a filehandle thingy and then 'print SQLHANDLE << EO_SQL'
Thanks for any help
Mark
------------------------------
Date: Mon, 18 Oct 1999 16:12:06 GMT
From: mark_f_edwards@my-deja.com
Subject: hpux perl oracle
Message-Id: <7ufgsb$n5i$1@nnrp1.deja.com>
hello all-
i have written a couple of scripts to build/load & test hpux perl oracle
on v12....
anyone want them, write & ask!
thx, mark_f_edwards@excite.com
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 18 Oct 1999 10:05:02 -0500
From: Michael Yuan <juntao@pan.as.utexas.edu>
Subject: Need help -- How to display an existing web page
Message-Id: <Pine.GS4.4.10.9910180955170.93-100000@pan.as.utexas.edu>
Hi, I am quite new here. So, excuse me if I am asking a dumb question, but
I do need your help ...
The problem is that I have a set of existing web pages. It is a folder
containing several .html files and several .jpg images. All the links and
images are inside this folder using relative paths. So, there is no
problem to display them if I install them under "test" directory under my
document root and point the browser to http://whatever.edu/test/index.html
However, I want to use a perl script to display them (I do not want the
user to see its path). I can write one to read "test/index.html" and print
line-by-line to the browser and see all the text from index.html But since
the relative paths to images and other html files are not correct (I am in
cgi-bin not test directory, I believe), the images and links are broken.
Can anyone tell me how to do that? Your help is appreciated.
Michael
------------------------------
Date: Mon, 18 Oct 1999 17:04:27 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Need help -- How to display an existing web page
Message-Id: <vqIO3.14458$E_1.853057@typ11.nn.bcandid.com>
In article <Pine.GS4.4.10.9910180955170.93-100000@pan.as.utexas.edu>,
Michael Yuan <juntao@pan.as.utexas.edu> wrote:
>However, I want to use a perl script to display them (I do not want the
>user to see its path). I can write one to read "test/index.html" and print
>line-by-line to the browser and see all the text from index.html But since
>the relative paths to images and other html files are not correct (I am in
>cgi-bin not test directory, I believe), the images and links are broken.
>
>Can anyone tell me how to do that? Your help is appreciated.
You parse the HTML in your script, look for relative links, and modify
the relative links to point to something different, such as another
query to your script.
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Sun Oct 17 1999
23 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: 18 Oct 1999 11:30:19 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: One bug with local and one bug with perlbug
Message-Id: <x74sfofzzo.fsf@home.sysarch.com>
perlbug seems to be broken right now (or the mail system behind it
is). so just mail the bug (and it seems to be one to me) directly to
perl5 porters at: perl5-porters@perl.org
use a subject which says something like:
BUG: local scope modifies pos()
and mention that perlbug is down.
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, 18 Oct 1999 17:01:41 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Passing values to and from File::Find
Message-Id: <VnIO3.14451$E_1.852474@typ11.nn.bcandid.com>
In article <2jGO3.14877$D33.41761@ozemail.com.au>,
Neale Morison <nmorison@ozemail.com.au> wrote:
>I'm using File:Find to construct arrays of files and directories. I'd like
>avoid using global or main:: package variables for the arrays. Is there a
>way to use 'my' variables declared in list_all, or return something from
>list_all_proc? The File::Find documentation indicates you can pass the find
>function a sub reference.
I seem to recall that named subs aren't closed in their compilation
environment, but anonymous subs are closed in their evaluation
environment, or something.
With that in mind, this modification of your program seems to work:
#!/usr/bin/perl -w
use strict;
use File::Find;
my @all_files=();
my @all_dirs=();
my $list_all_proc = sub {
my $curdir = $File::Find::dir;
my $file = $curdir.'/'.$_;
if (-f $_ ) {
push @all_files, $file;
} else {
push @all_dirs, $file;
}
};
sub list_all
{
my $dir = ".";
find $list_all_proc, $dir;
}
list_all;
print "all dirs: @all_dirs\nall files: @all_files\n";
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Sun Oct 17 1999
23 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Mon, 18 Oct 1999 09:51:46 -0700
From: Jon Shemitz <jon@midnightbeach.com>
Subject: Perl Builder [Was "Do you now an affordable Perl editor for Windows NT"]
Message-Id: <380B5022.21F87B3C@midnightbeach.com>
I looked at http://www.perl.com/reference/query.cgi?section=editors and
found "Perl Builder", which looks like just what I'd like to use: a
Win32 IDE with syntax highlighting and built-in debugging. However, the
free trial period is a bit short, and the price is high enough to make
me wary of buying something that might end up as shelfware. Can anyone
who's tried it post (or mail me) a quickie review? Thanks!
--
http://www.midnightbeach.com - Me, my work, my writing, and
http://www.midnightbeach.com/hs - my homeschool resource pages
------------------------------
Date: Mon, 18 Oct 1999 16:29:47 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Perl parser / brackets in C language
Message-Id: <%VHO3.14408$E_1.848528@typ11.nn.bcandid.com>
In article <7uf3a8$e6a$1@nnrp1.deja.com>, <sintes@my-deja.com> wrote:
>I'm looking for a PERL script which allows to add a bracket
>in all cases for the if,else,for instructions.
>
>for instance
>
>if(condition)
> instruction
>
>must be changed to
>
>if(condition)
> {
> instruction
> }
This sounds like a very useful script.
See my post of a few days ago about Ada parsing. You'll have to do
something similar with C.
You might be able to get away with a half-assed implementation if you
run the C code through "indent" first. (Assuming "indent" understands
your code correctly; it may not.)
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Sun Oct 17 1999
23 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Mon, 18 Oct 1999 18:19:29 GMT
From: mirak63@yahoo.com
Subject: Problem w/ PERL and SQL
Message-Id: <380b6397.2603734@news.vnet.net>
I know this may not be the right forum for this question
and if it isn't please direct me to a NG that is better suited...
When I push a scaler in to a SQL database (SQL 7)
the data shows up OK. However, when I retrieve the same
data using PERL, the data is truncated to 255 characters.
Does anyone have any ideas as to why?
Thanks,
S. Bentley
susan.a.bentley@nationsbank.com
------------------------------
Date: Mon, 18 Oct 1999 16:43:54 GMT
From: Scratchie <AgitatorsBand@yahoo.com>
Subject: Re: Problem w/ PERL and SQL
Message-Id: <e7IO3.328$LR3.73165@news.shore.net>
mirak63@yahoo.com wrote:
: When I push a scaler in to a SQL database (SQL 7)
: the data shows up OK. However, when I retrieve the same
: data using PERL, the data is truncated to 255 characters.
Just a wild guess, but it sounds like a problem with your database, not
Perl.
Does it show up OK when you retrieve it without using Perl?
--Art
--
--------------------------------------------------------------------------
National Ska & Reggae Calendar
http://www.agitators.com/calendar/
--------------------------------------------------------------------------
------------------------------
Date: Mon, 18 Oct 1999 17:53:20 +0200
From: Joern Stein <eedjoes@eed.ericsson.se>
Subject: PUT request in ftp?
Message-Id: <380B4270.56CBB29D@eed.ericsson.se>
Hi there,
I want to use the UserAgent to put something on an ftp-server. The code
below works if I replace PUT with GET: I then get the index.html file at
the specified address, so I guess networking is not the problem. But how
do I specify which file I want to upload?
$ua = LWP::UserAgent->new();
$ua->proxy(['http','ftp'] => 'http://www-proxy:8080');
$ua->timeout(30);
$url='ftp://user:password@ftp.blablabla.com/';
$req=HTTP::Request->new("PUT", $url);
$resp=$ua->request($req);
print $resp->content;
If someone wants to know why I don't just use Net::FTP: I have no idea
how to use that with our firewall...
Any help is greatly apprectiated.
--
Cheers
Joern Stein
-----------------------------t--h--e--r--e--i--s--n--o--s--p--o--o--n-
Joern's Palm Pilot und S25 Seiten:
http://www.geocities.com/joern.stein
------------------------------
Date: Mon, 18 Oct 1999 09:27:47 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Q: Truncate string length?
Message-Id: <MPG.1274ea57daa1bd2898a0b4@nntp.hpl.hp.com>
In article <7uedsb$mjp$1@charm.magnus.acs.ohio-state.edu> on 18 Oct 1999
06:14:35 GMT, Ilya Zakharevich <ilya@math.ohio-state.edu> says...
> [A complimentary Cc of this posting was sent to Craig Berry
> <cberry@cinenet.net>],
> who wrote in article <s0l9hfeer0160@corp.supernews.com>:
> > You have it, right there...what do you think should go next? If you mean
> > how do you make it apply back to $TheField, just assign the value:
> >
> > $TheField = substr($TheField, 0, 500);
>
> I would think it is *ways* better do it the other way around:
>
> substr($TheField, 500) = "";
Only if you are sure the string has at least 500 characters. Otherwise
you get a 'substr outside of string' warning.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Mon, 18 Oct 1999 09:19:29 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Range checking
Message-Id: <MPG.1274e865fe936b1298a0b3@nntp.hpl.hp.com>
In article <x7d7udf8qp.fsf@home.sysarch.com> on 18 Oct 1999 03:06:38 -
0400, Uri Guttman <uri@sysarch.com> says...
> >>>>> "N" == Neko <tgy@chocobo.org> writes:
> N> On Sun, 17 Oct 1999 11:49:19 -0700, lr@hpl.hp.com (Larry Rosler) wrote:
> >> if ($min < $x && $x <= $max)
> >> Short of the seven superfluous spaces, no one will beat par on this
> >> hole.
>
> N> if ($min < $x & $x <= $max)
>
> N> What do I win? :)
>
> a whack on the nose with larry's 2 iron. that isn't the same logic as
> his short circuits and yours doesn't. i see the :) so i think you know
> that. in this case with no (obvious) side effects that is fine. what if
> any of those scalars were tied with hidden side effects? if you wrote
> that for real i would join larry in beating you to a pulp.
There are a couple of other minor problems with doing bitwise 'and':
It will be slower if the first test yields 'false', because the second
test has to be done anyhow (in case of side effects; see above).
It relies on the conversion of Boolean 'true' to 1, which I believe is
universally the case, but which isn't documented. Suppose each
comparison is 'true', but the value of the first is converted to 1 and
that of the second to 2. (These conversions to 1 *are* documented in C,
and I think they should be in Perl also.)
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Mon, 18 Oct 1999 06:01:12 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Scalars with special characters
Message-Id: <85reu7.n6a.ln@magna.metronet.com>
c_j_marshall@my-deja.com wrote:
: I'm using perl with the CTlib module to access sybase.
I haven't used that module, I dunno if it eval()s your $sql.
I expect not.
In that case, there aren't any special characters (other than
the string delimiter) to worry about.
: Is there a better way of constructing a string containing special
: characters in a 'pretty' way.
Maybe, but you don't have any special characters in your query,
so I'm wondering why you are asking?
: I need to make my code as clear as
: possible as I know it will be maintained by people with no Perl, Sybase
: (or indeed Computing in general) knowledge.
: e.g. my query is:
: select dateadd(ss,M_TIME_CMP,M_DATE_CMP), M_DATE_SYS, M_COMMENT
: from TRN_EODA_DBF
: where M_DATE_SYS >=
: (select max(M_DATE_SYS)
: from TRN_EODA_DBF
: where M_COMMENT like '%BO EOD%'
: and M_START_END = 'START')
: and (M_COMMENT like '%BO EOD%' or
: M_COMMENT like '%Back-office%')
: order by M_DATE_CMP, M_TIME_CMP
my $sql =<<ENDQUERY;
select dateadd(ss,M_TIME_CMP,M_DATE_CMP), M_DATE_SYS, M_COMMENT
from TRN_EODA_DBF
where M_DATE_SYS >=
(select max(M_DATE_SYS)
from TRN_EODA_DBF
where M_COMMENT like '%BO EOD%'
and M_START_END = 'START')
and (M_COMMENT like '%BO EOD%' or
M_COMMENT like '%Back-office%')
order by M_DATE_CMP, M_TIME_CMP
ENDQUERY
That looks pretty maintainable to me.
"here-doc"s are documented in the perldata.pod man page.
: and the best format I've come up with so far is:
: my $sql = "select dateadd\(ss\,M_TIME_CMP\,M_DATE_CMP\)\, M_DATE_SYS\,
You should only need to escape:
$
@
"
[snip more prolifically backslashed stuff ]
: Which is fairly hideous.
and unnecessary :-)
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 18 Oct 1999 18:35:14 +0100
From: Tobias Byron Carlsson <Tobias.Byron-Carlsson@ivf.se>
Subject: Script result to Browser problem!
Message-Id: <380B5A51.918D277C@ivf.se>
Hello!
I've written a search "engine" that works perfectly (2 Mb file search).
Now i want the script to search a new 4.4Mb file which takes some
time...
When testing the program with Netscape/MIE I get perfect results if I
search for info that is in the beginning of the file, if searching for
something that is somewhere in the middle of the file the results get
shopped -the whole resulting html page isn't loaded. If I search for
something that is in the end I get a 500 Internal Server Error...
When testing the program with telnet it works perfectly.
???
Some kind of timeout? On telnet it just takes a couple of seconds to do
the search (max 30 seconds). Is it possible to send somkind of wait to
the browser?
Very grateful for fast respons!
/Byron
tcn@cadcam.kth.se
O
------------------------------
Date: Mon, 18 Oct 1999 16:57:45 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: slow regexp
Message-Id: <dkIO3.14443$E_1.851887@typ11.nn.bcandid.com>
In article <380b28f2.313098151@nntp-serv.cam.ac.uk>,
Hugh Denman <hd213@cam.ac.uk> wrote:
>I'm stripping html tags from a string, using Tom Christiansen's
>striphtml
>(http://www.perl.com/CPAN/authors/Tom_Christiansen/scripts/striphtml.gz).
>In general it's great, and quite quick, and far cleverer than my
>original $text =~ s/<[^>]*>//g; However, one html file takes
>(comparitively) ages to crunch. The file contains the tag
>
><IMG SRC="various/cnrtext.gif" VALIGN="MIDDLE" WIDTH="178" HEIGHT="47"
>VSPACE="0" HSPACE="0" BORDER="0" LOWSRC="various/cnrtextz.gif">
>
>and if this tag is removed, the file zips through - though a file
>containing the tag by itself doesn't slow things down. The regexp that
>we're dealing with is
>
>
>s{ < # opening angle bracket
>
> (?: # Non-backreffing grouping paren
> [^>'"] * # 0 or more things that are neither > nor ' nor "
> | # or else
> ".*?" # a section between double quotes (stingy match)
> | # or else
> '.*?' # a section between single quotes (stingy match)
> ) + # repetire ad libitum
> # hm.... are null tags <> legal? XXX
> > # closing angle bracket
>}{}gsx; # mutate into nada, nothing, and niente
>
>If anyone has any suggestion as to why this tag slows things down so
>much, I'd be very grateful.
This is discussed in Friedl's book. This expression basically reduces to
<(x*|y)+>
Which has the problem that if you have N x's in a row, they can be
matched in something like 2^N ways.
One thing that bothers me as I read this: with a traditional NFA like
Perl's, which will always take the first alternate if it can (rather
than taking the one which gives the longest match), this expression
should only take a long time if it fails, forcing all 2^N or so ways of
matching to be tried before failing. But it doesn't look like this
expression should fail. Indeed, trying it (see following script), it
looks like it succeeds on my version of Perl, and fairly quickly, too.
#!/usr/bin/perl -w
use strict;
$_ = q(<IMG SRC="various/cnrtext.gif" VALIGN="MIDDLE" WIDTH="178" HEIGHT="47"
VSPACE="0" HSPACE="0" BORDER="0" LOWSRC="various/cnrtextz.gif">);
if (s{ < # opening angle bracket
(?: # Non-backreffing grouping paren
[^>'"] * # 0 or more things that are neither > nor ' nor "
| # or else
".*?" # a section between double quotes (stingy match)
| # or else
'.*?' # a section between single quotes (stingy match)
) + # repetire ad libitum
# hm.... are null tags <> legal? XXX
> # closing angle bracket
}{}gsx) { print "matched $&\n" } else { print "didn't match\n" }
This outputs:
matched <IMG SRC="various/cnrtext.gif" VALIGN="MIDDLE" WIDTH="178" HEIGHT="47"
VSPACE="0" HSPACE="0" BORDER="0" LOWSRC="various/cnrtextz.gif">
A second thing that bothers me is that your x* strings in that tag are
none of them more than 8 characters long. So even if it is doing the
weird backtracking from hell, it shouldn't backtrack more than a few
thousand times.
One way to make it faster in the bad case is to remove the * on the x;
this will make it slower in the usual case, but much faster in the
worst case. It also keeps the matcher from matching null tags <>,
which might be considered a good thing.
Another way to make it faster in the bad case, without hurting the
normal case, is to unroll it a bit, as described in Friedl's book.
This involves transforming from <(x*|y)*> to something like <x*(x*y)*>,
which keeps out the exponential x** demons. But it's not quite clear
to me how to modify this for the <(x*|y)+> case. I don't suppose it
matters; the only difference between z* and z+ is that z* can match the
null string, and (x*|y)+ can match x*, which can match the null string
anyway.
You mention that a file containing the tag by itself doesn't slow
things down. I wonder if this pattern is, for some reason, trying to
match the rest of the file? Maybe the .*?'s are reaching past the end
for some reason?
Oh well. This post doesn't answer your question, but maybe it's a
direction to look in.
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Sun Oct 17 1999
23 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Mon, 18 Oct 1999 09:14:03 -0700
From: tgy@chocobo.org (Neko)
Subject: Re: Uses of #
Message-Id: <ITsLOE5C7DIkLFWa6NHNG97NiNkk@4ax.com>
On 17 Oct 1999 18:30:42 -0700, merlyn@stonehenge.com (Randal L. Schwartz)
wrote:
>Thus, only "perl" can parse "Perl" continues to be true.
>
> I would write a verse
> of haiku to show the point,
> but I'm not that good. :-)
To be pedantic,
the word 'haiku' has three
not two syllables.
--
Neko | tgy@chocobo.org | Will hack Perl for a moogle stuffy! =^.^=
------------------------------
Date: Mon, 18 Oct 1999 17:35:47 +0200
From: Alex Rhomberg <rhomberg@ife.ee.ethz.ch>
Subject: Re: variables on the right side of Reg Exp
Message-Id: <380B3E53.9665C590@ife.ee.ethz.ch>
Garrett Walker wrote:
>
> Greetings All,
>
> I am trying to do the following (possibly bizarre?) thing: I want
> to be able to specify the parameters for search and replace from the
> command line. Such as:
>
> ./myprog -f foo -r bar
>
> where within myprog I do something like:
>
> $myvar =~ s/$opt_f/$opt_r/g;
>
> Now, for the most part, this works well. But my life would be much
> better if the following worked:
>
> ./myprog -f "([0-9])" -r "test\$1"
You can enter some valid perl code containing $1 as second argument
and then take an eeg of it:
$opt_r = qq{"$opt_r"}; #puts it in double quotes, so it can be evalled
s/$opt_f/$opt_r/eeg; #measures the brain waves for DWIM
- Alex
------------------------------
Date: Mon, 18 Oct 1999 09:47:48 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: variables on the right side of Reg Exp
Message-Id: <MPG.1274ef0d31a501e398a0b5@nntp.hpl.hp.com>
In article <7ufbcn$csc$1@remus.rutgers.edu> on 18 Oct 1999 10:38:15 -
0400, Garrett Walker <cuz@remus.rutgers.edu> says...
> I am trying to do the following (possibly bizarre?) thing: I want
> to be able to specify the parameters for search and replace from the
> command line. Such as:
>
> ./myprog -f foo -r bar
>
> where within myprog I do something like:
>
> $myvar =~ s/$opt_f/$opt_r/g;
>
> Now, for the most part, this works well. But my life would be much
> better if the following worked:
>
> ./myprog -f "([0-9])" -r "test\$1"
>
> The match in $opt_f works - all single digits match. But I cannot
> find a way to get the $1 to act as it should in the regex. Instead,
> it just replaces all single digits with "test$1". I have poured
> over the perlre and perlop man pages but with no help (It may have
> been there and I missed it, though). Any suggestions? Is there
> some other way to get this functionality that I am missing?
You will have to use eval() on the statement containing the
substitutions. This may be relatively slow.
eval "$myvar =~ s/$opt_f/$opt_r/g";
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 19 Oct 1999 00:50:14 -0400
From: Ally Kwon <ewha95@shinbiro.com>
Subject: what is SHTML ?
Message-Id: <380BF886.71538C91@shinbiro.com>
i know what HTML is, but what is SHTML ?
how is it different from HTML ?
------------------------------
Date: 18 Oct 1999 16:49:24 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Where is Benchmark.pm?
Message-Id: <380b4184_2@newsread3.dircon.co.uk>
Garrett Casey <remove_this_prefix_adms1@cts.com> wrote:
> Where can I get the Benchmark module. I tried
> http://www.perl.com/CPAN/modules/by-module/Benchmark/ and it is not
> listed.
It is part of the distribution you should have it already. If you havent
then you have an older Perl that needs upgrading ...
/J\
--
"I was the chief make-up artist on the Titanic" - Tina Earnshaw, Chief
Make-Up Artist, Titanic
------------------------------
Date: Mon, 18 Oct 1999 08:52:29 -0700
From: Andrew Perrin <aperrin@demog.berkeley.edu>
Subject: Re: Why does this match take so long?
Message-Id: <380B423D.81A98E3F@demog.berkeley.edu>
Yes, your ESP was correct, that's what I was trying to do. And thanks to each
of you for your responses.
Andy Perrin
Alex Rhomberg wrote:
> Andrew J Perrin wrote:
>
> > Benchmark: timing 5 iterations of Match...
> > Match: 318 wallclock secs (318.26 usr + 0.00 sys = 318.26 CPU)
> >
> > That's a long time to do the match, isn't it? This is running on a P166
> > running NT and perl 5.005_03.
>
> It is quite a long time. I had to increase the count a bit to get timing
> results :-)
>
> my PSI::ESP module tells me you want to find the word "children"
> separated no more than 10 words from "violence". The second regexp
> should do this. Yours does about the same as my third
>
> timethese (50000,
> {'Match' => 'if ($foo =~ /children(?:\b.*\b){1,10}violence/)
> { $hit1++;}',
> 'Match2' => 'if ($foo =~ /children\W+(?:\w+\W+){0,10}violence/)
> {$hit2++;}',
> 'Match3' => 'if ($foo =~ /children\b.*\bviolence/)
> {$hit3++;}'
> }
> );
> Benchmark: timing 50000 iterations of Match, Match2, Match3...
> Match: 6 wallclock secs ( 7.44 usr + 0.00 sys = 7.44 CPU)
> Match2: 2 wallclock secs ( 1.87 usr + 0.00 sys = 1.87 CPU)
> Match3: 1 wallclock secs ( 0.71 usr + 0.00 sys = 0.71 CPU)
>
> Seems to be a tiny factor of 500_000 faster than your machine :-)
> This is a 500 MHz Alpha running Linux and $] == 5.00503
>
> - Alex
------------------------------
Date: Mon, 18 Oct 1999 16:50:57 GMT
From: Richard Lawrence <ralawrence@my-deja.com>
Subject: Windows -> UNIX text problems
Message-Id: <7ufj5c$oq6$1@nnrp1.deja.com>
Hello there, I wonder if anyone can help.
I have a Windows program that connects to a webpage and downloads its
contents for processing. These contents are generated by a perl program
running on the server.
Now when it is downloaded the file looks exactly like the sort of file
you'd get if you downloaded a text file in BIN mode. The CR's are
screwed up because of the difference in the way Windows and UNIX
handles them.
Is there any way I can get my perl program to output the text in a
"Windows friendly" format for downloading? I tried to manually add CR
and LF to the end of each line with:
#!/usr/bin/perl -w
use strict;
open (FILE, ">file.txt") || die "can't write to file.txt: $!";
print FILE "hello\13\10";
print FILE "there\13\10";
close FILE;
but when I sent the file across this didn't work.
Can anyone give me any suggestions?
Regards
Rich
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
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 1108
**************************************