[19453] in Perl-Users-Digest
Perl-Users Digest, Issue: 1648 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Aug 29 14:05:43 2001
Date: Wed, 29 Aug 2001 11: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: <999108310-v10-i1648@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 29 Aug 2001 Volume: 10 Number: 1648
Today's topics:
Re: accessing hash of hashes in package (Laith Suheimat)
Re: accessing hash of hashes in package (Laith Suheimat)
Re: accessing hash of hashes in package <info@fruiture.de>
ANNOUNCE: OpenInteract 1.2 <chris@cwinters.com>
Re: Difference between .pl, .cgi, and .pm File Extensio <jurgenex@hotmail.com>
Re: Editor Question <Doug.King@abh.siemens.com>
Re: eval problem (Bernard El-Hagin)
Re: eval problem <homer@simpsons.com>
Re: eval problem <dbohl@sgi.com>
Re: eval problem (Bernard El-Hagin)
Re: eval problem <vze2r2j8@verizon.net>
Re: eval problem (Jason Kawaja)
formatted ouput (jprok)
Re: formatted ouput (Anno Siegel)
Re: formatted ouput (Bernard El-Hagin)
Re: formatted ouput <vze2r2j8@verizon.net>
Re: how to do 'c' - 'a' = 2 in perl? <djberge@uswest.com>
How to name a Tie:: and namespace issues (Yves Orton)
Re: Is element in array <joe+usenet@sunstarsys.com>
Re: Is element in array <comdog@panix.com>
Re: Java mucks up split (Yves Orton)
Re: Line Breaking in Japanese <riechert@pobox.com>
Netscape Server / iPlanet caching Perl programs (Joel)
paginate search results with DBI (paul)
Re: paginate search results with DBI (mbower)
Re: paginate search results with DBI <vze2r2j8@verizon.net>
Passing constructor arguments in Class::Struct (BC)
Pattern matching, grabing everything right of the match (Steve McDonald)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 29 Aug 2001 08:16:31 -0700
From: l.suheimat@mdx.ac.uk (Laith Suheimat)
Subject: Re: accessing hash of hashes in package
Message-Id: <69f8a22d.0108290716.102e992a@posting.google.com>
"fruiture" <info@fruiture.de> wrote:
> it should rather be
> foreach $inner_key (keys %{ $pkg::hoh{$outer_key} } ) {
> and then the rest will work.
thanks, that seems to do the trick. here's the code snippet:
use pkg;
pkg::create_hoh();
foreach $outer_key (keys %pkg::hoh) {
print "\n$outer_key";
foreach $inner_key (keys %{$pkg::hoh{$outer_key}}) {
print "\n$inner_key : $pkg::hoh{$outer_key}{$inner_key}";
}
}
i think i now understand this syntax:
%{$pkg::hoh{$outer_key}}
as meaning:
get the (scalar) value corresponding to key $hoh{$outer_key}, then do
a keys lookup on this scalar (which is actually a hash, hence %)
> you see, you problem wasn't the package, but the reference:
> % perldoc perlref
will i ever fully understand references?! :)
laith
------------------------------
Date: 29 Aug 2001 08:29:27 -0700
From: l.suheimat@mdx.ac.uk (Laith Suheimat)
Subject: Re: accessing hash of hashes in package
Message-Id: <69f8a22d.0108290729.5e5a7ee5@posting.google.com>
"Homer J Simpson" <homer@simpsons.com> wrote:
> Hmm I not sure if I'm write about this by why not have your pkg::create_hoh
> routine return a reference to the hash you are trying to access. Such as...
you're right. i've tried it and it works as suggested. here's the
snippet from the calling script:
use pkg;
$hoh_ref = pkg::create_hoh();
%hoh = %{$hoh_ref};
foreach $outer_key (keys %hoh) {
print "\n$outer_key";
foreach $inner_key (keys %{$hoh{$outer_key}}) {
print "\n$inner_key : $hoh{$outer_key}{$inner_key}";
}
}
i'm just wondering which is more efficient: accessing the hash in the
package's namespace, or copying the hash into the caller's namespace?
is the latter solution equivalent to switching namespaces, viz:
use pkg;
pkg::create_hoh();
package pkg;
foreach $outer_key (keys %hoh) {
print "\n$outer_key";
foreach $inner_key (keys %{$hoh{$outer_key}}) {
print "\n$inner_key : $hoh{$outer_key}{$inner_key}";
}
}
cheers
laith
------------------------------
Date: Wed, 29 Aug 2001 18:59:16 +0200
From: "fruiture" <info@fruiture.de>
Subject: Re: accessing hash of hashes in package
Message-Id: <9mj7fb$51n$02$1@news.t-online.com>
"Laith Suheimat" <l.suheimat@mdx.ac.uk> wrote:
> [...]
> will i ever fully understand references?! :)
>
in fact it is too easy. In my head references are simply strings:
my %hash = ();
my @array = ();
my $scalar = '';
my $ref = \$scalar;
print $ref; #SCALAR(0x54b64d)
and you get this scalar by puttin ${} around all:
print ${ $ref }; #shorter: print $$ref
$ref = \@array;
print $ref; #ARRAY(0x56e546d)
print @{ $ref }; #shorter: print @$ref
it is the same with objects:
$ref bless \%hash,'MYPACKAGE';
print $ref; #MYPACKAGE=HASH(0x56446498)
print keys %{ $ref };
--
require Time::HiRes;my @m=split(/8/,55.52.56.49.49.55.56.49.49.53);push
@m,map{($_%2)?$_-1:$_+1} map ord($_),split//,'u!`onuids!Qdsm!i`bjds';
unshift @m,43 for(0..@m);for(0..@m){print map chr($_),@m[0..(@m/2-1)];
push @m,shift @m;print "\b"x(@m/2);Time::HiRes::usleep(0246*0xA**3);}
------------------------------
Date: Wed, 29 Aug 2001 14:25:22 GMT
From: Chris Winters <chris@cwinters.com>
Subject: ANNOUNCE: OpenInteract 1.2
Message-Id: <toq19qrkvgatee@corp.supernews.com>
A new version (1.2) of OpenInteract has been released to
CPAN. OpenInteract is an extensible web application server built on
Apache, mod_perl, the Template Toolkit and SPOPS object persistence.
This is a substantial upgrade -- if you're upgrading from an old
version, please read the 'UPGRADE' and 'Changes' files.
- Now supports LDAP for use as an object store and authentication
backend. Thanks to MSN Marketing Service Nordwest GmbH for funding
development!
- Beter Template Toolkit integration with a TT Provider and TT Plugin
- Many bugfixes and general enhancements
URLs:
Download the source (also making the CPAN rounds):
http://sourceforge.net/project/showfiles.php?group_id=50416
Release notes/changelog (much more detailed than above):
http://sourceforge.net/project/shownotes.php?release_id=50416
Sourceforge home (mailing lists, CVS, bugs, etc.):
http://sourceforge.net/projects/openinteract/
Other home:
http://www.openinteract.org/
Thanks!
Chris
--
Chris Winters (chris@cwinters.com)
Building enterprise-capable snack solutions since 1988.
------------------------------
Date: Wed, 29 Aug 2001 08:59:08 -0700
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Difference between .pl, .cgi, and .pm File Extensions.
Message-Id: <3b8d114d@news.microsoft.com>
"Bob Holden" <bob@eawf.nospam.com> wrote in message
news:l33potsh0n3evogfoqhg7kthl6bicd7l30@4ax.com...
> What's the difference between a .pl, .cgi, and a .pm file, and why
> would you use one over another?
Well, it's a different file name.
And a rose by any other name smelles as sweet.
jue
------------------------------
Date: Wed, 29 Aug 2001 11:25:24 -0400
From: Doug King <Doug.King@abh.siemens.com>
Subject: Re: Editor Question
Message-Id: <3B8D0964.879F20EC@abh.siemens.com>
I have a similar problem with emacs 20.6. It doesn't understand the ${var}
syntax.
Try putting a space between the $ and the {.
------------------------------
Date: Wed, 29 Aug 2001 13:17:09 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: eval problem
Message-Id: <slrn9opqc9.oa.bernard.el-hagin@gdndev25.lido-tech>
On Wed, 29 Aug 2001 15:52:40 +0200, Peter Sørensen <maspsr@dou.sdu.dk> wrote:
>Hi,
>
>I want to search a string to see if a set of words is contained in the
>string.
>
>I have the characters in $string.
>
>I set up the following
>
>$search = "(\$string =~ ?WORD1?) || (\$string =~ ?WORD2?);
>if( eval $search) {
> ......
>
>and I get following error:
>
>Insecure dependency in eval while running with the -T switch at ....
>
>why??
This is quite clearly explained in:
perldoc perldiag
as are all of Perl's error messages.
You could also have a look at:
perldoc perlsec
for more info about security issues (one of which you have in your
example).
Cheers,
Bernard
--
perl -l54e's yyw q q tvmrx "h\ywx ersxliv zivp legoiv"qiy;y #a-zA-Z#d-gu-z#
chefghijklmnopqrstuvwxyzcJab-def-uPwxyzc;s j j s u u s t t s r r s
ppevalpereeteueje'
------------------------------
Date: Wed, 29 Aug 2001 14:16:05 +0100
From: "Homer J Simpson" <homer@simpsons.com>
Subject: Re: eval problem
Message-Id: <9miq23$5o3$1@news.formus.pl>
Hmm,
Not sure if I'm write but running perl with -T checks for tainting of data.
Basically it improves security, helping to make sure you don't do something
to important system files like the password file when you really mean to
append to your log file.
Using an eval on the string search I think gets flagged up with -T because
$search could contain arbitrary code, which could do anything....
Though I'll let someone else figure out how you get around it....
Thanks
Homer
"Peter Sørensen" <maspsr@dou.sdu.dk> wrote in message
news:9mio6a$l9c$1@news.net.uni-c.dk...
> Hi,
>
> I want to search a string to see if a set of words is contained in the
> string.
>
> I have the characters in $string.
>
> I set up the following
>
> $search = "(\$string =~ ?WORD1?) || (\$string =~ ?WORD2?);
> if( eval $search) {
> ......
>
> and I get following error:
>
> Insecure dependency in eval while running with the -T switch at ....
>
> why??
>
>
> Regards
>
> Peter Sorensen/University of Southern Denmark/email: maspsr@dou.sdu.dk
>
>
------------------------------
Date: Wed, 29 Aug 2001 08:27:38 -0500
From: Dale Bohl <dbohl@sgi.com>
Subject: Re: eval problem
Message-Id: <3B8CEDCA.C1078981@sgi.com>
"Peter Sørensen" wrote:
>
> Hi,
>
> I want to search a string to see if a set of words is contained in the
> string.
>
> I have the characters in $string.
>
> I set up the following
>
> $search = "(\$string =~ ?WORD1?) || (\$string =~ ?WORD2?);
> if( eval $search) {
> ......
>
> and I get following error:
>
> Insecure dependency in eval while running with the -T switch at ....
>
> why??
>
> Regards
>
> Peter Sorensen/University of Southern Denmark/email: maspsr@dou.sdu.dk
See http://www.perldoc.com/perl5.6/pod/perldiag.html
for an explanation.
--
Thanks,
Dale
Dale Bohl
SGI Information Services
dbohl@sgi.com
(715)-726-8406
http://wwwcf.americas.sgi.com/~dbohl/
------------------------------
Date: Wed, 29 Aug 2001 13:28:57 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: eval problem
Message-Id: <slrn9opr2d.oa.bernard.el-hagin@gdndev25.lido-tech>
On Wed, 29 Aug 2001 08:27:38 -0500, Dale Bohl <dbohl@sgi.com> wrote:
>"Peter Sørensen" wrote:
>>
>> Hi,
>>
>> I want to search a string to see if a set of words is contained in the
>> string.
>>
>> I have the characters in $string.
>>
>> I set up the following
>>
>> $search = "(\$string =~ ?WORD1?) || (\$string =~ ?WORD2?);
>> if( eval $search) {
>> ......
>>
>> and I get following error:
>>
>> Insecure dependency in eval while running with the -T switch at ....
>>
>> why??
>>
>> Regards
>>
>> Peter Sorensen/University of Southern Denmark/email: maspsr@dou.sdu.dk
>
>See http://www.perldoc.com/perl5.6/pod/perldiag.html
>for an explanation.
Or look on your hard drive. Oh, but that would be silly.
Cheers,
Bernard
--
perl -l54e's yyw q q tvmrx "h\ywx ersxliv zivp legoiv"qiy;y #a-zA-Z#d-gu-z#
chefghijklmnopqrstuvwxyzcJab-def-uPwxyzc;s j j s u u s t t s r r s
ppevalpereeteueje'
------------------------------
Date: Wed, 29 Aug 2001 13:52:16 GMT
From: "Kurt Stephens" <vze2r2j8@verizon.net>
Subject: Re: eval problem
Message-Id: <ks6j7.84$jd.83919@typhoon1.gnilink.net>
"Peter Sørensen" <maspsr@dou.sdu.dk> wrote in message
news:9mio6a$l9c$1@news.net.uni-c.dk...
> Hi,
>
> I want to search a string to see if a set of words is contained in the
> string.
>
> I have the characters in $string.
>
> I set up the following
>
> $search = "(\$string =~ ?WORD1?) || (\$string =~ ?WORD2?);
> if( eval $search) {
> ......
>
> and I get following error:
>
> Insecure dependency in eval while running with the -T switch at ....
>
> why??
As others have mentioned, read perlsec for more information on taint
checking. In general, you should avoid using the eval EXPR form unless you
have a really good reason for generating code on the fly. In the case
above, you are probably better off generating the regular expression itself.
my @word_list = qw(WORD1 WORD2);
my $re = join "|", map { "\\b$_\\b" } @word_list;
if ($string =~ /$re/) {
# ...
}
The code above generates the regular expression /\bWORD1\b|\bWORD2\b/, which
performs a case sensitive match on word boundaries. This will match WORD1
or WORD2, but not Word1 or SOMEWORD2. The code above also has the advantage
that additional words can be added to the list without having to rewrite the
logic.
HTH,
Kurt Stephens
------------------------------
Date: Wed, 29 Aug 2001 17:22:05 +0000 (UTC)
From: kawaja@ece.ufl.edu (Jason Kawaja)
Subject: Re: eval problem
Message-Id: <slrn9oq97t.353.kawaja@kawaja.ece.ufl.edu>
for a better explaination -> http://www.perldoc.com/perl5.6/pod/perlsec.html
previously, Homer J Simpson <homer@simpsons.com> wrote:
> Hmm,
>
> Not sure if I'm write but running perl with -T checks for tainting of data.
> Basically it improves security, helping to make sure you don't do something
> to important system files like the password file when you really mean to
> append to your log file.
>
> Using an eval on the string search I think gets flagged up with -T because
> $search could contain arbitrary code, which could do anything....
>
> Though I'll let someone else figure out how you get around it....
>
> Thanks
> Homer
>
> "Peter Sørensen" <maspsr@dou.sdu.dk> wrote in message
> news:9mio6a$l9c$1@news.net.uni-c.dk...
>> Hi,
>>
>> I want to search a string to see if a set of words is contained in the
>> string.
>>
>> I have the characters in $string.
>>
>> I set up the following
>>
>> $search = "(\$string =~ ?WORD1?) || (\$string =~ ?WORD2?);
>> if( eval $search) {
>> ......
>>
>> and I get following error:
>>
>> Insecure dependency in eval while running with the -T switch at ....
>>
>> why??
>>
>>
>> Regards
>>
>> Peter Sorensen/University of Southern Denmark/email: maspsr@dou.sdu.dk
>>
>>
>
>
--
/* Regards,
Jason Kawaja, UF-ECE Sys Admin */
------------------------------
Date: 29 Aug 2001 06:11:44 -0700
From: john.prokopek@ubsw.com (jprok)
Subject: formatted ouput
Message-Id: <477748dc.0108290511.5dadce99@posting.google.com>
can "formats" be used for input as well as output?
thanks for the help
john
------------------------------
Date: 29 Aug 2001 13:49:05 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: formatted ouput
Message-Id: <9mirsh$qv5$1@mamenchi.zrz.TU-Berlin.DE>
According to jprok <john.prokopek@ubsw.com>:
> can "formats" be used for input as well as output?
Formats are an output-only affair. So much so that I can't begin to
guess what you even mean by "using formats for input".
Anno
------------------------------
Date: Wed, 29 Aug 2001 13:52:27 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: formatted ouput
Message-Id: <slrn9opsef.oa.bernard.el-hagin@gdndev25.lido-tech>
On 29 Aug 2001 13:49:05 GMT, Anno Siegel <anno4000@lublin.zrz.tu-berlin.de>
wrote:
>According to jprok <john.prokopek@ubsw.com>:
>> can "formats" be used for input as well as output?
>
>Formats are an output-only affair. So much so that I can't begin to
>guess what you even mean by "using formats for input".
I think he wants something like scanf(3) in C.
Cheers,
Bernard
--
perl -l54e's yyw q q tvmrx "h\ywx ersxliv zivp legoiv"qiy;y #a-zA-Z#d-gu-z#
chefghijklmnopqrstuvwxyzcJab-def-uPwxyzc;s j j s u u s t t s r r s
ppevalpereeteueje'
------------------------------
Date: Wed, 29 Aug 2001 15:01:19 GMT
From: "Kurt Stephens" <vze2r2j8@verizon.net>
Subject: Re: formatted ouput
Message-Id: <3t7j7.1825$Tz.1565999@typhoon2.gnilink.net>
"jprok" <john.prokopek@ubsw.com> wrote in message
news:477748dc.0108290511.5dadce99@posting.google.com...
> can "formats" be used for input as well as output?
>
> thanks for the help
>
> john
If you meant "Does perl have a built-in mechanism for reading fixed length
records?", try perldoc -f unpack.
HTH,
Kurt Stephens
------------------------------
Date: Wed, 29 Aug 2001 10:22:48 -0500
From: Mr Sunblade <djberge@uswest.com>
Subject: Re: how to do 'c' - 'a' = 2 in perl?
Message-Id: <3B8D08C8.5B11A819@uswest.com>
Abigail wrote:
> Craig Berry (cberry@cinenet.net) wrote on MMCMXIX September MCMXCIII in
> <URL:news:Xns910B8B94E9FD4cberrycinenetnet1@207.126.101.92>:
> __ tadmc@augustmail.com (Tad McClellan) wrote in
> __ news:slrn9onck7.sc0.tadmc@tadmc26.august.net:
> __ > cheng huang <cheng@cs.wustl.edu> wrote:
> __ >>Say I have a $letter variable and want to know what it is exactly, can
> __ >>sb.
> __ >
> __ > What is "sb"?
> __
> __ I first read it as 'antimony', but that's just me. :) I think it's a
> __ pointless hyperabbreviation of 'somebody'.
>
> I thought it stands for 'son of a bitch'.
>
No, that's "sob". :)
Regards,
Mr. Sunblade
--
"Evil will always triumph because Good is *dumb*."
-- Dark Helmet, 'Spaceballs: The Movie'
------------------------------
Date: 29 Aug 2001 07:19:27 -0700
From: demerphq@hotmail.com (Yves Orton)
Subject: How to name a Tie:: and namespace issues
Message-Id: <74f348f7.0108290619.5eabfdee@posting.google.com>
Hello all,
I am curious as to the current state of thinking regarding the Tie::
namespace.
On the modulelist most ties seem to named 'naturally' according to
their function such as
Tie::IxHash or Tie:SubstrHash
Whereas the less natural but more OOish might have been
Tie::Hash::Indexed (Tie::Hash::Ix??) and Tie::Hash::Substr
(personally I might even suggest restructuring the Tie:: namespace
into their components and keeping stubs that use the @ISA relationship
to refer to the reorganized classes. I _might_ suggest this because
as people contribute more and more tie classes the flat nature of the
namespace is going to get quite polluted indeed, I *won't* of course
because suggesting such a thing would get me lynched...) (Oops! :-)
Now my question is for a new Tie that I am about to submit to cpan
should I go along with the former or the later scheme?
FYI: The module I want to submit is a hash implemented using tries,
similer to Tree::Trie (actually mine impleements Tree::Trie as well)
but with a tie interface as well as an OO interface. So should this
be called
Tie::TrieHash
or
Tie::Hash::Trie
My personal 'gut' feeling is that the latter makes more sense, but I
would appreciate any thoughts on the matter from those that manage
these things.
yves
------------------------------
Date: 29 Aug 2001 09:45:24 -0400
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Is element in array
Message-Id: <m3pu9fnfnv.fsf@mumonkan.sunstarsys.com>
"cp" <cpryce@pryce.net> writes:
> The reason that I quoted the FAQ that covers this topic (perlfaq4 How can I
> tell whether a list or array contains a certain element?) is that grep in
> this context is mentioned, and the pitfalls discussed. You should read the
> whole FAQ, but since you haven't bothered to yet, I quote the relavent
> passage:
>
> " Please do not use
>
> $is_there = grep $_ eq $whatever, @array;"
>
> " or worse yet
>
>
> $is_there = grep /$whatever/, @array;"
> " These are slow (checks every element even if the first matches),
> inefficient (same reason), and potentially buggy (what if there are regexp
> characters in $whatever?). "
That passage sounds more like a bug report than anything else.
IMO the only reason "grep" is in the language is to emulate the
functionality of Unix's grep, which has an "-l" flag. In a boolean
context, I think it would be nice if perl6's grep would behave similarly.
Besides, the same FAQ you are browbeating Pascal with prequalifies
most of it's recommendations with
"If you are going to make this query many times over
arbitrary string values,"
which hardly resembles anything OP wrote, and if untrue
would make the most of the recommended faq answers utterly
stupid. Moreover, the FAQ's alternative to the single-line
grep answer spans 7 lines, and at best saves a couple of
milliseconds per test. Seems hardly worth mentioning the
"pitfalls of grep" in that case.
So let's see how these two extend beyond the context of
"If you're only testing once, then use:"
#!/usr/bin/perl -w
use Benchmark;
@array = 0..shift;
timethese -10, {
foreach => <<'CODE',
$elt_to_find = $array[rand @array];
$is_there = 0;
foreach $elt (@array) {
if ($elt == $elt_to_find) {
$is_there = 1;
last;
}
}
CODE
grep => <<'CODE',
$elt_to_find = $array[rand @array];
$is_there = grep $_ == $elt_to_find, @array;
CODE
};
__END__
% ./try.pl 10
foreach => 32607.00/s
grep => 34994.21/s
% ./try.pl 100
foreach => 8419.94/s
grep => 6521.52/s
% ./try.pl 1000
foreach => 929.41/s
grep => 608.79/s
% ./try.pl 10000
foreach => 88.10/s
grep => 57.16/s
(Figures from an AMD 233 running 5.6.1 on linux 2.4.)
Now imagine if grep were actually fixed so as to be memory-efficient
in a non-list context?
YMMV
--
Joe Schaefer "Never put off until tomorrow that which can be done the day
after tomorrow."
--Mark Twain
------------------------------
Date: Wed, 29 Aug 2001 11:41:59 -0400
From: brian d foy <comdog@panix.com>
Subject: Re: Is element in array
Message-Id: <comdog-D3E98E.11415929082001@news.panix.com>
In article <m3pu9fnfnv.fsf@mumonkan.sunstarsys.com>, Joe Schaefer
<joe+usenet@sunstarsys.com> wrote:
[snip]
> That passage sounds more like a bug report than anything else.
> IMO the only reason "grep" is in the language is to emulate the
> functionality of Unix's grep, which has an "-l" flag.
grep is much more powerful that than though, and certainly doesn't
act like `grep -l`. if you think that, and only use simple conditions
in the grep block, then you are missing most of the fun.
> In a boolean
> context, I think it would be nice if perl6's grep would behave similarly.
but then it wouldn't be grep. you can already use grep in a scalar
context to count the number of matches. if you want to search in
another fashion, a different function is in order :)
--
brian d foy <comdog@panix.com> - Perl services for hire
CGI Meta FAQ - http://www.perl.org/CGI_MetaFAQ.html
Troubleshooting CGI scripts - http://www.perl.org/troubleshooting_CGI.html
------------------------------
Date: 29 Aug 2001 06:12:05 -0700
From: demerphq@hotmail.com (Yves Orton)
Subject: Re: Java mucks up split
Message-Id: <74f348f7.0108290512.141ef078@posting.google.com>
trewth_seeker@yahoo.com (Trewth Seeker) wrote in message news:<d690a633.0108281320.5bcb45f8@posting.google.com>...
> 194.203.212.8 [demerphq@hotmail.com] wrote in message news:<XjNi7.1385$3x.4984@news.bc.tac.net>...
> > > That's just dumb, and misses the whole point of the limit. This is
> > > going to lead to confusion and cause some people to think that Perl is
> > > just as broken, since Java's split is taken from Perl. What can be
> > > done to get Sun to do it right?
> >
> > Why do you want Sun to get it right?
>
> I already explained that immediately above.
So then really from a perl point of view the question is how can we
get Java to stop claiming that their regex engine is from perl.
Fixing Java either way is Suns problem.
> > Aren't you a perler?
>
> Religion makes people stupid.
True. Literalism is a good way to defuse sarcasm.
I have to say that Java _never_ excited me, and so the concept of
making it better so more corporate jerks can demand that I have to
write in it really doesnt impress me. The only Java I like gets
pissed out a couple of hours later.
Yves
Ps (To be fair I have seen some cool apps in Java)
------------------------------
Date: 29 Aug 2001 19:34:34 +0200
From: Andreas Marcel Riechert <riechert@pobox.com>
Subject: Re: Line Breaking in Japanese
Message-Id: <m3u1yqvkgl.fsf@tairou.japanologie.kultur.uni-tuebingen.de>
tim.heilmann@tfn.co.jp (Tim) writes:
> I'm trying to break a long string into lines. The string is encoded in
> Japanese EUC format. There are various scripts to break the line at a
> certain number of characters, but none that seem to follow the Kinsoku
> line breaking rules.
>
> Has anyone had similar experiences or found other ways to break lines
> in Japanese? For example, separate utility programs or commerical
> software.
ShiftJIS::LineBreak by SADAHIRO Tomoyuki allows to set different
levels of kinsoku for SJIS:
http://homepage1.nifty.com/nomenclator/perl/indexE.htm
HTH
Andreas Marcel Riechert
------------------------------
Date: 29 Aug 2001 09:02:41 -0700
From: plotkin@ejournalpress.com (Joel)
Subject: Netscape Server / iPlanet caching Perl programs
Message-Id: <40d256b3.0108290802.5e80a314@posting.google.com>
Hi,
Label me clueless- but is there a way for iPlanet / Netscape
Enterprise Server (running on Solaris) to cache Perl cgi programs?
1) to save time via persistent database connections; and
2) not have to re-compile the perl code on every web hit?
Something like mod_perl, Appache::Registry, PerlEx, or fast-cgi?
I looked at nsapi- but it doesn't compile under Linux (our test
machine) and doesn't look too well supported.
Fast.serv looked good- but it does not appear to be available...
Any ideas? The more the better.
Many thanks,
Joel
------------------------------
Date: 29 Aug 2001 06:37:44 -0700
From: paulthomson@hotmail.com (paul)
Subject: paginate search results with DBI
Message-Id: <464e478f.0108290537.2fe6cd1a@posting.google.com>
Hi,
I am using DBI to process data. I have found it easy to process rows
of data as follows:
### send action here for each number pulled from group ###
while (@row=$sthG->fetchrow_array) {
foreach $i (@row) {
do stuff
}
}
What I want to do is pull 50 results at a time and process them. Can
anyone give me any pointers?
Thanks in advance,
Paul
------------------------------
Date: Wed, 29 Aug 2001 13:52:02 GMT
From: mbower@ibuk.bankgesellschaft.de (mbower)
Subject: Re: paginate search results with DBI
Message-Id: <3b8cf1a0.1729342343@news>
I'm doing the exact same thing using Perl to read Sybase tables.
seems to me you have 2 choices ......
1. Read every row and discard the ones you don't want. The response
is suprisingly ok, even for tables with up to 10,000 rows.
2. Write a stored proc which only returns the rows you want. I'm in
the process on writing one..email me for details
>What I want to do is pull 50 results at a time and process them. Can
>anyone give me any pointers?
------------------------------
Date: Wed, 29 Aug 2001 14:50:13 GMT
From: "Kurt Stephens" <vze2r2j8@verizon.net>
Subject: Re: paginate search results with DBI
Message-Id: <Fi7j7.96$jd.106900@typhoon1.gnilink.net>
"paul" <paulthomson@hotmail.com> wrote in message
news:464e478f.0108290537.2fe6cd1a@posting.google.com...
> Hi,
>
> I am using DBI to process data. I have found it easy to process rows
> of data as follows:
>
> ### send action here for each number pulled from group ###
> while (@row=$sthG->fetchrow_array) {
>
> foreach $i (@row) {
> do stuff
> }
> }
>
> What I want to do is pull 50 results at a time and process them. Can
> anyone give me any pointers?
>
> Thanks in advance,
>
> Paul
It all depends on the database that you're using. With MySQL, you can use
the LIMIT clause in your select statement to return a page of results. This
way, you only need to keep track of the current page.
# MySQL Example
my $page = 2;
my $records_per_page = 50;
my $start = ($page - 1) * $records_per_page;
my $query = "SELECT * FROM foo ORDER BY id "
. "LIMIT $start, $records_per_page";
# MySQL returns records 51 - 100
With other databases that do not support the LIMIT clause, things get a bit
trickier. If your data can be sorted by a unique key, you can keep track of
the last value returned and use the WHERE clause on subsequent queries to
retrieve the next set of records. Database engines such as MS Jet/Access
and SQL Server support the TOP clause to limit the number of rows returned.
# MS Jet/SQL Server Example
my $last_id = 123456;
my $record_per_page = 50;
my $query = "SELECT TOP $records_per_page FROM foo "
. "WHERE id > $last_id "
. "ORDER BY ID";
If neither of these approches are possible, you may be stuck using
fetchall_arrayref and taking a slice of the returned rows.
# Not that efficient, but hey, it works
my $aref = $sth->fetchall_arrayref;
my $count = scalar(@$aref);
my $page = 2;
my $records_per_page = 50;
my $first = ($page - 1) * $records_per_page;
my $last = $first + $records_per_page - 1;
$last = $count - 1 if $last >= $count;
foreach my $rec (@{$aref}[$first .. $last]) {
# ...
}
HTH,
Kurt Stephens
------------------------------
Date: 29 Aug 2001 07:16:51 -0700
From: fozzy@sbg.org (BC)
Subject: Passing constructor arguments in Class::Struct
Message-Id: <3b45ab7e.0108290616.61f9f097@posting.google.com>
Here's the scenario:
package FooBar;
sub new
{
my($this, $param) = @_;
croak "Missing param" unless $param;
}
package MyModule;
use Class::Struct;
@MyModule::ISA = qw(MyStruct);
struct("MyStruct", { foobar => 'FooBar' });
sub new
{
# ...
my $self = new MyStruct;
# ...
}
When MyModule::new calls "new MyStruct", it will call "new FooBar" but how
do I pass the parameter to the constructor of FooBar?
I can't modify FooBar so I'd like to get it to work in a struct as oppose
to having a global instance of FooBar in my MyModule package.
BC
------------------------------
Date: 29 Aug 2001 09:20:05 -0700
From: steve_mcdonald@choicehotels.com (Steve McDonald)
Subject: Pattern matching, grabing everything right of the match
Message-Id: <acaf067b.0108290820.28c6f231@posting.google.com>
Hello all,
I have a script that posts data to a website and accepts the returning
HTLM. I'm using iterations of the following to pull out values from
the return. I have 19 values to extract. The problem I am having is
some of the values are of variable length and words. Is there a
"universal" replacement for "\w+.\w+." that will grab all characters
to the right of the pattern no matter how long or how many spaces
there are?
@strlist = split(/\n/, $html); # Splits $html into substrings by line
foreach $str(@strlist) {
if($str =~/CurrentTicketStatus=(\w+.\w+.)/ ) {
$its_status = $1;
print "ITS STatus = $its_status\n";
next;
}
}
Thanks in advance for your help!
Steve
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.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 V10 Issue 1648
***************************************