[19452] in Perl-Users-Digest
Perl-Users Digest, Issue: 1647 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Aug 29 09:05:31 2001
Date: Wed, 29 Aug 2001 06:05:09 -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: <999090309-v10-i1647@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 29 Aug 2001 Volume: 10 Number: 1647
Today's topics:
Re: 64 bit perl (Helgi Briem)
accessing hash of hashes in package (Laith Suheimat)
Re: accessing hash of hashes in package <info@fruiture.de>
Re: accessing hash of hashes in package <homer@simpsons.com>
Re: crypt function and upgrading perl/libc (Villy Kruse)
Re: dec2hex conversion ,uninitialized value (Randal L. Schwartz)
Re: dec2hex conversion ,uninitialized value <bart.lateur@skynet.be>
Re: Difference between .pl, .cgi, and .pm File Extensio (Villy Kruse)
eval problem <maspsr@dou.sdu.dk>
Re: how to get character from string one by one? <gimi@psico.ch>
Re: how to get character from string one by one? (Yves Orton)
Re: how to get character from string one by one? (Yves Orton)
Re: Parse::RecDescent (Randal L. Schwartz)
Re: Perl Question about hash element within list array <jonni@ifm.liu.nospam.se>
Questions about MakeMaker <alexis.roda@si.urv.es>
R: Parse::RecDescent <marco.baringer@convey.it>
Re: R: Parse::RecDescent (Randal L. Schwartz)
Re: random link from web page <alexis.roda@si.urv.es>
Re: regexp for removing HTML tags (Tad McClellan)
Spliting on [ ?? (Lynto)
Re: use() versus import() changing semantics? <tinamue@zedat.fu-berlin.de>
Re: use() versus import() changing semantics? (Anno Siegel)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 29 Aug 2001 12:32:58 GMT
From: helgi@NOSPAMdecode.is (Helgi Briem)
Subject: Re: 64 bit perl
Message-Id: <3b8ce026.3211335546@news.isholf.is>
On Tue, 28 Aug 2001 11:53:40 -0600, James Wai
<wai@hpeswai.fc.hp.com> wrote:
>Hi All,
>
>I need help on installing perl 5.6.1 on a HPUX 11.0 machine.
>I have no problem installing in using the default
>"Config.sh;make;make test;make install" method. However,
>I am trying to install DBD/DBI module that will talk to
>Oracle 9.0.1. It seems that I need everything to be 64 bit.
>I try adding +DA2.0W to the ccflags, but did not go very far.
>Has anyone sucessfully install a 64 bit perl on HPUX 11.0?
I'm pretty sure there is no such animal.
Why do think you "need everything to be 64 bit"?
What have you done and where do you fail?
Have you installed DBI? What happened?
Have you installed DBD::Oracle? What happened?
This is almost certainly an XY problem.
(OP asks X, should be asking Y)
Regards,
Helgi Briem
------------------------------
Date: 29 Aug 2001 03:34:04 -0700
From: l.suheimat@mdx.ac.uk (Laith Suheimat)
Subject: accessing hash of hashes in package
Message-Id: <69f8a22d.0108290234.13fd3234@posting.google.com>
hello
i have a subroutine in a package (pkg::create_hoh) that creates a hash
of hashes (%hoh). i can unwind this HOH ok from within the package:
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}";
}
print "\n\n";
}
but i can't seem to print out the whole hash from a script that calls
the package (line numbers added):
1 use pkg;
2 pkg::create_hoh();
3 foreach $outer_key (keys %pkg::hoh) {
4 print "\n$outer_key";
5 foreach $inner_key (keys %pkg::hoh{$outer_key}) {
6 print "\n$inner_key : $pkg::hoh{$outer_key}{$inner_key}";
7 }
8 }
in fact, i get a syntax error at line 5, near %pkg::hoh{
of course, i can access the entire hash by switching to the pkg
namespace, but i'd really like to access the hash using the pkg::
syntax ??
Laith Suheimat
------------------------------
Date: Wed, 29 Aug 2001 12:38:24 +0200
From: "fruiture" <info@fruiture.de>
Subject: Re: accessing hash of hashes in package
Message-Id: <9mih54$bl9$07$1@news.t-online.com>
"Laith Suheimat" <l.suheimat@mdx.ac.uk> wrote:
> [...]
> 1 use pkg;
>
> 2 pkg::create_hoh();
so far ok, but
> 3 foreach $outer_key (keys %pkg::hoh) {
keys gets a hash as argument
> 4 print "\n$outer_key";
> 5 foreach $inner_key (keys %pkg::hoh{$outer_key}) {
an here it gets kidn of slice or sth. like that ?
it should rather be
foreach $inner_key (keys %{ $pkg::hoh{$outer_key} } ) {
> 6 print "\n$inner_key : $pkg::hoh{$outer_key}{$inner_key}";
> 7 }
> 8 }
>
and then the rest will work.
> in fact, i get a syntax error at line 5, near %pkg::hoh{
yes, that's where the error is :-)
> of course, i can access the entire hash by switching to the pkg
> namespace, but i'd really like to access the hash using the pkg::
> syntax ??
you see, you problem wasn't the package, but the reference:
% perldoc perlref
HTH
--
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 11:55:44 +0100
From: "Homer J Simpson" <homer@simpsons.com>
Subject: Re: accessing hash of hashes in package
Message-Id: <9mihnl$avd$1@news.formus.pl>
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...
#return a reference to the hash you want to access
sub create_hoh{
.
.
.
return(\%hashreference);
}
#store the reference in a variable
($hashreference) = pkg::create_hoh();
#then turn the reference it into a real hash
%hash = %{hashreference};
Then work on %hash....
foreach $outer_key (keys %hash) {
print "\n$outer_key";
foreach $inner_key (keys %{$hash{$outer_key}}) {
print "\n$inner_key : $hash{$outer_key}{$inner_key}";
}
print "\n\n";
}
But then again this might be plain wrong,
Thanks
Homer
"Laith Suheimat" <l.suheimat@mdx.ac.uk> wrote in message
news:69f8a22d.0108290234.13fd3234@posting.google.com...
> hello
>
> i have a subroutine in a package (pkg::create_hoh) that creates a hash
> of hashes (%hoh). i can unwind this HOH ok from within the package:
>
> 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}";
> }
> print "\n\n";
> }
>
> but i can't seem to print out the whole hash from a script that calls
> the package (line numbers added):
>
> 1 use pkg;
>
> 2 pkg::create_hoh();
> 3 foreach $outer_key (keys %pkg::hoh) {
> 4 print "\n$outer_key";
> 5 foreach $inner_key (keys %pkg::hoh{$outer_key}) {
> 6 print "\n$inner_key : $pkg::hoh{$outer_key}{$inner_key}";
> 7 }
> 8 }
>
> in fact, i get a syntax error at line 5, near %pkg::hoh{
>
> of course, i can access the entire hash by switching to the pkg
> namespace, but i'd really like to access the hash using the pkg::
> syntax ??
>
>
> Laith Suheimat
------------------------------
Date: 29 Aug 2001 11:30:25 GMT
From: vek@pharmnl.ohout.pharmapartners.nl (Villy Kruse)
Subject: Re: crypt function and upgrading perl/libc
Message-Id: <slrn9opkig.ne2.vek@pharmnl.ohout.pharmapartners.nl>
On 29 Aug 2001 01:32:06 GMT,
Robert mangiafico <rmang@submariner.org> wrote:
>We recently upgraded our OS from RH5.x to RH6.x, from libc5 to glibc2, and
>from perl 5.004_04 to 5.6.0. Once script that uses the perl 'crypt'
>function to encrypt passwords no longer works, as it seems the passwords it
>created with 'crypt' and 'salt' in the old OS are different from the ones
>it creates/compares under the new OS.
>
If you pass the same password and the same salt to the crypt function
you get different results on those two systems, is that what you are
saying?
Villy
------------------------------
Date: 29 Aug 2001 03:53:57 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: dec2hex conversion ,uninitialized value
Message-Id: <m1pu9fyw56.fsf@halfdome.holdit.com>
>>>>> "Benjamin" == Benjamin Goldberg <goldbb2@earthlink.net> writes:
Benjamin> Stephen Lohning wrote:
Benjamin> [snip]
>> And does anyone know how to get pack unpack to do decimal to hex
>> string conversions ?
>>
>> Thanks
>>
Benjamin> sub dec2hex {
Benjamin> my ($dec, $width) = @_;
Benjamin> unpack( "H" x $width, pack( "N", $dec ) );
Benjamin> }
*ahem*
That's "int2hex". Don't make me come over there and slap you!
:-)
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Wed, 29 Aug 2001 11:09:28 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: dec2hex conversion ,uninitialized value
Message-Id: <g6jpotoqva1tb2gtg6teqjnrgh30aj2r6i@4ax.com>
Randal L. Schwartz wrote:
>Benjamin> sub dec2hex {
>Benjamin> my ($dec, $width) = @_;
>Benjamin> unpack( "H" x $width, pack( "N", $dec ) );
>Benjamin> }
>
>*ahem*
>
>That's "int2hex". Don't make me come over there and slap you!
>
>:-)
sub int2dec {
return "$_[0]";
}
--
Bart.
------------------------------
Date: 29 Aug 2001 11:36:18 GMT
From: vek@pharmnl.ohout.pharmapartners.nl (Villy Kruse)
Subject: Re: Difference between .pl, .cgi, and .pm File Extensions.
Message-Id: <slrn9opkti.ne2.vek@pharmnl.ohout.pharmapartners.nl>
On Wed, 29 Aug 2001 10:57:54 +0200,
Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de> wrote:
>
>.cgi however is a generic suffix that wont give away information on the
>language in which it was written. It could be Perl, but it could also be
>Python or even C. Possibly assembly, if you like. So if you write
>cgi-scripts in Perl you are free to either use .pl or .cgi as extension
>but do tell your webserver about it.
>
However, do check the web server for how to tell it that the file is a cgi
program and not some file that is sent back as is to the browser. This
is usualy a configuration issue. It also depends on the web server if
it uses the file name suffix to determine the type of executable file
or if it gets that information from the '#!" line in the file.
Villy
------------------------------
Date: Wed, 29 Aug 2001 15:52:40 +0200
From: "Peter Sørensen" <maspsr@dou.sdu.dk>
Subject: eval problem
Message-Id: <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 12:15:59 +0200
From: gimi <gimi@psico.ch>
Subject: Re: how to get character from string one by one?
Message-Id: <3B8CC0DF.3F2A1EF@psico.ch>
hi
Abigail wrote:
> Craig Berry (cberry@cinenet.net) wrote on MMCMXIX September MCMXCIII in
> <URL:news:Xns910B65D8AFCC1cberrycinenetnet1@207.126.101.92>:
> ^^ demerphq@hotmail.com (Yves Orton) wrote in
> ^^ news:74f348f7.0108280139.332a852a@posting.google.com:
> ^^ > I will be posting an overview of a bunch of benchmarks that I have
> ^^ > done in this area to the thread 'one character at a time'. There are
> ^^ > a variety of methods (5 basic ideas) to achieve it ranging from fast
> ^^ > to slow. Split doesnt perform that well actually.
> ^^
> ^^ Let's see...substr, split, unpack, m/(.)/sg, and...what?
>
> chop.
at first, this puzzled me.. then, i thought about
good old recursions -- but was that what you guys
had in mind when you said 'chop'..?
- i spent some time trying, so i won't stop now :D
__CODE__
#!perl
use warnings;
use strict;
sub charwise {
my $str = shift;
my $cut = chop $str;
my @chars;
$str and @chars = charwise($str);
push @chars, $cut;
return @chars
}
print join ' ', charwise( "many characters here" );
exit 0
__END__
i guess this isn't "fast", after all..
but i am curious; what are the "other ways to do it"
using chop?
[oh, just before posting, with my fingers already on
'ctrl' and 'enter', i thought again, and quickly
wrote this second sub:
__CODE, too__
sub cw2 {
my $str = shift;
my @chars;
while ($str) { unshift @chars, chop $str }
return @chars
}
__now that really is the END__
- a bit faster, i think.
sometimes it's a good thing to 'think again' :) ]
gimi
ps. something to think about - i have found this in
povray.off-topic, and it even relates to "speed":
(i adore Bill DeWitt's sense of humor, and added it
to my personal 'quotes.pl' file)
[i know it's too long; sorry - but it's *fast* :) ]
--
"I have long contended (without empirical support) that time itself must
have changed rate over time. As the Universe expands, time, space and
energy -must- change form. For instance, in the first seconds of it's
expansion, the universe was scant light-seconds across, now it is
mega-light-years across. But from the inside, it always took light
forever to cross it. The length of forever must have been much shorter
in the past." -- Bill DeWitt
------------------------------
Date: 29 Aug 2001 05:06:04 -0700
From: demerphq@hotmail.com (Yves Orton)
Subject: Re: how to get character from string one by one?
Message-Id: <74f348f7.0108290406.c6d64fd@posting.google.com>
The tests that I ran...
chop and vec have been omitted so far.
#!perl
use strict;
use warnings;
use Benchmark qw(cmpthese timethese);
use Data::Dumper;
my $types={
Scalar_only=>{
'substr4' => 'substr ($s, 0, 1, "") while length($s)',
'substr3' => 'substr( $s, $_, 1 ) foreach (0..length($s)-1)',
},
Regexp=>{
'rex_dot' => '$s =~ /(.)/gs',
'rex_class' => '$s =~ /([\x00-\xFF])/gs',
},
List_only=>{
'unpack' => 'unpack("C*", $s)',
'split' => 'split(//,$s)',
},
};
sub build_test {
my $TestString=shift || "TEST";
my $Print=shift;
my $h='{my ($s,$r,@l)=("TEST","");'."\n";
$h=~s/(TEST)/$TestString/e;
my $f="}\n";
$f=";\n".'print "s=$s | r=$r | l=@l\n"'.$f if ($Print);
my $hash={};
foreach my $key (keys %{$types->{Scalar_only}}) {
$hash->{'@= '.$key}=$h.'push
@l,'.$types->{Scalar_only}->{$key}.$f;
$hash->{'= '.$key}=$h.'$r='.$types->{Scalar_only}->{$key}.$f;
}
foreach my $key (keys %{$types->{Regexp}}) {
$hash->{'@= '.$key}=$h.'@l='.$types->{Regexp}->{$key}.$f;
$hash->{'= $_ '.$key}=$h.'$r= $_ foreach
('.$types->{Regexp}->{$key}.')'.$f;
$hash->{'= $1 '.$key}=$h.'$r= $1 while
'.$types->{Regexp}->{$key}.$f;
}
foreach my $key (keys %{$types->{List_only}}) {
$hash->{'@= '.$key}=$h.'@l='.$types->{List_only}->{$key}.$f;
$hash->{'= '.$key}=$h.'$r= $_ foreach
'.$types->{List_only}->{$key}.$f;
} return $hash;
}
use Data::Dumper;
my $print =build_test("ABCDEF",1);
foreach my $name (sort keys %$print) {
print $name."\t";
eval $print->{$name};
die $@ if $@;
}
{
local $,="\n";
local $\="\n";
print '$hash={\n';
while (my ($k,$v)=each(%$print)) {
print "'$k'\t=>","'$v',";
} print '};';
}
foreach my $mul (1..10,20,30,40,50) {
my $test=build_test("01234567890" x $mul);
my %list;
my %process;
map { (substr($_,0,1) eq "@")
? $list{$_}=$test->{$_}
: $process{$_}=$test->{$_}
} keys %$test;
print "-----------------------------------------------------
Testing against ".($mul*10)." char string....\n\n";
my $t=timethese (-60,\%list,"none");
my $p=timethese (-60,\%process,"none");
cmpthese($t);
print "\n";
cmpthese($p);
}
__END__
********************
* EDITED RESULTS *
********************
= $1 rex_class s=ABCDEF | r=F | l=
= $1 rex_dot s=ABCDEF | r=F | l=
= $_ rex_class s=ABCDEF | r=F | l=
= $_ rex_dot s=ABCDEF | r=F | l=
= split s=ABCDEF | r=F | l=
= substr3 s=ABCDEF | r=F | l=
= substr4 s= | r=F | l=
= unpack s=ABCDEF | r=70 | l=
@= rex_class s=ABCDEF | r= | l=A B C D E F
@= rex_dot s=ABCDEF | r= | l=A B C D E F
@= split s=ABCDEF | r= | l=A B C D E F
@= substr3 s=ABCDEF | r= | l=A B C D E F
@= substr4 s= | r= | l=A B C D E F
@= unpack s=ABCDEF | r= | l=65 66 67 68 69 70
$hash={\n
'= unpack' =>
'{my ($s,$r,@l)=("ABCDEF","");
$r= $_ foreach unpack("C*", $s);
print "s=$s | r=$r | l=@l\n"}
',
'@= unpack' =>
'{my ($s,$r,@l)=("ABCDEF","");
@l=unpack("C*", $s);
print "s=$s | r=$r | l=@l\n"}
',
'= split' =>
'{my ($s,$r,@l)=("ABCDEF","");
$r= $_ foreach split(//,$s);
print "s=$s | r=$r | l=@l\n"}
',
'= $_ rex_dot' =>
'{my ($s,$r,@l)=("ABCDEF","");
$r= $_ foreach ($s =~ /(.)/gs);
print "s=$s | r=$r | l=@l\n"}
',
'= $_ rex_class' =>
'{my ($s,$r,@l)=("ABCDEF","");
$r= $_ foreach ($s =~ /([\x00-\xFF])/gs);
print "s=$s | r=$r | l=@l\n"}
',
'= $1 rex_dot' =>
'{my ($s,$r,@l)=("ABCDEF","");
$r= $1 while $s =~ /(.)/gs;
print "s=$s | r=$r | l=@l\n"}
',
'@= rex_class' =>
'{my ($s,$r,@l)=("ABCDEF","");
@l=$s =~ /([\x00-\xFF])/gs;
print "s=$s | r=$r | l=@l\n"}
',
'@= split' =>
'{my ($s,$r,@l)=("ABCDEF","");
@l=split(//,$s);
print "s=$s | r=$r | l=@l\n"}
',
'= substr3' =>
'{my ($s,$r,@l)=("ABCDEF","");
$r=substr( $s, $_, 1 ) foreach (0..length($s)-1);
print "s=$s | r=$r | l=@l\n"}
',
'= substr4' =>
'{my ($s,$r,@l)=("ABCDEF","");
$r=substr ($s, 0, 1, "") while length($s);
print "s=$s | r=$r | l=@l\n"}
',
'@= substr3' =>
'{my ($s,$r,@l)=("ABCDEF","");
push @l,substr( $s, $_, 1 ) foreach (0..length($s)-1);
print "s=$s | r=$r | l=@l\n"}
',
'= $1 rex_class' =>
'{my ($s,$r,@l)=("ABCDEF","");
$r= $1 while $s =~ /([\x00-\xFF])/gs;
print "s=$s | r=$r | l=@l\n"}
',
'@= substr4' =>
'{my ($s,$r,@l)=("ABCDEF","");
push @l,substr ($s, 0, 1, "") while length($s);
print "s=$s | r=$r | l=@l\n"}
',
'@= rex_dot' =>
'{my ($s,$r,@l)=("ABCDEF","");
@l=$s =~ /(.)/gs;
print "s=$s | r=$r | l=@l\n"}
',
};
REMOVE PRINT STATEMENTS FOR THE BELOW TESTS
-----------------------------------------------------
Testing against 10 char string....
@= substr3 33489/s
@= rex_class 34165/s
@= rex_dot 35212/s
@= substr4 36117/s
@= split 41859/s
@= unpack 84778/s
= $1 rex_class 28994/s
= $1 rex_dot 29886/s
= $_ rex_class 32732/s
= $_ rex_dot 33915/s
= split 34041/s
= substr3 51807/s
= unpack 57781/s
= substr4 57959/s
-----------------------------------------------------
Testing against 20 char string....
@= rex_class 18616/s
@= rex_dot 19178/s
@= substr3 19327/s
@= substr4 19739/s
@= split 22983/s
@= unpack 49074/s
= $1 rex_class 15850/s
= $1 rex_dot 16360/s
= $_ rex_class 18827/s
= split 19421/s
= $_ rex_dot 19668/s
= substr3 31502/s
= substr4 31870/s
= unpack 35170/s
-----------------------------------------------------
Testing against 30 char string....
@= rex_class 12732/s
@= substr4 13177/s
@= rex_dot 13307/s
@= substr3 13465/s
@= split 15849/s
@= unpack 34655/s
= $1 rex_class 10983/s
= $1 rex_dot 11345/s
= $_ rex_class 13335/s
= split 13683/s
= $_ rex_dot 13741/s
= substr4 22059/s
= substr3 22778/s
= unpack 25335/s
-----------------------------------------------------
Testing against 40 char string....
@= rex_class 9634/s
@= rex_dot 10126/s
@= substr4 10279/s
@= substr3 10373/s
@= split 12212/s
@= unpack 26740/s
= $1 rex_class 8192/s
= $1 rex_dot 8730/s
= $_ rex_class 10214/s
= split 10362/s
= $_ rex_dot 10687/s
= substr4 17088/s
= substr3 17783/s
= unpack 19785/s
-----------------------------------------------------
Testing against 50 char string....
@= rex_class 7856/s
@= rex_dot 8175/s
@= substr4 8295/s
@= substr3 8435/s
@= split 9817/s
@= unpack 21827/s
= $1 rex_class 6849/s
= $1 rex_dot 7158/s
= $_ rex_class 8317/s
= split 8544/s
= $_ rex_dot 8714/s
= substr4 13716/s
= substr3 14564/s
= unpack 16227/s
-----------------------------------------------------
Testing against 60 char string....
@= rex_class 6576/s
@= rex_dot 6869/s
@= substr4 6952/s
@= substr3 7136/s
@= split 8125/s
@= unpack 18344/s
= $1 rex_class 5729/s
= $1 rex_dot 5876/s
= $_ rex_class 7022/s
= split 7208/s
= $_ rex_dot 7337/s
= substr4 11399/s
= substr3 12353/s
= unpack 13727/s
-----------------------------------------------------
Testing against 70 char string....
@= rex_class 5658/s
@= rex_dot 5875/s
@= substr4 5977/s
@= substr3 6113/s
@= split 7120/s
@= unpack 15943/s
= $1 rex_class 5002/s
= $1 rex_dot 5189/s
= $_ rex_class 6053/s
= split 6244/s
= $_ rex_dot 6347/s
= substr4 9951/s
= substr3 10726/s
= unpack 11922/s
-----------------------------------------------------
Testing against 80 char string....
@= rex_class 4982/s
@= rex_dot 5183/s
@= substr4 5254/s
@= substr3 5374/s
@= split 6229/s
@= unpack 14023/s
= $1 rex_class 4352/s
= $1 rex_dot 4519/s
= $_ rex_class 5322/s
= split 5482/s
= $_ rex_dot 5598/s
= substr4 8757/s
= substr3 9461/s
= unpack 10535/s
----------------------------------------------------
Testing against 90 char string....
@= rex_class 4427/s
@= substr4 4531/s
@= rex_dot 4604/s
@= substr3 4815/s
@= split 5564/s
@= unpack 12532/s
= $1 rex_class 3874/s
= $1 rex_dot 4029/s
= $_ rex_class 4771/s
= split 4900/s
= $_ rex_dot 4987/s
= substr4 7771/s
= substr3 8478/s
= unpack 9424/s
-----------------------------------------------------
Testing against 100 char string....
@= rex_class 3992/s
@= rex_dot 4164/s
@= substr4 4221/s
@= substr3 4392/s
@= split 5019/s
@= unpack 11327/s
= $1 rex_class 3491/s
= $1 rex_dot 3664/s
= $_ rex_class 4311/s
= split 4408/s
= $_ rex_dot 4499/s
= substr4 7006/s
= substr3 7676/s
= unpack 8492/s
-----------------------------------------------------
Testing against 200 char string....
@= rex_class 2015/s
@= rex_dot 2100/s
@= substr4 2128/s
@= substr3 2203/s
@= split 2535/s
@= unpack 5760/s
= $1 rex_class 1729/s
= $1 rex_dot 1829/s
= $_ rex_class 2190/s
= split 2246/s
= $_ rex_dot 2291/s
= substr4 3569/s
= substr3 3941/s
= unpack 4365/s
-----------------------------------------------------
Testing against 300 char string....
@= rex_class 1345/s
@= rex_dot 1402/s
@= substr4 1408/s
@= substr3 1496/s
@= split 1658/s
@= unpack 3853/s
= $1 rex_class 1179/s
= $1 rex_dot 1237/s
= $_ rex_class 1463/s
= split 1500/s
= $_ rex_dot 1505/s
= substr4 2396/s
= substr3 2653/s
= unpack 2935/s
-----------------------------------------------------
Testing against 400 char string....
@= rex_class 1004/s
@= rex_dot 1036/s
@= substr4 1064/s
@= substr3 1111/s
@= split 1270/s
@= unpack 2890/s
= $1 rex_class 900/s
= $1 rex_dot 918/s
= $_ rex_class 1101/s
= split 1127/s
= $_ rex_dot 1154/s
= substr4 1724/s
= substr3 1999/s
= unpack 2212/s
----------------------------------------------------
Testing against 500 char string....
@= rex_class 799/s
@= rex_dot 833/s
@= substr4 847/s
@= substr3 877/s
@= split 1015/s
@= unpack 2236/s
= $1 rex_class 697/s
= $1 rex_dot 741/s
= $_ rex_class 864/s
= split 898/s
= $_ rex_dot 917/s
= substr4 1405/s
= substr3 1603/s
= unpack 1771/s
------------------------------
Date: 29 Aug 2001 05:58:08 -0700
From: demerphq@hotmail.com (Yves Orton)
Subject: Re: how to get character from string one by one?
Message-Id: <74f348f7.0108290458.300f4772@posting.google.com>
logan@cs.utexas.edu (Logan Shaw) wrote in message news:<9mh0pk$fdu$1@charity.cs.utexas.edu>...
> In article <Xns910B65D8AFCC1cberrycinenetnet1@207.126.101.92>,
> Craig Berry <cberry@cinenet.net> wrote:
> >demerphq@hotmail.com (Yves Orton) wrote in
> >news:74f348f7.0108280139.332a852a@posting.google.com:
> >> I will be posting an overview of a bunch of benchmarks that I have
> >> done in this area to the thread 'one character at a time'. There are
> >> a variety of methods (5 basic ideas) to achieve it ranging from fast
> >> to slow. Split doesnt perform that well actually.
> >
> >Let's see...substr, split, unpack, m/(.)/sg, and...what?
>
> Also:
>
> $s = "abc123";
>
> while ($s =~ s/(.)//s)
> {
> push (@s, $1);
> }
>
> Can't imagine that'd be terribly fast. Maybe this has a decent shot at
> being fast:
>
> $s =~ s/(.)/"\Q$1\E", /sg;
> @s = eval "($s)";
>
> OK, now I have to admit it's convenient to be able to throw in extra
> commas at the end of lists.
the fastest overall was
@ords=unpack("C*",$string);
My question though is if this was strictly fair. My doubt comes from
he fact that unpack returns a list of ordinal values, NOT 1 digit
strings. Is it fair to compare such a method without doing the
conversion to chr()?
And how would perl deal with that? (The chr() conversion) And
further, shouldnt there be a template char so that unpack KNOWS to
treat the byte as a char and put it into a string? Surely that would
be the fastest? Something like the 'A' template char, but returning a
list of chars instead of string of bytes as ascii? I mean maybe i
shouldnt ask, there is NO way i am going to look at the perl source
code to do this, it just seems like a strange ommision.
As a further point I would love to know why split so radically
outperforms everything else (but unpack) for longer strings, but
substr4 outperforms everything else for short strings. (On that
thought what is the perfomance difference between chop and substr4 i
wonder... Hmm... back to the bench...)
Anyway, these are my mental mutterings....
yves
------------------------------
Date: 29 Aug 2001 04:04:53 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Parse::RecDescent
Message-Id: <m1itf7yvmy.fsf@halfdome.holdit.com>
>>>>> "Marco" == Marco Baringer <marco.baringer@convey.it> writes:
Marco> i'm trying ot use Parse::RecDescent to parse a configuration file which
Marco> looks like this:
Marco> [SECTION]
Marco> parameter 1=value 1
Marco> parameter2=value 2
Marco> [NEXTSECTION]
Marco> ohter parameter=other value
Marco> (standard windows .ini format)
Have you seen the modules IniConf, AnyData::Format::Ini, Config::Ini,
and Config::IniFiles in the CPAN? Do you really need to reinvent it a
fifth time?
Marco> i'm having some problems since the use of white space is very
Marco> important and i can't get RecDescent to not consume white space
Marco> before attempting a token match.for example i want to require
Marco> that after a [SECTION] there be [ \t]+\n/ followed by some
Marco> key/value pairs, however RecDescent after matching [SECTION]
Marco> consume all the white space between [SECTION] and 'value 1' and
Marco> so the /[ \t]+\n/ never matches. I've tried setting
Marco> RecDescent::skip to various things ('' is what i would like it
Marco> to be), but it seems to have no effect.
Are you doing it inline? that's how Damian does it. :-)
top_rule: <skip: ''> ....
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Wed, 29 Aug 2001 14:19:44 +0200
From: "Jonas Nilsson" <jonni@ifm.liu.nospam.se>
Subject: Re: Perl Question about hash element within list array
Message-Id: <9mimca$s12$1@newsy.ifm.liu.se>
"Chris" <clee008@yahoo.com> wrote in message
news:6b5e9aa2.0108282157.413cab0d@posting.google.com...
| I got a difficult question of writing some code to loop through all
| the data printing it out
|
| @myData = ( ( name => 'Chris',
| address => 'London',
| phone => '207 721 2000' },
| { name => 'John',
| address => 'Hong Kong' },
| phone => '3306 2457' },
| etc ...
| );
Try a module:
use Data::Dumper;
print Dumper(\@myData);
--
/jN
------------------------------
Date: Mon, 27 Aug 2001 11:02:28 +0200
From: Alexis Roda <alexis.roda@si.urv.es>
Subject: Questions about MakeMaker
Message-Id: <3B8A0CA4.3D49051D@si.urv.es>
Hi,
I'm learning MakeMaker, so excuse me if those are estupid questions. I'm
using perl 5.005 under linux (debian potato).
My script needs some datafiles installed under /usr/share. I think that
the simplest way is to add a new dependency to the install target (btw.
install_usr_share) and add a rule install_usr_share in the postamble of
MakeMaker:
install: usual_dependencies install_usr_share
....
install_user_share:
install src dest
The problem is that I don't know how to do this. If I pass a 'depend' =>
{ 'install' => 'install_usr_share' } parameter to WriteMakefile the
install dependencies are overwriten by 'install_usr_share'.
What is the 'right way' to do what I need?
TIA
--
////
(@ @)
---------------------------oOO----(_)----OOo------------------------
Los pecados de los tres mundos desapareceran conmigo.
Alexis Roda - Universitat Rovira i Virgili - Reus, Tarragona (Spain)
--------------------------------------------------------------------
------------------------------
Date: Wed, 29 Aug 2001 13:59:32 +0200
From: "Marco Baringer" <marco.baringer@convey.it>
Subject: R: Parse::RecDescent
Message-Id: <9milmq$295s$1@stargate1.inet.it>
Randal L. Schwartz <merlyn@stonehenge.com> wrote in message
m1itf7yvmy.fsf@halfdome.holdit.com...
> >>>>> "Marco" == Marco Baringer <marco.baringer@convey.it> writes:
>
> Marco> i'm trying ot use Parse::RecDescent to parse a configuration file
which
> Marco> looks like this:
>
> Marco> [SECTION]
> Marco> parameter 1=value 1
> Marco> parameter2=value 2
>
> Marco> [NEXTSECTION]
> Marco> ohter parameter=other value
>
> Marco> (standard windows .ini format)
>
> Have you seen the modules IniConf, AnyData::Format::Ini, Config::Ini,
> and Config::IniFiles in the CPAN? Do you really need to reinvent it a
> fifth time?
i've seen Config::IniFiles, i''l check out the others. however, i have no
other experience using RecDescent and i'd like to learn, so no i'm not going
to use another module. i want to do this with RecDescent even if that's not
the quickest/easiest/best way.
> Marco> i'm having some problems since the use of white space is very
> Marco> important and i can't get RecDescent to not consume white space
> Marco> before attempting a token match.for example i want to require
> Marco> that after a [SECTION] there be [ \t]+\n/ followed by some
> Marco> key/value pairs, however RecDescent after matching [SECTION]
> Marco> consume all the white space between [SECTION] and 'value 1' and
> Marco> so the /[ \t]+\n/ never matches. I've tried setting
> Marco> RecDescent::skip to various things ('' is what i would like it
> Marco> to be), but it seems to have no effect.
>
> Are you doing it inline? that's how Damian does it. :-)
>
> top_rule: <skip: ''> ....
i tried it with that, but i'm still getting the same error. It says that it
was expecting / *\n/ but it found 'parameter 1=value1', i know there's a '
\n' after [SECTION], i even tried making the skip ' ' so that the first
space would get consumed and then ' \n' would be left, which would match the
regex however that didn't change anything. i'm assuming that i've not
figured out how to set skip, isn't it just
$Parse::RecDescent::skip = ''; ?
> --
> Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777
0095
> <merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
> Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
> See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl
training!
------------------------------
Date: 29 Aug 2001 05:15:09 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: R: Parse::RecDescent
Message-Id: <m1zo8jxdte.fsf@halfdome.holdit.com>
>>>>> "Marco" == Marco Baringer <marco.baringer@convey.it> writes:
Marco> i tried it with that, but i'm still getting the same error. It says that it
Marco> was expecting / *\n/ but it found 'parameter 1=value1', i know there's a '
Marco> \n' after [SECTION], i even tried making the skip ' ' so that the first
Marco> space would get consumed and then ' \n' would be left, which would match the
Marco> regex however that didn't change anything. i'm assuming that i've not
Marco> figured out how to set skip, isn't it just
Marco> $Parse::RecDescent::skip = ''; ?
Post your rules so far. We're not psychic, and the descriptions aren't
helping me enough to figure out what's going on.
Also, there's a specific Parse::RecDescent mailing list at perl.org - you
might want to post there instead.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Mon, 27 Aug 2001 15:09:16 +0200
From: Alexis Roda <alexis.roda@si.urv.es>
Subject: Re: random link from web page
Message-Id: <3B8A467C.859400B1@si.urv.es>
confused wrote:
>
> ok, i am using the code at the bottom of this message to get links
> from a web page. How do i get it to return only 1 random link from the
> page so every time you goto the cgi page, it will show a different
> link ?
>
> #!/usr/bin/perl -w
>
> use strict;
> use HTML::LinkExtor;
> use LWP::Simple;
>
> my %seen;
> my $url =
> "http://www.yahoo.com";
> my $parser = HTML::LinkExtor->new(undef, $url);
> $parser->parse(get($url))->eof;
> my @links = $parser->links;
> foreach my $linkarray (@links) {
> my @element = @$linkarray;
> my $elt_type = shift @element;
> while (@element) {
> my ($attr_name, $attr_value) = splice(@element, 0, 2);
> $seen{$attr_value}++;
> }
> }
If I understand correctly you need something like:
my @links = sort keys %seen;
my $random_link = int(rand($#links + 1));
> print "Content-type: text/html\n\n";
print "$links[$random_link]\n";
HTH
--
////
(@ @)
---------------------------oOO----(_)----OOo------------------------
Los pecados de los tres mundos desapareceran conmigo.
Alexis Roda - Universitat Rovira i Virgili - Reus, Tarragona (Spain)
--------------------------------------------------------------------
------------------------------
Date: Wed, 29 Aug 2001 08:06:32 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: regexp for removing HTML tags
Message-Id: <slrn9opmm7.1ua.tadmc@tadmc26.august.net>
Mik Mifflin <dogansmoobs.NOSPAM@ctel.net> wrote:
>> "Mik Mifflin" <dogansmoobs.NOSPAM@ctel.net> wrote in message
>> news:toot0p1rls9ka0@corp.supernews.com...
>>> I've been trying to come up with a regexp to remove all HTML tags.
>> As mentioned a gazillion times in this NG: if you want to parse HTML use
>> an HTML parser, e.g. HTML::Parse.
>> Please see the FAQ about why it's a bad idea to try using REs for parsing
>> HTML.
>I know that,
I assume that that "that" refers to the "use a module" part?
What about the "see the FAQ" part? Did you have a look at that?
>but I don't want to use a module.
It is standard practice to reuse software rather than rewrite
already-written software.
If standard practice won't work for you, then you need to offer
a reason why it won't work if you'd like help working around
your requirement.
Why do you not want to use a module?
>I just want to strip away
>the tags.
The FAQ answer shows several snippets of perfectly legal HTML
where an attempt at a regex solution will fail.
Is it OK if your code fails sometimes, or must it always
work correctly?
If you only need to deal with a restricted subset of HTML, then
we need to know what legal HTML constructs you are disallowing
in your data if we are to be able to make helpful suggestions.
>I've tried things like s/<.*>//g,
Then you haven't seen the FAQ answer yet, as it shows the solution
to the problem(s) with the above.
Please have a look at the FAQ answer!
>but they dont' work.
It works perfectly. Does exactly what it is supposed to do,
removes everything (on the same line) in between < and >.
>I need a
>regular expression to drop everything in between < and >.
Like that guy with the large mouth says "you can't always get what you want".
What you want is impossible, so you must either give up, or modify
what you want.
It is not possible to correctly remove tags from arbitrary HTML
with a regular expression.
You have asked for the impossible, you may have to wait a good
long time to get an answer :-)
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 29 Aug 2001 05:53:04 -0700
From: tlynch@riverdelta.com (Lynto)
Subject: Spliting on [ ??
Message-Id: <e3ffb70d.0108290453.271d7bad@posting.google.com>
Greetings:
I have the line:
input [31:0] foo;
I'm using:
@x = $_;
@x = split(/[\s\[\]:;]+/);
I'm getting:
/[/: unmatched [] in regexp at /asic_tools/perl/vports line 61
Why? I'm escaping the [ character? What am I doing wrong?
I'm running on a Solaris box and my perl version is:
% perl -v
This is perl, v5.6.0 built for sun4-solaris
Copyright 1987-2000, Larry Wall
If this matters
Thanks for any help in advanced!
Lynto
------------------------------
Date: 29 Aug 2001 10:38:39 GMT
From: Tina Mueller <tinamue@zedat.fu-berlin.de>
Subject: Re: use() versus import() changing semantics?
Message-Id: <9mignf$2d9h6$4@fu-berlin.de>
Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
> According to Tina Mueller <news@tinita.de>:
>> Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
>> > Disabling isn't exactly what's happening here, prototyping doesn't
>> > get a chance. The prototype of a function *must* be known at compile
>> > time for it to take effect.
>>
>> ah, i see, that was what i was looking for. where could i read
>> that in the docs?
> Prototypes are in perlsub.
well, i had read that, but i must have missed the very first line of the
Prototype section. thank you.
--
http://www.tinita.de \ enter__| |__the___ _ _ ___
tina's moviedatabase \ / _` / _ \/ _ \ '_(_-< of
search & add comments \ \ _,_\ __/\ __/_| /__/ perception
--- Warning: content of homepage hopelessly out-dated ---
------------------------------
Date: 29 Aug 2001 10:47:28 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: use() versus import() changing semantics?
Message-Id: <9mih80$7uv$5@mamenchi.zrz.TU-Berlin.DE>
According to Tina Mueller <news@tinita.de>:
> Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
> > According to Tina Mueller <news@tinita.de>:
> >> Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
> >> > Disabling isn't exactly what's happening here, prototyping doesn't
> >> > get a chance. The prototype of a function *must* be known at compile
> >> > time for it to take effect.
> >>
> >> ah, i see, that was what i was looking for. where could i read
> >> that in the docs?
>
> > Prototypes are in perlsub.
>
> well, i had read that, but i must have missed the very first line of the
> Prototype section. thank you.
Yeah. To make sure people overlook something, either
- print it in all-caps
- draw a box around it
- put it in the first line
Anno
------------------------------
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 1647
***************************************