[12434] in Perl-Users-Digest
Perl-Users Digest, Issue: 6034 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jun 17 15:07:17 1999
Date: Thu, 17 Jun 99 12:01:38 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 17 Jun 1999 Volume: 8 Number: 6034
Today's topics:
Re: Multi line match help <srishti@giasbg01.vsnl.net.in>
Re: my and interpolation? <tchrist@mox.perl.com>
Neet Perl Obfucation Program (Harry P Bloomberg)
Re: Newbie Array Question <gte482i@prism.gatech.edu>
Re: Newbie Array Question <rootbeer@redcat.com>
Re: odd autoincrement behavior ? <Allan@due.net>
Online database <neil@pacifier.com>
Re: pattern matching question <emschwar@rmi.net>
Re: pattern matching question <jcreed@cyclone.jprc.com>
Re: Perl training on east coast (Randal L. Schwartz)
Re: Personal Rant (was Re: Does Perl have a future?) <dgris@moiraine.dimensional.com>
Re: program execution meter???? <rootbeer@redcat.com>
Re: qr// doesn't save my day! (Fuzzy Warm Moogles)
Re: qr// doesn't save my day! <rootbeer@redcat.com>
Re: qr// doesn't save my day! <garethr@cre.canon.co.uk>
Re: RC5 <rootbeer@redcat.com>
Re: RC5 <garethr@cre.canon.co.uk>
Re: Regex Help Needed <srishti@giasbg01.vsnl.net.in>
Re: regexp trouble.. <rootbeer@redcat.com>
Re: Regular expresions as parameters <aperrin@mcmahon.qal.berkeley.edu>
Re: reloadable script <rootbeer@redcat.com>
Re: Request for improvements to my search script (brian d foy)
Sorting a text file. <jim.ray@west.boeing.com>
Re: Sorting a text file. <vmurphy@gamora.ndhm.gtegsc.com>
Ugly delimiters (was Re: pattern matching question) (Gary E. Ansok)
Re: URGENT--pppd and chat <rootbeer@redcat.com>
Re: Using Exporter <garethr@cre.canon.co.uk>
Re: Using Exporter <ksm+usenet@sas.upenn.edu>
Re: Using Exporter <jdporter@min.net>
Who's accessing the file?? <aschrock@pubnix.org>
Re: win32 perl problems <tja@fast.de>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 18 Jun 1999 00:22:08 +0530
From: Srishti <srishti@giasbg01.vsnl.net.in>
To: "Narasimha G. Pai" <pai@cadence.com>
Subject: Re: Multi line match help
Message-Id: <376943D8.8847BBC9@giasbg01.vsnl.net.in>
This is a multi-part message in MIME format.
--------------7196A1492E630AC267F0CF66
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Hi Kanwarpreet,
There are variety of ways to go about it:
1. First write one Perl script to move one record in one line, i.e. keep
concatinationg till you get next date. Now do a line by line read and
locate your pattern.
2. I assume there are no ':' other than in the beginning. try matching
/([0-9][0-9]:[0-9][0-9]:[0-9][0-9]) :[^:]*PLANNED/. The [^:] will take
care that the nearest date is matched. You may have to use /s at the end
of the pattern so that a . matches a new line as well.
If problems revert back,
Deepak.
Narasimha G. Pai wrote:
>
> Hi friends ,
>
> I have a problem in perl pattern matching and only someone here
> can help .
>
> I have a file in the following format :
>
> 12:12:96 : Updated test1 . Writing test2.
> 01:10:97 : test2 done . Started test3.
> test4 PLANNED .
>
> Now I have to get the date for which test4 was planned .
> I suppose this requires a multiline match .
>
> so what I am doing is setting $/ to nothing . I read the entire file
> in $_ and then try to do a match .
>
> I tried :
>
> if(/([0-9][0-9]).*PLANNED) /) and guess what it gave me :
>
> 12:12 in $1 .
>
> Now what i need is 01:10.
>
> Any ideas on how I can reduce my search to the last possible
> match and not the first possible .
>
> to summarise : what I need to do is to find a date after which
> there some text and then the word PLANNED . There can be
> multiple lines between the date and the word PLANNED . but
> there would be no date between them .
>
> help !
>
> --
> |======================================================================|
> |Kanwarpreet Singh Grewal | email: kanwar@cadence.com |
> | Cadence Design Systems (India) Pvt. Ltd.,| Home address: E-217 |
> | SDF # B-8, Noida Export Processing Zone, | Ram Vihar |
> | Noida, UP - 201305, India | Sector : 30 |
> | Tel: +91-11-8562842 | Noida, UP India |
> |======================================================================|
--------------7196A1492E630AC267F0CF66
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Srishti
Content-Disposition: attachment; filename="vcard.vcf"
begin: vcard
fn: Srishti
n: ;Srishti
org: Srishti Software Pvt. Ltd
adr: #66, 4th Cross, 17th 'A' Main;;5th Block, Koramangala;Bangalore;Karnataka;560 095;India
email;internet: srishti@giasbg01.vsnl.net.in
tel;work: 91-80-5522011/5084529
tel;fax: 91-80-5532016
tel;home: 91-80-5084528
x-mozilla-cpt: ;0
x-mozilla-html: FALSE
version: 2.1
end: vcard
--------------7196A1492E630AC267F0CF66--
------------------------------
Date: 17 Jun 1999 11:12:55 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: my and interpolation?
Message-Id: <37692c97@cs.colorado.edu>
[courtesy cc of this posting mailed to cited author]
In comp.lang.perl.misc,
Nenad Vidovic <nenad@halcyon.ca> writes:
:$file_size_gz = "3";
:$file_size = ${"file_size_$compression"};
You forgot to make a data structure! $file_size{$compression}
would perhaps be the more normal thing.
How can I use a variable as a variable name?
Beginners often think they want to have a variable contain the
name of a variable.
$fred = 23;
$varname = "fred";
++$$varname; # $fred now 24
This works *sometimes*, but it is a very bad idea for two
reasons.
The first reason is that they *only work on global variables*.
That means above that if $fred is a lexical variable created
with my(), that the code won't work at all: you'll accidentally
access the global and skip right over the private lexical
altogether. Global variables are bad because they can easily
collide accidentally and in general make for non-scalable and
confusing code.
Symbolic references are forbidden under the `use strict' pragma.
They are not true references and consequently are not reference
counted or garbage collected.
The other reason why using a variable to hold the name of
another variable a bad idea is that the question often stems
from a lack of understanding of Perl data structures,
particularly hashes. By using symbolic references, you are just
using the package's symbol-table hash (like `%main::') instead
of a user-defined hash. The solution is to use your own hash or
a real reference instead.
$fred = 23;
$varname = "fred";
$USER_VARS{$varname}++; # not $$varname++
There we're using the %USER_VARS hash instead of symbolic
references. Sometimes this comes up in reading strings from the
user with variable references and wanting to expand them to the
values of your perl program's variables. This is also a bad idea
because it conflates the program-addressable namespace and the
user-addressable one. Instead of reading a string and expanding
it to the actual contents of your program's own variables:
$str = 'this has a $fred and $barney in it';
$str =~ s/(\$\w+)/$1/eeg; # need double eval
Instead, it would be better to keep a hash around like
%USER_VARS and have variable references actually refer to
entries in that hash:
$str =~ s/\$(\w+)/$USER_VARS{$1}/g; # no /e here at all
That's faster, cleaner, and safer than the previous approach. Of
course, you don't need to use a dollar sign. You could use your
own scheme to make it less confusing, like bracketed percent
symbols, etc.
$str = 'this has a %fred% and %barney% in it';
$str =~ s/%(\w+)%/$USER_VARS{$1}/g; # no /e here at all
Another reason that folks sometimes think they want a variable
to contain the name of a variable is because they don't know how
to build proper data structures using hashes. For example, let's
say they wanted two hashes in their program: %fred and %barney,
and to use another scalar variable to refer to those by name.
$name = "fred";
$$name{WIFE} = "wilma"; # set %fred
$name = "barney";
$$name{WIFE} = "betty"; # set %barney
This is still a symbolic reference, and is still saddled with
the problems enumerated above. It would be far better to write:
$folks{"fred"}{WIFE} = "wilma";
$folks{"barney"}{WIFE} = "betty";
And just use a multilevel hash to start with.
The only times that you absolutely *must* use symbolic
references are when you really must refer to the symbol table.
This may be because it's something that can't take a real
reference to, such as a format name. Doing so may also be
important for method calls, since these always go through the
symbol table for resolution.
In those cases, you would turn off `strict 'refs'' temporarily
so you can play around with the symbol table. For example:
@colors = qw(red blue green yellow orange purple violet);
for my $name (@colors) {
no strict 'refs'; # renege for the block
*$name = sub { "<FONT COLOR='$name'>@_</FONT>" };
}
All those functions (red(), blue(), green(), etc.) appear to be
separate, but the real code in the closure actually was compiled
only once.
So, sometimes you might want to use symbolic references to
directly manipulate the symbol table. This doesn't matter for
formats, handles, and subroutines, because they are always
global -- you can't use my() on them. But for scalars, arrays,
and hashes -- and usually for subroutines -- you probably want
to use hard references only.
--
They spell it "da Vinci" and pronounce it "da Vinchy". Foreigners
always spell better than they pronounce.
-- Mark Twain
------------------------------
Date: 17 Jun 1999 18:50:37 GMT
From: hpb+@pitt.edu (Harry P Bloomberg)
Subject: Neet Perl Obfucation Program
Message-Id: <7kbg1t$kb9$1@usenet01.srv.cis.pitt.edu>
I need to be able to deliver some code written in Perl and I want
to make it very difficult for unauthrorized personnel to read.
I've dealt with some commercial packages that have been delivered with
Perl source that has been obsfucated to the point that a mere mortal
could not make sense of the code. Alas, I've been unable to find a program
that can do this, but I know they exist.
So, could someone please point me towards a Perl obfucation program,
free or commercial?
Thanks,
Harry Bloomberg
hpb+@pitt.edu
------------------------------
Date: 17 Jun 1999 17:52:24 GMT
From: Franklin Edward Sadler <gte482i@prism.gatech.edu>
Subject: Re: Newbie Array Question
Message-Id: <7kbcko$h6j@catapult.gatech.edu>
Franklin Edward Sadler <gte482i@prism.gatech.edu> wrote:
My bad...nevermind I just learned the push command, Doh! Sorry for
takking up space.
: Is there any way to declare the size of an array in PERL without having to
: put anything into it yet? For ex..
: Can I Do @Array[4];
: Or Do I HAVE to do... @Array = ("","","",""); ?
: Anyhelp would be appreciated.
: Thanx
: Frankie
: --
: M U S T A N G Z !
: Franklin Edward Sadler
: Georgia Institute of Technology, Atlanta Georgia, 30332
: Email: gte482i@prism.gatech.edu
--
M U S T A N G Z !
Franklin Edward Sadler
Georgia Institute of Technology, Atlanta Georgia, 30332
Email: gte482i@prism.gatech.edu
------------------------------
Date: Thu, 17 Jun 1999 11:26:03 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Newbie Array Question
Message-Id: <Pine.GSO.4.02A.9906171123080.13900-100000@user2.teleport.com>
On 17 Jun 1999, Franklin Edward Sadler wrote:
> Subject: Newbie Array Question
Please check out this helpful information on choosing good subject
lines. It will be a big help to you in making it more likely that your
requests will be answered.
http://www.perl.com/CPAN/authors/Dean_Roehrich/subjects.post
> Is there any way to declare the size of an array in PERL without
> having to put anything into it yet?
I'll give you two answers; you can choose the one you prefer.
No, you don't declare the size of Perl arrays. They grow and shrink as
needed.
Yes. See the information about $#days in the perldata manpage.
Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Thu, 17 Jun 1999 14:24:37 -0400
From: "Allan M. Due" <Allan@due.net>
Subject: Re: odd autoincrement behavior ?
Message-Id: <7kbe1r$l8f$1@nntp4.atl.mindspring.net>
Uri Guttman wrote in message ...
:>>>>> "PRL" == Phil R Lawrence <prlawrence@lehigh.edu> writes:
: PRL> Hmm.. None of the possible positions for autoincrementing do
: PRL> what I want, which is to use the current element of $_ as a hash
: PRL> key, and assign the next element of _ as the value!
:
: PRL> OUTPUT for $h{$_[$idx]} = $_[++$idx];
:
:that (or your other tries) won't work since the prefix ++ is executed
before
:the assignment is done.
This is all just so darn interesting and, for me, unexpected. Please bear
with me if my terminology is a bit spotty here (one of the liabilities of
never having any formal training in programming). It seems to me that
incrementing right hand (side) values effects strings differently than
indexes. In each of the following $i and $array[$i] are the same value just
before the eval but when they are assigned to values of autoincrementing
hash keys I get different results. For example:
If I post increment the key and use a string I get the following key, hash
pairs:
1 : 2
3 : 4
5 : 6
7 : 8
but if I post increment the key and assign using an array index I get:
1 : 2
3 : 4
5 : 5
7 : 7
I would have thought I would get the same. This pattern does not happen
when I autoincrement the values. As far as I can tell the pattern in the
following is that autoincrementing a key on the left side will increment the
string value but not the array index. If you autoincrement the string or
the array index on the right side of the equation it impacts the left side
key as well. This makes some sense to me in that assignment usually goes
right to left. The thing that seems non-intuitive is that strings and array
indexes would be differentially impacted by autoincrements on the left. In
the following evals examples 5 - 8 make sense to me in that I obtain the
same values whether I am using a string or using an index to assign the
value to the key. In examples 1-4 I would have expected 1 and 2 to produce
the same results and 3 and 4 to produce the same results, but they do not.
This all this make any sense? Probably not.
Anyone care to shed any light on this for me?
--
$email{'Allan M. Due'} = ' All@n.Due.net ';
--random quote --
Williams and Holland's Law: If enough data is collected, anything may be
proven by statistical methods.
-------------
#!/usr/local/bin/perl -w
use strict;
my %inc_ways = (
1=> '$hash{$i++} = $i;',
2=> '$hash{$i++} = $array[$i];',
3=> '$hash{++$i} = $i;',
4=> '$hash{++$i} = $array[$i];',
5=> '$hash{$i} = $i++;',
6=> '$hash{$i} = $array[$i++];',
7=> '$hash{$i} = ++$i;',
8=> '$hash{$i} = $array[++$i];'
);
my %inc_titles = (
1=> 'post key string',
2=> 'post key array',
3=> 'pre key string',
4=> 'pre key array',
5=> 'post string string',
6=> 'post array array',
7=> 'pre array string',
8=> 'pre array array'
);
foreach my $way (1..8) {
my %hash = (1=>2,3=>4);
my @array = qw(0 1 2 3 4 5 6 7 8);
my $i=5;
print "$way: $inc_titles{$way}\n";
foreach (1..2){
print "The same here: $i $array[$i]\n";
eval $inc_ways{$way};
$i++;
}
print "\n";
print "$_ : $hash{$_}\n" foreach sort keys %hash;
print "\n";
}
__END__
1: post key string
The same here: 5 5
The same here: 7 7
1 : 2
3 : 4
5 : 6
7 : 8
2: post key array
The same here: 5 5
The same here: 7 7
1 : 2
3 : 4
5 : 5
7 : 7
3: pre key string
The same here: 5 5
The same here: 7 7
1 : 2
3 : 4
6 : 6
8 : 8
4: pre key array
The same here: 5 5
The same here: 7 7
1 : 2
3 : 4
6 : 5
8 : 7
5: post string string
The same here: 5 5
The same here: 7 7
1 : 2
3 : 4
6 : 5
8 : 7
6: post array array
The same here: 5 5
The same here: 7 7
1 : 2
3 : 4
6 : 5
8 : 7
7: pre array string
The same here: 5 5
The same here: 7 7
1 : 2
3 : 4
6 : 6
8 : 8
8: pre array array
The same here: 5 5
The same here: 7 7
1 : 2
3 : 4
6 : 6
8 : 8
------------------------------
Date: 17 Jun 1999 11:38:00 PST
From: Neil <neil@pacifier.com>
Subject: Online database
Message-Id: <37694088.0@news.pacifier.com>
I am looking for Online database options: actually just a flatfile
database.
The intn'l trade association I work for has a Virtual Server
running on a UNIX box at our ISP.
We want to have a simple database that would consist of companies
and 15 possible services. Each company provides from 1 to a maximum
of all 15 services.
We want visitors to the Web page to, using a form, query the database
based on services. Maybe a checkbox next to each service, and the user
can check those services he or she wants and then click submit and the
database would return companies that provide the services selected. The
output would just be a simple table with basic information and a hyperlink
if more information about a specific company is desired.
I am looking for a recommendation on perl scripts that will accomplish the
above.
On another topic, I am happy to report that I have ordered the Ram and
am looking forward to learning some Perl. My learning strategy will be
to read, program, and lurk in this group.
Neil
------------------------------
Date: 17 Jun 1999 11:07:22 -0600
From: Eric The Read <emschwar@rmi.net>
Subject: Re: pattern matching question
Message-Id: <xkf1zfalprp.fsf@valdemar.col.hp.com>
bart.lateur@skynet.be (Bart Lateur) writes:
> Eric The Read wrote:
> > Somebody wrote:
> >> ($path = $url) =~ s,^.*?//.*?/,,;
> >It's entirely possible that those are the ugliest delimiters I've ever
> >seen for s///.
>
> Oh yeah?
*wince* I shoulda seen this coming....
> ($path = $url) =~ s;^.*?//.*?/;;;
I can't decide. On the one hand, it's definitely uglier. OTOH, it's
kinda cute in a sickening, Linda Blair sort of way. I call it a tie.
(Third tie today... maybe it's me.)
-=Eric
------------------------------
Date: 17 Jun 1999 14:11:22 -0400
From: Jason Reed <jcreed@cyclone.jprc.com>
Subject: Re: pattern matching question
Message-Id: <a1hfo63df9.fsf@cyclone.jprc.com>
> > >> ($path = $url) =~ s,^.*?//.*?/,,;
> > >It's entirely possible that those are the ugliest delimiters I've ever
> > >seen for s///.
> > Oh yeah?
> > ($path = $url) =~ s;^.*?//.*?/;;;
> I can't decide. On the one hand, it's definitely uglier. OTOH, it's
> kinda cute in a sickening, Linda Blair sort of way. I call it a tie.
Hey, I use s,,, and m,, all the time when /'s are involved
in patterns.
Hardly ugly, (better than m## anyway, which confuses c-perlmode)
and they almost resemble miniature slashes, no? :)
---Jason
(';', otoh, that's just evil...)
*&=sub{map{&$_($_,@_)}sub{$#_>1&&map{push@_,$_+pop;
(chr).(&{$_[0]})[0]}pop}},print&{&}(m(...)g)for qw;
000013250008002249072180250013021048174013253244005001013065172001254043074;
------------------------------
Date: 17 Jun 1999 11:05:29 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Perl training on east coast
Message-Id: <m1n1xy66ty.fsf@halfdome.holdit.com>
>>>>> "Tad" == Tad McClellan <tadmc@metronet.com> writes:
Tad> jkeys (jkeys@pobox.upenn.edu) wrote:
Tad> : Anyone familiar with traiing offered in the Philadelphia, New Jersey or
Tad> : New York area?
Tad> Yet Another Perl Conference (YAPC) will be held in Pittsburgh
Tad> next week.
Tad> Very cheap...
Tad> http://www.cs.cmu.edu/~lenzo/yapc/
unfortunately, it's also "SOLD OUT".
Cool.
That means there'll probably be scalpers at the front gate selling
unused YAPC tickets!
I'll get a "all access pass" laminated, and have to go in through
the back door just to avoid the mobs.
<grin>
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: 17 Jun 1999 12:18:21 -0600
From: Daniel Grisinger <dgris@moiraine.dimensional.com>
Subject: Re: Personal Rant (was Re: Does Perl have a future?)
Message-Id: <m3u2s6pu6q.fsf@moiraine.dimensional.com>
Watcher <watcher_q@my-deja.com> writes:
> Of course, Sun would say that they are the best. Which company won't?
> Sun is course worried. If Java slips on the server side, its
> importance will greatly diminished in the enterprise space. Then, the
> only place that Java would exist would be in the device space (eg Jini,
> etc).
It should be pointed out that the device space is larger than all
other application spaces combined.
dgris
--
Daniel Grisinger dgris@moiraine.dimensional.com
perl -Mre=eval -e'$_=shift;;@[=split//;;$,=qq;\n;;;print
m;(.{$-}(?{$-++}));,q;;while$-<=@[;;' 'Just Another Perl Hacker'
------------------------------
Date: Thu, 17 Jun 1999 10:17:28 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: program execution meter????
Message-Id: <Pine.GSO.4.02A.9906171003080.13900-100000@user2.teleport.com>
On Thu, 17 Jun 1999, Wolfgang [iso-8859-1] G=F6tzinger wrote:
> I programmed a script, that starts the program myProgr and prints the
> stdout of this program:
>=20
> open OUTPUT,"myProgr|";
> while (<OUTPUT>) {
> print;
> }
> close OUTPUT;
Okay.... Although it would be better to check the return value from open.
> myProgr takes several minutes to execute and return a stdout.
> the question is:
> How can i print out a "." every 10 seconds until myProgr has finished?
You want the docs mixed with the output of the other program? Or maybe
the other program only produces output when it's done.
You could use an alarm, but that's not as reliable as using the four-arg
select and sysread.=20
You should probably set up a naked block in which you call select with a
one-second timeout. When it returns, you can process the incoming data (if
any), issue a dot (if it's time), and restart the loop (with redo) unless
sysread returned zero. (But see your system's read(2) manpage for more
information about what sysread is doing.)
Good luck with it!
--=20
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 17 Jun 1999 18:10:21 GMT
From: tgy@chocobo.org (Fuzzy Warm Moogles)
Subject: Re: qr// doesn't save my day!
Message-Id: <7kbdmd$inq$0@216.39.141.200>
On Thu, 17 Jun 1999 10:49:51 GMT, bart.lateur@skynet.be (Bart Lateur) wrote:
>I don't know if I'm doing anything wrong. I'm trying out the new qr//
>feature, but it turns out to be SLOWER even than recompiling the regex
>every time. Or did I just pick a bad example?
>
> use Benchmark;
> $regex1 = ' \\w+';
> $regex2 = qr/$regex1/;
> $text = "Hello, world!\n";
> timethese(10000, {
> 'string' => sub { $text =~ /$regex1/ }, # compile every time
> 'precompiled' => sub { $text =~ $regex2}, # precompiled
> 'straightforward' => sub { $text =~ /$regex1/o }, # compile once
> });
>__END__
>Benchmark: timing 10000 iterations of precompiled, straightforward,
>string...
>precompiled: 6 wallclock secs ( 5.71 usr + 0.00 sys = 5.71 CPU)
>straightforward: 4 wallclock secs ( 5.22 usr + 0.00 sys = 5.22 CPU)
> string: 5 wallclock secs ( 5.60 usr + 0.00 sys = 5.60 CPU)
>
> Bart.
I get a faster qr// over here. Why isn't it as fast as /o though?
Benchmark: timing 500000 iterations of precompiled, straightforward,
string...
precompiled: 3 wallclock secs ( 3.47 usr + 0.00 sys = 3.47 CPU)
straightforward: 4 wallclock secs ( 2.92 usr + 0.00 sys = 2.92 CPU)
string: 4 wallclock secs ( 4.11 usr + 0.00 sys = 4.11 CPU)
--
Fuzzy | tgy@chocobo.org | Will hack Perl for a moogle stuffy! =^.^=
------------------------------
Date: Thu, 17 Jun 1999 11:13:22 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: qr// doesn't save my day!
Message-Id: <Pine.GSO.4.02A.9906171107420.13900-100000@user2.teleport.com>
On Thu, 17 Jun 1999, Bart Lateur wrote:
> I'm trying out the new qr// feature, but it turns out to be SLOWER
> even than recompiling the regex every time.
> $regex2 = qr/$regex1/;
> 'precompiled' => sub { $text =~ $regex2}, # precompiled
Someone has misinformed you that qr// precompiles a pattern to make it
faster, or something of the sort. It may help to think of this operator as
"quoting a string as pattern would be quoted" instead. See the perlop
manpage for more information. Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Thu, 17 Jun 1999 18:24:12 GMT
From: Gareth Rees <garethr@cre.canon.co.uk>
Subject: Re: qr// doesn't save my day!
Message-Id: <siemja1y9f.fsf@cre.canon.co.uk>
Tom Phoenix <rootbeer@redcat.com> wrote:
> Someone has misinformed you that qr// precompiles a pattern to make it
> faster, or something of the sort.
You can understand why someone might think this, given that the perlop
manpage for 5.005_02 says
The benefit from [using qr//] is that the pattern is precompiled
into an internal representation, and does not need to be recompiled
every time a match is attempted. This makes it very efficient to do
something like:
foreach $pattern (@pattern_list) {
my $re = qr/$pattern/;
foreach $line (@lines) {
if($line =~ /$re/) {
do_something($line);
}
}
}
The perlop manpage for 5.005_57 doesn't make the same "very efficient"
claim, but says instead:
Since Perl may compile the pattern at the moment of execution of
qr() operator, using qr() may have speed advantages in some
situations, notably if the result of qr() is used standalone:
--
Gareth Rees
------------------------------
Date: Thu, 17 Jun 1999 11:05:21 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: RC5
Message-Id: <Pine.GSO.4.02A.9906171104190.13900-100000@user2.teleport.com>
On 17 Jun 1999, nick wrote:
> I'm looking for a perl module implementing RC5. Any suggestions?
If there's a module which does what you want, it should be listed in
the module list on CPAN. If you don't find one to your liking, you're
welcome and encouraged to submit one! :-) Hope this helps!
http://www.perl.org/CPAN/
http://www.perl.com/CPAN/
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Thu, 17 Jun 1999 18:12:38 GMT
From: Gareth Rees <garethr@cre.canon.co.uk>
Subject: Re: RC5
Message-Id: <sig13q1ysp.fsf@cre.canon.co.uk>
Tom Phoenix <rootbeer@redcat.com> wrote:
> http://www.perl.org/CPAN/
> http://www.perl.com/CPAN/
Don't forget http://www.cpan.org/
In answer to the original query, the CPAN search engine at
http://theory.uwinnipeg.ca/search/cpan-search.html produces no matches
for 'RC5' as part of a module name or description.
--
Gareth Rees
------------------------------
Date: Fri, 18 Jun 1999 00:00:28 +0530
From: Srishti <srishti@giasbg01.vsnl.net.in>
To: John Frank <jwfrank@toad.net>
Subject: Re: Regex Help Needed
Message-Id: <37693EC4.B306FF2D@giasbg01.vsnl.net.in>
This is a multi-part message in MIME format.
--------------A3CD4CC4646F0D6BA6794082
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
try using \b (stands for word boundary) instead of \W ....
Deepak.
John Frank wrote:
>
> I have 2 types of files in a long html page. They are
> quite similar. One is s_a***.html and the other is a***.html.
> I want to change the names of the a***.html files but not the
> s_a*** files. If I use s/a*\.html/a*\.xyz/g; it changes
> both files. I tried using s/\Wa*\.hmtl/a*\.html/g; but that
> won't work. Any help here is appreciated. I'm still feeling
> my way in Perl.
>
> Jack
--------------A3CD4CC4646F0D6BA6794082
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Srishti
Content-Disposition: attachment; filename="vcard.vcf"
begin: vcard
fn: Srishti
n: ;Srishti
org: Srishti Software Pvt. Ltd
adr: #66, 4th Cross, 17th 'A' Main;;5th Block, Koramangala;Bangalore;Karnataka;560 095;India
email;internet: srishti@giasbg01.vsnl.net.in
tel;work: 91-80-5522011/5084529
tel;fax: 91-80-5532016
tel;home: 91-80-5084528
x-mozilla-cpt: ;0
x-mozilla-html: FALSE
version: 2.1
end: vcard
--------------A3CD4CC4646F0D6BA6794082--
------------------------------
Date: Thu, 17 Jun 1999 10:21:49 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: regexp trouble..
Message-Id: <Pine.GSO.4.02A.9906171018460.13900-100000@user2.teleport.com>
On Thu, 17 Jun 1999, Bastiaan S van den Berg wrote:
> isn't there a way to get perl 5.002 for win32? just to be on the save
> side?
That would be the _unsafe_ side. Perl versions as old as that have
exploits registered with CERT. That is to say, someone may be able to
exploit a bug in that old Perl to take over the machine running the
webserver at your ISP. In fact, someone may already have done so.
If this reason doesn't seem persuasive to your system administrator,
perhaps you should upgrade. :-)
Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Thu, 17 Jun 1999 10:46:56 -0700
From: Andrew J Perrin <aperrin@mcmahon.qal.berkeley.edu>
Subject: Re: Regular expresions as parameters
Message-Id: <37693490.8EB3DB99@mcmahon.qal.berkeley.edu>
I can think of two ways to do it; I'm sure the greater gurus will mention
many others:
1.) use eval() to run code stored in strings; however, I suspect this is
depracated in favor of...
2.) use the new qr// construct (new in perl 5.005) to store a regexp object
in a scalar variable, then use the stored construct in your hash of regexps.
Hope this helps-
Andy Perrin
Derek Lavine wrote:
> Hi all,
>
> I would like to be able to call a function passing it a hash of regular
> expressions and a hash of field values. Both hashes will have a common
> index (namely the field names) to which the field values correspond.
-------------------------------------------------------------
Andrew J. Perrin - NT/Unix/Access Consulting - (650)938-4740
aperrin@mcmahon.qal.berkeley.edu (Remove the Junk Mail King)
http://www.geocities.com/SiliconValley/Grid/7544/
-------------------------------------------------------------
------------------------------
Date: Thu, 17 Jun 1999 11:22:51 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: reloadable script
Message-Id: <Pine.GSO.4.02A.9906171122140.13900-100000@user2.teleport.com>
On Thu, 17 Jun 1999, Leonid Goltser wrote:
> I want my script reload (refresh) itself in a definite amount of time
> (like a chat). How can I do that?
It sounds as if you want a remote browser to re-fetch a URL. Check the
docs, FAQs, and newsgroups about browsers for more information. Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Thu, 17 Jun 1999 13:22:13 -0400
From: brian@pm.org (brian d foy)
Subject: Re: Request for improvements to my search script
Message-Id: <brian-ya02408000R1706991322130001@news.panix.com>
In article <7kapv3$hld$1@nnrp1.deja.com>, lou@visca.com posted:
> I've written a Perl script called Site Search whose purpose is to
> recursively search a web site for a user-supplied string. The user can
> choose Boolean AND, OR or AS A PHRASE; whole-word or not; and
> case-sensitive or not. The program returns a list of pages, represented
> by their titles and description meta-tags, and sorted by relevance,
> which is determined by the file length of the page divided by the number
> of matches per page.
>
> I've taken the liberty of posting the script in the hopes that people
> here will offer comments and suggestions for improvements. I plan to
> offer this script for free.
you may wish to read the docs for the glimpse package to see how you
might design something like this. as it is, your script wastes a
lot of effort.
--
brian d foy
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Monger Hats! <URL:http://www.pm.org/clothing.shtml>
------------------------------
Date: Thu, 17 Jun 1999 17:51:02 GMT
From: "news.boeing.com" <jim.ray@west.boeing.com>
Subject: Sorting a text file.
Message-Id: <FDHG9A.Cns@news.boeing.com>
I am using ActiveState PERL on NT under IIS4. My text file has 7 fields
separated by ' ; ' . I use to use the command
open(CONFG, "sort -k5 '-t;' $dataname |"); under UNIX PERL, but under
ActiveState it does not.
Is this handled another way? If so, how can I sort my text file?
Thank you for your help.
--
Jim Ray
Delta Program NT Administrator
The Boeing Company
714-896-2038
jim.ray@west.boeing.com
------------------------------
Date: 17 Jun 1999 14:42:24 -0400
From: Vincent Murphy <vmurphy@gamora.ndhm.gtegsc.com>
Subject: Re: Sorting a text file.
Message-Id: <xjgpv2uis8f.fsf@gamora.ndhm.gtegsc.com>
>>>>> "news" == news boeing com <jim.ray@west.boeing.com> writes:
news> I am using ActiveState PERL on NT under IIS4. My text file has 7 fields
news> separated by ' ; ' . I use to use the command
news> open(CONFG, "sort -k5 '-t;' $dataname |"); under UNIX PERL, but under
news> ActiveState it does not.
news> Is this handled another way? If so, how can I sort my text file?
see ftp://ftp.cs.colorado.edu/pub/perl/CPAN/doc/FMTEYEWTK/sort.html for
details on sorting. This is far more descriptive than I could ever be.
HTH.
--
Vinny
------------------------------
Date: 17 Jun 1999 18:57:05 GMT
From: ansok@alumni.caltech.edu (Gary E. Ansok)
Subject: Ugly delimiters (was Re: pattern matching question)
Message-Id: <7kbge1$gg1@gap.cco.caltech.edu>
In article <376c935c.3792022@news.skynet.be>,
Bart Lateur <bart.lateur@skynet.be> wrote:
>Eric The Read wrote:
>
>>> ($path = $url) =~ s,^.*?//.*?/,,;
>>
>>It's entirely possible that those are the ugliest delimiters I've ever
>>seen for s///.
>
>Oh yeah?
>
> ($path = $url) =~ s;^.*?//.*?/;;;
Try this one on for size:
($path = $url) =~ s\^.*?//.*?/\\;
--
Gary Ansok
------------------------------
Date: Thu, 17 Jun 1999 10:53:45 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: URGENT--pppd and chat
Message-Id: <Pine.GSO.4.02A.9906171047220.13900-100000@user2.teleport.com>
On Thu, 17 Jun 1999 sherifhanna@my-deja.com wrote:
> Subject: URGENT--pppd and chat
We answer URGENT questions at top speed around here. We also answer
non-urgent questions at top speed. This is because there's nothing to be
gained by dawdling, after all. Thus, you can save yourself eight
characters of typing next time and get your answer just as fast. :-)
> I wrote a Perl script that brings up multiple ppp sessions
> consequtively or at once. From the script, I issue a pppd command that
> looks like this:
> pppd /dev/ttyDx lock modem nodefaultip.....connect "chat -v -
> f '/etc/ppp/ppp.chatscript'"
>
> The problem is that this command is issued many many times...in a loop
> basically (this is my intention...). Some calls are not successful and
> that's fine, but numerous instances of pppd and chat continue to run,
> even after the phones hang up. Also, before restarting the cycle of
> issuing pppd commands, I use the ppp-off script to make sure that no
> connections are up.
>
> I'm wondering how this could be resolved.
What needs resolving here? It sounds as if you're saying that you're doing
what you want to do.
> My memory gets eaten up quickly, and the system eventually falls into
> segmentation fault, and crashes.
That indicates that you may have a shortage of memory for your needs, or a
bug in your system or pppd. Maybe you should check the docs, FAQs, and
newsgroups about PPP and your system. Good luck!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Thu, 17 Jun 1999 17:03:50 GMT
From: Gareth Rees <garethr@cre.canon.co.uk>
To: pavel@asei.cz
Subject: Re: Using Exporter
Message-Id: <siiu8m21zd.fsf@cre.canon.co.uk>
Pavel Hlavnicka <pavel@asei.cz> wrote:
> All I need to know is: Why a have to require (at least) Exporter in
> MyModule. In other words why adding Exporter into @ISA isn't enough?
Perl's method dispatcher doesn't load modules. (It can't, because
there's no reliable way to deduce the name of a module from the name of
a package. A module may correspond to several packages, or a single
package may be implemented across any number of modules.)
If you want compile-time loading of the module with the same name as
your base class, write `use base qw(Foo)' instead of `@ISA = qw(Foo)'.
See `perldoc base' for details.
--
Gareth Rees
------------------------------
Date: Thu, 17 Jun 1999 13:36:29 -0400
From: Ken MacFarlane <ksm+usenet@sas.upenn.edu>
To: pavel@asei.cz
Subject: Re: Using Exporter
Message-Id: <3769321D.9692573B@sas.upenn.edu>
[mailed & posted]
Pavel Hlavnicka wrote:
>
> Hi all,
> simple question for skilled one.
>
> When I write module using Exporter, is starts like this:
>
> package MyPack;
>
> require Exporter;
> use vars qw(@ISA @EXPORT_OK @EXPORT);
>
> @ISA = qw(Exporter);
> @EXPORT = qw(showmessage);
> @EXPORT_OK = qw(showmessage);
>
> In program I write
>
> use MyModule;
[...]
> All I need to know is: Why a have to require (at least) Exporter in
> MyModule.
You would use Exporter to allow code that uses your module to import
subroutines, variables, etc. into the current package. For instance,
assuming that MyPack.pm is using Exporter, your code looks like:
use MyPack;
my $msg = showmessage('hello world');
You don't have to use Exporter, but if you don't, you'll need to prepend
the package name to the subroutine (and variables, etc.):
use MyPack; # doesn't export
my $msg = MyPack::showmessage('hello world');
> In other words why adding Exporter into @ISA isn't enough? What's
> happened while
> require Exporter is called (I found no startup code in Exporter).
The best way to answer this is as follows: go to
http://www.plover.com/~mjd/perl/Hello/
Download the sample programs and do the exercises. It will help. (So
will
Chapter 6 of "Advanced Perl Programming", if you have it available.)
--
Ken MacFarlane, Systems Programmer
SAS Computing Workstation Services
University of Pennsylvania
http://ccat.sas.upenn.edu/~ksm/
------------------------------
Date: Thu, 17 Jun 1999 17:23:28 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Using Exporter
Message-Id: <7kbau2$p2u$1@nnrp1.deja.com>
In article <37691DE2.4DD35B2A@asei.cz>,
pavel@asei.cz wrote:
> Hi all,
> simple question for skilled one.
>
> When I write module using Exporter, is starts like this:
>
> package MyPack;
>
> require Exporter;
> use vars qw(@ISA @EXPORT_OK @EXPORT);
>
> @ISA = qw(Exporter);
> @EXPORT = qw(showmessage);
> @EXPORT_OK = qw(showmessage);
>
> In program I write
>
> use MyModule;
>
> Camel book says, use MyModule means
> BEGIN {
> require "Module.pm";
> Module->import();
> }
>
> All I need to know is: Why a have to require (at least) Exporter in
> MyModule.
> In other words why adding Exporter into @ISA isn't enough? What's
> happened while
> require Exporter is called (I found no startup code in Exporter).
Good question.
You can't just add a module name to @ISA and expect method lookups
to resolve to anything in that module. You have to 'use' the module
in order to load its subroutine definitions into the program.
The reason you want to do that with Exporter is to get access to
the import() sub which is defined there. You could write your own
import() sub, but the one in Exporter does something which is very
commonly desired. It's actually Exporter::import which looks at
the @EXPORT and @EXPORT_OK variables.
--
John Porter
Put it on a plate, son. You'll enjoy it more.
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Thu, 17 Jun 1999 17:58:55 GMT
From: aschrock <aschrock@pubnix.org>
Subject: Who's accessing the file??
Message-Id: <Pine.GSO.4.05.9906171338320.6255-100000@pubnix.org>
Greetings all,
I'm trying to get a simple applet working that will search through a given
directory on the network and return the files which are currently open and
say by whom. The search function is easy enough, but I can't figure out
where the info is for accessing the actual file info. How can I check out
who's accessing a given file? (platform is win95/NT)
Please reply via email in addition to the NG...
Thanks a lot!
Andrew
------------------------------
Date: Thu, 17 Jun 1999 18:51:21 +0200
From: "Thimal Jayasooriya" <tja@fast.de>
To: <comp.lang.perl.misc@list.deja.com>
Subject: Re: win32 perl problems
Message-Id: <199906171654.SAA05905@prokyon.fast.de>
> them: CGI ERROR:
> The specified CGI application misbehaved by not returning a
> complete set of HTTP headers. The headers it did return are:
> Unfortunately, I am no Perl guru, but I'd like to report the same
error message, using ActivePerl 517, on IIS 4.0
I got it in the following section of code,
$q = new CGI;
$q->header;
# blah blah blah, html stuff follows
well, if you alter that, ie: comment out the $q->header, and just
pass a plain vanilla "Content-type:text/html\n\n", it works fine..
I guessed that the default header isn't good enough...
Thimal
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V8 Issue 6034
**************************************