[8975] in Perl-Users-Digest
Perl-Users Digest, Issue: 2593 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu May 14 10:27:21 1998
Date: Thu, 14 May 98 07:01:33 -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, 14 May 1998 Volume: 8 Number: 2593
Today's topics:
Re: Accessing Oracle tables from Perl <quednauf@nortel.co.uk>
Re: Actually a proposal: (was: Grieving our dying commu <quednauf@nortel.co.uk>
ANNOUNCE: Bit::Vector 5.3 (Steffen Beyer)
ANNOUNCE: Date::Calc 4.0 (Steffen Beyer)
Re: Compiling Perl <tchrist@mox.perl.com>
Re: Does Perl have a IDE?I don't like command line. (John Porter)
Re: Grieving our dying community (RonaldWS)
Re: Grieving our dying community (Steffen Beyer)
Re: How can you break out of a 'while... ' loop in a fu (John Porter)
Re: How can you break out of a 'while... ' loop in a fu <antonio@ifi.unizh.ch>
Re: Matching the last character in a scalar <sowmaster@juicepigs.com>
Re: Matching the last character in a scalar (Mike Stok)
Re: Need discussion group script <ava@oxylipin.siobc.ras.ru>
Re: newbie question <dorr@cetrel.lu>
Re: OO perl and speed <jll@skynet.be>
Re: reading file into an array of hash <xah@best.com>
Re: regexp for strings of chars <tchrist@mox.perl.com>
Re: regexp for strings of chars <lr@hpl.hp.com>
REXECD <michaelk@sapiens.com>
Re: script opens new window <quednauf@nortel.co.uk>
Some perlers don't have docs! (John Porter)
Re: Tearing my hair out over Regular Expressions - help (John Porter)
Re: Unable to use CPAN.pm through firewall <jbb@torstar.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 14 May 1998 13:01:22 +0100
From: "Frank L. Quednau" <quednauf@nortel.co.uk>
Subject: Re: Accessing Oracle tables from Perl
Message-Id: <355ADD11.181F2072@nortel.co.uk>
ryant wrote:
> Hi,
>
> I have a problem which I hope someone out there can help me with. I have to
> write some Perl code to access an Oracle database. My question here is how
> difficult would this be to perform straight from the script vs. writing
> persistent object layers to perform the same tasks? ...
The job has already been done for you. Look for Oraperl and for the DBI
modules.
--
____________________________________________________________
Frank Quednau
http://www.surrey.ac.uk/~me51fq
________________________________________________
------------------------------
Date: Thu, 14 May 1998 12:51:26 +0100
From: "Frank L. Quednau" <quednauf@nortel.co.uk>
Subject: Re: Actually a proposal: (was: Grieving our dying community)
Message-Id: <355ADABE.D36068DA@nortel.co.uk>
Andy Armstrong wrote:
> How would you point people at the wizard instead of this newsgroup?
Well, the newsgroups itself would have to be notified, and the link made
known to the important websites on the world related to Perl.
> If people were prepared to do the necessary legwork to find the answers to
> their questions ... then the problem would ... cease to be.
Certainly valid, but it's a basic 'feature' of our time that everything has
to go fast, also information seeking. Personally I don't see an advantage in
hunting down information, I would gladly use any way that would make this
easier for me. Thing is, nowadays technology allows us to compile information
in a way that is far easier to access than a chapter in a book. The only
problem I see is the amount of effort needed to keep such a wizard system up
to date. That is why it would be important to give it a first structure which
is flexible in a way as that it is easily extendable within the given
structure. I'll definitely have a think about that.
--
____________________________________________________________
Frank Quednau
http://www.surrey.ac.uk/~me51fq
________________________________________________
------------------------------
Date: 12 May 1998 23:19:49 GMT
From: sb@engelschall.com (Steffen Beyer)
Subject: ANNOUNCE: Bit::Vector 5.3
Message-Id: <6jalel$lsn$3@en1.engelschall.com>
I am pleased to announce version 5.3 of the "Bit::Vector" module:
The package is available for download either from my web site at
http://www.engelschall.com/u/sb/download/
or from any CPAN (= "Comprehensive Perl Archive Network") mirror server:
(allow a few days for propagation if necessary)
http://www.perl.com/CPAN/authors/id/STBEY/
The package consists of a C library (designed for maximum efficiency)
which is the core of a Perl module (designed for maximum ease of use).
The C library is specifically designed so that it can be used stand-alone,
without Perl.
What does it do:
----------------
This module is useful for a large range of different tasks:
- For example for implementing sets and performing set operations
(like union, difference, intersection, complement, check for subset
relationship etc.),
- as a basis for many efficient algorithms, for instance the
"Sieve of Erathostenes" (for calculating prime numbers),
(The complexities of the methods in this module are usually either
O(1) or O(n/b), where "b" is the number of bits in a machine word
on your system.)
- for shift registers of arbitrary length (for example for cyclic
redundancy checksums),
- to calculate "look-ahead", "first" and "follow" character sets
for parsers and compiler-compilers,
- for graph algorithms,
- for efficient storage and retrieval of status information,
- for performing text synthesis ruled by boolean expressions,
- for "big integer" arithmetic with arbitrarily large integers,
- for manipulations of chunks of bits of arbitrary size,
- for bitwise processing of audio CD wave files,
- to convert formats of data files,
and more.
What's new in version 5.3:
--------------------------
The method "Norm()" has been further improved to become still a bit more
efficient.
The upgrade utility "upgrade_BV52" (a shell script) was ported to Perl
(now named "upgrade_BV53.pl"), making it faster, more flexible and easier
to read and maintain and -- last but not least -- executable under
Windows NT/95 as well.
Moreover, a similar tool for upgrading from "Set::IntegerFast" version 3.x
to "Bit::Vector" version 4.2 (called "upgrade_BV42.pl") was added.
Support for Windows NT/95 was also improved by adding the extension ".txt"
to all text files (where possible) in order to allow opening them with a
double-click.
Finally, the document "CHANGES.txt" was completely rewritten because
it had become a terrible mess.
Legal issues:
-------------
Copyright (c) 1995, 1996, 1997, 1998 by Steffen Beyer.
All rights reserved.
This package is free software; you can redistribute it and/or
modify it under the same terms as Perl itself, i.e., under the
terms of the "Artistic License" or the "GNU General Public License".
The C library at the core of this Perl module can additionally
be redistributed and/or modified under the terms of the "GNU
Library General Public License".
Prerequisites:
--------------
Perl version 5.000 or higher, and an ANSI C compiler (!)
^^^^^^
Author's note:
--------------
If you have any questions, suggestions or need any assistance, please
let me know!
I would in fact be glad to receive any kind of feedback from you!
I hope you will find this module beneficial.
Yours,
--
Steffen Beyer <sb@engelschall.com> http://www.engelschall.com/u/sb/
"There is enough for the need of everyone in this world,
but not for the greed of everyone." - Mahatma Gandhi
------------------------------
Date: 12 May 1998 23:17:56 GMT
From: sb@engelschall.com (Steffen Beyer)
Subject: ANNOUNCE: Date::Calc 4.0
Message-Id: <6jalb4$lsn$2@en1.engelschall.com>
I am pleased to announce version 4.0 of the "Date::Calc" module:
The package is available for download either from my web site at
http://www.engelschall.com/u/sb/download/
or from any CPAN (= "Comprehensive Perl Archive Network") mirror server:
(allow a few days for propagation if necessary)
http://www.perl.com/CPAN/authors/id/STBEY/
The package consists of a C library (useful for C developers) which is the
core of a Perl (wrapper) module (for easy access to the library from Perl).
The C library is specifically designed so that it can be used stand-alone,
without Perl.
What does it do:
----------------
This package consists of a C library and a Perl module (which uses
the C library, internally) for all kinds of date calculations based
on the Gregorian calendar (the one used in all western countries today),
thereby complying with all relevant norms and standards: ISO/R 2015-1971,
DIN 1355 and, to some extent, ISO 8601 (where applicable).
(See also http://www.engelschall.com/u/sb/download/Date-Calc/DIN1355/
for a scan of part of the "DIN 1355" document (in German)).
The module of course handles year numbers of 2000 and above correctly
("Year 2000" or "Y2K" compliance) -- actually all year numbers from 1
to the largest positive integer representable on your system (which
is at least 32767) can be dealt with.
Note that this package EXTRAPOLATES the Gregorian calendar BACK
until the year 1 A.D. -- even though the Gregorian calendar was only
adopted in 1582 by most (not all) European countries, in obedience to
the corresponding decree of catholic pope Gregor I in that year.
Some (mainly protestant) countries continued to use the Julian calendar
(used until then) until as late as the beginning of the 20th century.
Finally, note that this package is not intended to do everything you could
ever imagine automagically for you; it is rather intended to serve as a
toolbox (in the best of UNIX spirit and traditions) which should, however,
always get you where you want to go.
If nevertheless you can't figure out how to solve a particular problem,
please let me know! (See e-mail address at the bottom of this document.)
Changes in version 4.0:
-----------------------
+ Complete rewrite of the XS file.
+ Extensive rewrite of the C library at the core.
+ Changed the naming conventions for function names from all lower case
to mixed upper- and lower case.
+ Added systematic exception handling.
+ Renamed the package from "Date::DateCalc" to simply "Date::Calc".
+ Renamed the corresponding files as well as the files of the C core.
+ Added a new Perl function "Week_of_Year()" (replacing "week_number()").
+ Changed the Perl function "Week_Number()" to call the C function
"Week_Number()".
+ Added new functions System_Clock()", "Today()", "Now()" and
"Today_and_Now()".
+ Added "check_business_date()", "Standard_to_Business()" and
"Business_to_Standard()".
+ Ported the functions from "Date::DateCalcLib" from Perl to C.
+ Dropped the module "Date::DateCalcLib".
+ Added multi-language support.
+ Enhanced support for Windows NT/95.
+ Complete rewrite of the demo programs.
+ Complete rewrite of the documentation.
+ Added many new tools, including a utility for upgrading existing
applications automatically and a filter for conversions between
different character sets (ISO-Latin-1 and PC "CP 850").
Legal issues:
-------------
Copyright (c) 1995, 1996, 1997, 1998 by Steffen Beyer.
All rights reserved.
This package is free software; you can redistribute it and/or
modify it under the same terms as Perl itself, i.e., under the
terms of the "Artistic License" or the "GNU General Public License".
The C library at the core of this Perl module can additionally
be redistributed and/or modified under the terms of the "GNU
Library General Public License".
Prerequisites:
--------------
Perl version 5.000 or higher, and an ANSI C compiler (!)
^^^^^^
Author's note:
--------------
If you have any questions, suggestions or need any assistance, please
let me know!
I would in fact be glad to receive any kind of feedback from you!
I hope you will find this module beneficial.
Yours,
--
Steffen Beyer <sb@engelschall.com> http://www.engelschall.com/u/sb/
"There is enough for the need of everyone in this world,
but not for the greed of everyone." - Mahatma Gandhi
------------------------------
Date: 14 May 1998 12:26:16 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Compiling Perl
Message-Id: <6jent8$a83$2@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
"LauRenCe WonG" <xiaoyu@singnet.com.sg> writes:
:any good compilers to recommend for perl?
There aren't any.
:i heard there are only a few
:compilers in the market and most are still in process of modifications and
:a lot of patches.
Market? MARKET? @#$^@#$^%#$@
:i need a compiler to compile my scripts becoz i need to
:pass the scripts to a friend who doesnt have a perl interpreter.
You have to give him the interpreter. Period.
--tom
--
Stranger does not rhyme with anger,
Neither does devour with clangour.
------------------------------
Date: Thu, 14 May 1998 12:34:05 GMT
From: jdporter@min.net (John Porter)
Subject: Re: Does Perl have a IDE?I don't like command line.
Message-Id: <MPG.fc4b0603d692a2a9896be@news.min.net>
On 13 May 1998 21:42:12 GMT,
in article <6jd43k$d3@mozo.cc.purdue.edu>,
gebis@albrecht.ecn.purdue.edu (Michael J Gebis) wrote:
> jdporter@min.net (John Porter) writes:
>
> }Spoon-feeding the documentation IS a waste of time and bandwidth.
> }By doing it, we're complicit in the misuse of the ng bw, rather
> }than resistant to it, as we ought to be.
>
> Aieeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee!
Sheesus, keep your pants on.
So apparently I misunderstood what you meant by "spoon-feed".
You want a program, preferably on the local machine, which makes
the info easy to find. Well, Perl for Win32 comes with a help file
containing most of the perl docs. Does that fit the bill?
John Porter
------------------------------
Date: 14 May 1998 13:45:33 GMT
From: ronaldws@aol.com (RonaldWS)
Subject: Re: Grieving our dying community
Message-Id: <1998051413453300.JAA23806@ladder03.news.aol.com>
I have joined the Perl Institute but have not received any communication back
from that organization. The web site for TPI (www.perl.org) has a "Coming
Soon" section which includes mention of a list of Perl projects. I do not yet
directly see any way of helping.
I have kept busy meanwhiles with a port/emulator of open2/open3 functionality
for Activestate Perl and have posted some related bug reports. I think that
there is help to be found and look forward to a time when it will be
coordinated.
Ronald Schmidt
The Software Path
Software Engineering
------------------------------
Date: 12 May 1998 12:15:04 GMT
From: sb@engelschall.com (Steffen Beyer)
Subject: Re: Grieving our dying community
Message-Id: <6j9eg8$ie$1@en1.engelschall.com>
To make my point before a long quote (I'm attaching it in full length because
I think it's worth reading from start to end, and in order for it to still be
available should the original posting expire), I fully second Leon's views
(see below).
I think it should be possible for "newbies" to ask their beginner's questions
even if they are FAQs, because sometimes it's hard when one doesn't even know
where to start searching for an answer, given the overwhelming volume of
available Perl documentation.
I think their questions are legitimate (even if they are FAQs!) and should not
be ridiculed or answered grumpily or aggressively.
On the other side, people who want to discuss more in-depth technical details
about Perl and who do not want to "wade" through all sorts of postings that
don't interest them, also have a legitimate urge, IMO.
(Which is also the reason why a "comp.lang.perl.moderated" is currently in the
process of being created (well, formally proposed, actually), which I think is
a good thing.)
Therefore, I think Leon's suggestion of a "comp.lang.perl.beginners" newsgroup
(or whatever the name should be) is actually a great idea, too.
I don't know the procedure for formally suggesting such a newsgroup; does
anybody know and agree with Leon and myself, and could [s]he lend a hand?
Thanks for any support!
Best regards,
Steffen
Leon Stepanian <info@purco.qc.ca> wrote:
>> In article <6issr5$6rk@mozo.cc.purdue.edu>,
>> gebis@albrecht.ecn.purdue.edu (Michael J Gebis) writes:
>> : I'm not saying that the flood of newbie questions doesn't
>> : get on my nerves, but I think a lot of people who should
>> : know better are only adding noise and hostility to the mix.
> I think this is very right.
> Who are these newbies? I am still a newbie after two years fiddling with
> Perl. I have managed to write some good code, granted sometimes a
> five-liner could be condensed into a one-liner by the more proficient
> Perlscriptors.
> Maybe we need a new group called comp.lang.perl.newbie where more
> mundane or direct questions could be addressed in a more layman style. I
> am sure, as I have in the past, that there are a large number of
> readers who are extremely intimidated by the level of proficiency which
> is most often displayed in this group, so both sides of the coin exist.
> Maybe there should be two coins.
> You should not forget that we can't go to school to learn Perl. We are
> mostly alone on our computers, with our books, with our own
> misconceptions, trying to figure out what the pro's see as most obvious.
> Of course, if I painted the MonaLisa, I'd know what it is about, but for
> me to explain it in writting, and expect you to then see the exact
> portrait is not a given.
> We are mostly also limited in time, or we wind up alone with allimony
> payments. We love to learn and Perl has opened our eyes again and given
> us some control back from the $M rapery which we all have to cope with.
> Changes from DOS control to Windows dependance, then internet freedom to
> now an Internet oversaturation of information and distracting directions
> have all played on all of us. That and the fact that the mortgage still
> has to be paid at the end on the month kind of brings us back to
> reality.
> If we now have to deal with paranoia because we don't know if a question
> on Perl meets a certain standard, then we are really in bad shape. What
> one person considers trivial, may be in fact ultra essential to someone
> else who is more than stuck, but actually frozen in time because a
> certain problem has blocked further progress. Does this feel good.
> Yes, trying, searching, experimenting is learning. But I am sure that in
> most cases, questions to this group have been honest ones, and not all
> about Page1 from lazy people not willing to do some honest work on their
> own. On the contrary, I personally commend anyone who even shows some
> genuine interest as this is from where they can then grow. It seems to
> me that a pat on the back and a word of encouragement should be the norm
> and not the exception.
> Just as writers need someone to proof read their work because at a
> certain point, one cannot see any more mistakes, but still knows there
> is a problem, why then should anyone consider that questions are either
> good or bad. Why not also appreciate the level of progress one had to
> make in Perl to even ask a question in the first place, and feel happy
> that this progress is being displayed even if it is usually a cry for
> help, without fear of public reprisal. If you think it is easy for most
> people to address a problem to the group, maybe think again.
> What we are forgetting is that you are all on this newsgroup because you
> want be here. You want to help people. You like it when Perl is known.
> You need to show that you master the subject and you can stand as a
> pillar or lightpost for those who cannot see that far. So why then
> should there be all this gripping. Even though one can master a language
> and concept, it does not discard them from the public responsibility of
> activing in a descent manner to others, regardless of their level of
> understanding. That's what teaching is all about. Or maybe we have
> forgotten how to teach.
> As a 2 year newbie, I for one have always felt like this is home. And I
> have learned alot more from this group than from any books, or
> databases, because, as always, information is static, problems are
> dynamic, and solving problems is fantastic. Thank you to all.
> Leon Stepanian
> Perl.......from an ocean of human kinds!
--
Steffen Beyer <sb@engelschall.com>
Free Perl and C Software for Download: www.engelschall.com/u/sb/download/
------------------------------
Date: Thu, 14 May 1998 12:44:57 GMT
From: jdporter@min.net (John Porter)
Subject: Re: How can you break out of a 'while... ' loop in a function?
Message-Id: <MPG.fc4b2ec7cf9d3139896bf@news.min.net>
On 14 May 1998 05:38:51 GMT,
in article <6je01b$efq$1@mathserv.mps.ohio-state.edu>,
ilya@math.ohio-state.edu (Ilya Zakharevich) wrote:
>
> Depends on what is in documentation.
>
> With Perl4 it would probably be the head. With perl5... I think it
> is a *giant* step back - at least if the docs are not in Gnuinfo, PDF,
> or other online book format with an easy search, table-of-contents and
> index available.
>
> And with Gnuinfo and PDF sucking enormously, OS/2 online book not
> allowing third party viewers/searchers (though this need comes pretty
> rare), I just do not understand how people who did not learn from
> Perl4 docs can do anything without a book.
Whine whine. What format do you recommend for the online docs?
I think PDF would be nice, if only because Acroread is available for
most major platforms.
Surely someone in the perl community can convert the pods to pdf (or
whatever) each time they're revised, and post it to CPAN.
John Porter
------------------------------
Date: Thu, 14 May 1998 14:32:22 +0200
From: "Denis N. Antonioli" <antonio@ifi.unizh.ch>
Subject: Re: How can you break out of a 'while... ' loop in a function?
Message-Id: <Pine.SOL.3.96.980514130220.5262A-100000@mauritius.ifi.unizh.ch>
On 14 May 1998, Tina Marie Holmboe wrote:
> What I *am* saying is that in concept both next() and last() do the sam=
e
> thing to a loop that a goto() does - it interrupts the flow; it "breaks o=
ut"
> of it. next() is by far the least 'harmful' - and note the 's there - of
> the two, as it merely skips to the next iteration.
>=20
There is a huge difference between next/last and goto: it is quite
trivial to free code from the first two to get a 'canonical' form
(see, e.g. Brandis, Marc M. 'Optimizing Compilers for Structured
Programming Languages', ETH Z=FCrich, 1995); to remove goto from a program
in a general way isn't simple to accomplish.
next/last are just shortcuts for "cleaner" programs. But these shortcuts
help write code that will be easier to read.
I'd rather read:
while (<>) {
next unless /^\d{1,3}/;
# process $_ here
}
than:
while (<>) {
if (/^\d{1,3}/) {
# process $_ here
}
}
I know at once in the first case that I'm not interested in lines that don'=
t
start with a number. In the second case, I have to match the {} and hope
that the indents match, no small feat when the processing part is complex.
My $0.02...
dna
- --
Perhaps you could have been a little more vague about what you were
looking for. Perhaps not. :-)
-- Randal L. Schwartz in <65iv6g$ceh@dfw-ixnews12.ix.netcom.com>
Version: 2.6.3ia
Charset: latin1
iQCVAwUBNVrkZH7lXFr6ofWlAQGcJQP/ZILBydArcJqNyiflrecfqJN+zFxc8IMR
tiE6dDFUtTWb5MhM5OwGf1vGAs47sGOehgGBDVH3oePqWb5gGsDMqjNtxb3PVCm6
R/NZ0AGXwsy3+NKrKBNKmNVSqAuDnlSz9wZSog2Xd6vNOmdkHDn7gU4vOSlvRtVj
ejVF9oHOsPs=3D
=3Du3Vd
-----END PGP SIGNATURE-----
------------------------------
Date: Thu, 14 May 1998 08:08:51 -0400
From: Bob Trieger <sowmaster@juicepigs.com>
To: Hauk Langlo <hauk@forumnett.no>
Subject: Re: Matching the last character in a scalar
Message-Id: <355ADED3.38A2@juicepigs.com>
[ mailed & posted]
Hauk Langlo wrote:
>
> Hi there. After playing around with perl for a week or so, regular
> expressions still are somewhat confusing.
> Right now I would like to check if a scalars last letter(s) match either
> "/" or ".txt". The ".txt" mach is not too much of a problem because such
> a match would in most cases be the end of the scalar anyway. I know how
> to detect a / , but I would like a true condition only if it is the
> last character. For experienced perl programers, this should be no
> problem at all. I would be very thankfull if you could bother to help me
> on this one. Thanks
perldoc perlre
specifically the "$" operator.
HTH
--
Bob Trieger | Titanic: big boat, bigger
sowmaster@juicepigs.com | iceberg, big deal
------------------------------
Date: 14 May 1998 12:43:09 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Matching the last character in a scalar
Message-Id: <6jeost$cn6@news-central.tiac.net>
In article <355AD343.E540D01A@forumnett.no>,
Hauk Langlo <hauk@forumnett.no> wrote:
>Hi there. After playing around with perl for a week or so, regular
>expressions still are somewhat confusing.
>Right now I would like to check if a scalars last letter(s) match either
>"/" or ".txt". The ".txt" mach is not too much of a problem because such
>a match would in most cases be the end of the scalar anyway. I know how
>to detect a / , but I would like a true condition only if it is the
>last character. For experienced perl programers, this should be no
>problem at all. I would be very thankfull if you could bother to help me
>on this one. Thanks
If you're looking for constant strings you can sometimes use index or
substr to find them e.g.
# assume string is in $s
foreach $ending ('/', '.txt') {
$l = length $ending;
if (substr ($s, -$l, $l) eq $ending) {
print "$s ends in $ending\n";
last; # break ending test loop
}
}
If you want to use regular expressions then it's worth making use of the
fact that you want to match at the end to tell the regex engine that the
match must be there (and remembering that . is a special character in
regexes - '/home/mike/tmptxt/foo.doc' will match against a regex of
/.txt/)
if ($string =~ m{(\.txt|/)$}) {
# ending in $1 here
}
This code shows some of the ways to do it:
#!/usr/local/bin/perl -w
foreach $s ('', 'foo.txt', 'foo/', 'banana') {
foreach $ending ('/', '.txt') {
$l = length $ending;
if (substr ($s, -$l, $l) eq $ending) {
print "1 $s ends in $ending\n";
last;
}
}
if ($s =~ m{(\.txt|/)$}) {
print "2 $s ends in $1\n";
}
if ($s =~ /\.txt$/ || $s =~ m{/$}) {
print "3 $s matches\n";
}
}
It produces
1 foo.txt ends in .txt
2 foo.txt ends in .txt
3 foo.txt matches
1 foo/ ends in /
2 foo/ ends in /
3 foo/ matches
The perlre man page covers regexes in detail.
Hope this helps,
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@colltech.com | Collective Technologies (work)
------------------------------
Date: Thu, 14 May 1998 16:38:37 +0400
From: "ava" <ava@oxylipin.siobc.ras.ru>
Subject: Re: Need discussion group script
Message-Id: <355ae5cd.0@oxylipin.siobc.ras.ru>
Some references to web conferencing software can be found at
http://freenet.msp.mn.us/people/drwool/webconf.html.
Some programs are available for free. I'd tried 'Ceilidh' and 'Dialogue
forum'. The former is more professional but allow you to have only one forum
(for no charge), the latter is written in Perl and to force it to work
correctly I had to change the source.
pkbk@badger.tds.net wrote in message <6jd6um$i6l$1@nnrp1.dejanews.com>...
>I'm trying to find a discussion group or message forum script similar to
the
>one in Matt's script archives or the WeBBS message board. An example of
the
>kind of message forum I'm talking about is at http://www.mtdaily.com.
>
>My web host is using a Windows NT inforamtion server, ISAPI and Perl5.
------------------------------
Date: Thu, 14 May 1998 12:46:33 +0200
From: Denis DORR <dorr@cetrel.lu>
Subject: Re: newbie question
Message-Id: <355ACB89.54C19C60@cetrel.lu>
sg wrote:
> ...
> * another question : where could i found a complete documentation about the
> "split" fonction???
perldoc -f split
--
HTH.
dorr@cetrel.lu
------------------------------
Date: Thu, 14 May 1998 15:07:08 +0200
From: Jean-Louis Leroy <jll@skynet.be>
Subject: Re: OO perl and speed
Message-Id: <VA.000000bc.0a78dfc4@jll>
> The greater the level of
> inheritance (ala "reuse") the greater the effect can be, depending
> (some compilers can cut this down, depending on the language).
Time for a benchmark:
sub make_hierarchy
{
($id, $depth) = @_;
$class = 0;
$hierarchy = <<ROOT;
package $id$class;
sub foo { }
ROOT
for ($base = 0; $base < $depth; ++$base)
{
$class = $base + 1;
$hierarchy .= <<SUBCLASS;
package $id$class;
\@ISA = '$id$base';
SUBCLASS
}
#print $hierarchy;
eval $hierarchy;
$id . $class;
}
$a1 = bless {}, make_hierarchy 'A', 1;
$a0 = bless {}, 'A0';
$b10 = bless {}, make_hierarchy 'B', 10;
$c100 = bless {}, make_hierarchy 'C', 100;
use Benchmark;
print ref $a0, " : "; timethis(1000000, sub { $a0->foo } );
print ref $a1, " : "; timethis(1000000, sub { $a1->foo } );
print ref $b10, " : "; timethis(1000000, sub { $b10->foo } );
print ref $c100, ": "; timethis(1000000, sub { $c100->foo } );
The result was:
A0 : timethis 1000000: 56 secs (56.07 usr 0.00 sys = 56.07 cpu)
A1 : timethis 1000000: 60 secs (59.94 usr 0.00 sys = 59.94 cpu)
B10 : timethis 1000000: 61 secs (60.67 usr 0.00 sys = 60.67 cpu)
C100: timethis 1000000: 60 secs (59.90 usr 0.00 sys = 59.90 cpu)
IOW, the method dispatch overhead doesn't seem to depend on the number of classes
to the method definition. This is not that surprising: an implementation that
uses lists to *declare* inheritance relationships always has the option of
converting the lists into more efficient data structures (e.g. a hash) on the
fly. A trip to the Source would be needed at this point...
Strangely, when I tried creating a 1000-level deep hierarchy, I got the following
errors:
Recursive inheritance detected at K:\perltest\method_overhead.pl line 38.
Recursive inheritance detected during global destruction.
Now let's benchmark an elementary Perl action that is typical in both OO and
non-OO styles: hash access. I picked up 10 for the hash size, since this is
probably a typical number of member variables:
@H{1..10} = 1..10;
print "hash access : "; timethis(1000000, sub { $h{4} } );
hash access : timethis 1000000: 54 secs (54.13 usr 0.00 sys = 54.13 cpu)
It seems that a method call has roughly the same cost as a hash access.
Conclusions:
1) 'simple' accessors (those that come in get/set pairs) double the cost of the
access.
2) overloaded accessors (a single method for both set and get, determined by
examining @_) probably cost *a*lot*.
3) anybody who's willing to give up on OO should give up on hashes as well <g>
Jean-Louis Leroy
http://ourworld.compuserve.com/homepages/jl_leroy
------------------------------
Date: Thu, 14 May 1998 05:32:52 -0700
From: "Xah" <xah@best.com>
Subject: Re: reading file into an array of hash
Message-Id: <6jenua$ej4$1@nntp2.ba.best.com>
In article <6jejnl$dfq$1@nntp2.ba.best.com> , "Xah" <xah@best.com> wrote:
>I want to parse a file into an array of hashes such as
>
>$record = (
> {seller_ship_carrier=>'UPS',
> seller_street_address=>'4299 Court Court Apt: 3',
> seller_state=>'Ohio',...},
> {...},
> ...
>);
Ooops. Actually I got the answer myself, easier than I thougt. Here's the
solution (attached below) that's fairly good. All nit-picking comments
welcom.
Xah, xah@best.com
http://www.best.com/~xah/Wallpaper_dir/c0_WallPaper.html
(Intelligence (lisp (pigs (perl (unix baggage (C (brain tumor)))))))
---------------------------------
#!/usr/local/bin/perl -w
# this is a testing file. Delete it when needed. This script tests parsing a
series of identical formated lines into a series of hashes. Xah
use strict;
my($filePath) = '/somedir/tempRawData.txt';
# @array1
my(@array1);
# the final desired ref.
my($record);
{
local($/) = '-----------';
if (not(open(FILE,"<$filePath"))) {die "Cannot open file: $!;"};
@array1 = <FILE>;
if (not(close(FILE))) {die "Cannot close file: $!;"};
};
{
my($textBlock);
my($i);
foreach ($i = 0; $i <= $#array1; $i++) {
$textBlock = $array1[$i];
my(@lines) = split('\n',$textBlock);
my($line);
foreach $line (@lines) {
if ($line =~ m{^([^:]+): (.+)$}) {
$record->[$i]->{$1} = $2;
};
};
};
}
# testing. print it out.
{
my($hRef,$aa2);
foreach $hRef (@{$record}) {
foreach $aa2 (keys(%{$hRef})) { print "$aa2--${$hRef}{$aa2}\n" };
print "\n";
};
}
__END__
here's a sample file.
---------------------------------------------------
seller_ship_carrier: UPS
seller_street_address: 6658 Elmdale Rd.
buyer_street_address: 776 Sposito Circle
seller_state: Ohio
buyer_state: CA
seller_ship_num: 3Z9565X40530038590
seller_name_first: Ronald
buyer_name_first: John
transaction_id: 47555487
seller_zip: 44350
buyer_zip: 95356
seller_name_last: Ballas
seller_country: U.S.A.
buyer_name_last: Manuel
buyer_country: USA
buyer_address_2:
seller_address_2:
seller_city: Middleburg Hts.,
buyer_city: San Mat
---------------------------------------------------
seller_ship_carrier: UPS
seller_street_address: 4759 Tarryton Court South
buyer_street_address: 8734 Elmwood Lane
seller_state: Ohio
buyer_state: FL
seller_ship_num: 3744965E0530005755
seller_name_first: Tom
buyer_name_first: Keith
transaction_id: 47505346
seller_zip: 45778
buyer_zip: 55635
seller_name_last: Brooks
seller_country: CAN
buyer_name_last: Busch
buyer_country: USA
buyer_address_2:
seller_address_2:
seller_city: Columbus
buyer_city: Tampa
------------------------------
Date: 14 May 1998 12:24:58 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: regexp for strings of chars
Message-Id: <6jenqq$a83$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
Jim Monty <monty@primenet.com> writes:
:@a = 'aaaaaabbb,,,xyfooffff' =~ m/(.)\1{2}/g;
You should able to use:
@a = 'aaaaaabbb,,,xyfooffff' =~ m/((.)\1{2})/g;
But that's not helping. I smell a bug.
This also fails:
while('aaaaaabbb,,,xyfooffff' =~ m/((.)\1{2})/g) {
print "$1\n"
}
But this works:
while('aaaaaabbb,,,xyfooffff' =~ m/(.)\1{2}/g) {
print "$&\n"
}
To produce output like:
aaa
aaa
bbb
,,,
fff
I'll play with the bug some more.
--tom
--
char program[1]; /* Unwarranted chumminess with compiler. */
--Larry Wall in the Perl source code
(quoting Henry Spencer (quoting Dennis Ritchie (quoting Brian Kerninghan)))
------------------------------
Date: Thu, 14 May 1998 06:26:09 -0700
From: "Larry Rosler" <lr@hpl.hp.com>
Subject: Re: regexp for strings of chars
Message-Id: <6jeret$onm@hplntx.hpl.hp.com>
[posted and emailed]
Tom Christiansen wrote in message
<6jenqq$a83$1@csnews.cs.colorado.edu>...
> [courtesy cc of this posting sent to cited author via email]
>
>In comp.lang.perl.misc,
> Jim Monty <monty@primenet.com> writes:
>:@a = 'aaaaaabbb,,,xyfooffff' =~ m/(.)\1{2}/g;
>
>You should able to use:
>
>@a = 'aaaaaabbb,,,xyfooffff' =~ m/((.)\1{2})/g;
>
>But that's not helping. I smell a bug.
>
>This also fails:
>
> while('aaaaaabbb,,,xyfooffff' =~ m/((.)\1{2})/g)
> print "$1\n"
> }
>
>But this works:
>
> while('aaaaaabbb,,,xyfooffff' =~ m/(.)\1{2}/g)
> print "$&\n"
> }
>
>To produce output like:
>
> aaa
> aaa
> bbb
> ,,,
> fff
>
>I'll play with the bug some more.
Gosh, no bug. Try this regex (with \2 instead of \1):
while('aaaaaabbb,,,xyfooffff' =~ m/((.)\2{2})/g)
print "$1\n"
}
--
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com
------------------------------
Date: Thu, 14 May 1998 16:53:44 +0300
From: Michael <michaelk@sapiens.com>
Subject: REXECD
Message-Id: <355AF768.EE6B5837@sapiens.com>
Is there a perl implementation of rexecd.
------------------------------
Date: Thu, 14 May 1998 13:16:36 +0100
From: "Frank L. Quednau" <quednauf@nortel.co.uk>
Subject: Re: script opens new window
Message-Id: <355AE0A3.CFB1B230@nortel.co.uk>
>
>
> Does anyboy know what the problem could be?
It could be a target problem. <a href="bla" target="sumtin">bla</a>
&replace_all if (target eq '_top') ;
&replace_frame_called_general if (target eq 'general');
&have_new_window if (target eq 'main');
>
--
____________________________________________________________
Frank Quednau
http://www.surrey.ac.uk/~me51fq
________________________________________________
------------------------------
Date: Thu, 14 May 1998 12:50:58 GMT
From: jdporter@min.net (John Porter)
Subject: Some perlers don't have docs!
Message-Id: <MPG.fc4b4543b6bb3a79896c0@news.min.net>
On Thu, 14 May 1998 09:03:56 GMT,
in article <355ab368.3756952@news.demon.co.uk>,
stu-w@usa.net.remove.everything.after.net (Stuart Wright) wrote:
> On Wed, 13 May 1998 21:57:30 -0400, rjk@coos.dartmouth.edu (Ronald J Kimball) wrote:
>
> >What's the point of programming in Perl if you don't have perl? That's
> >like programming in C without a C compiler. You get a nice text file
> >that does absolutely nothing.
> >
> It does plenty when it's uploaded to the server !
That's good point, one which some of us tend to overlook.
But you should go and grab the perl distribution from CPAN
(look at www.perl.com).
Then you can have the perl docs, even if you never run the
interpreter locally. Although I think you'll want to,
rather sooner than later.
John Porter
------------------------------
Date: Thu, 14 May 1998 12:30:03 GMT
From: jdporter@min.net (John Porter)
Subject: Re: Tearing my hair out over Regular Expressions - help!
Message-Id: <MPG.fc4af6df542ffc79896bd@news.min.net>
On Wed, 13 May 1998 20:10:43 GMT,
in article <3559f6e5.4095422@news.cableinet.co.uk>,
ljs@cableinet.co.uk (Luke Steele) wrote:
>
> The problem is this: I have a file containing a number of lines, each
> of which consists of a field name (in uppercase) followed by some text
> (the 'value' of that particular line) followed by a newline. The
> contents of the file is placed in a scalar. I wish to be able to
> place the text following the field name in each line into a specific
> scalar variable determined by the field name.
>
> "CONTACT: Luke Steele \nADDRESS: asdf \n" =~
>
> (The idea is $1 should contain Luke Steele with no spaces afterward.)
I'm not sure regex is the way to go on this one.
$s = "CONTACT: Luke Steele \nADDRESS: asdf \n";
for ( split( "\n", $s ) ) {
s/\s+$//; # strip trailing whitespace
if ( /:\s+/ ) {
print "$` = $'\n";
# store in hash:
$d{$`} = $';
}
# else not valid line
}
# dump the hash:
for ( sort keys %d ) {
print "$_ = $d{$_}\n";
}
hth,
John Porter
------------------------------
Date: 14 May 1998 10:09:32 -0400
From: Jordan Baker <jbb@torstar.com>
Subject: Re: Unable to use CPAN.pm through firewall
Message-Id: <uutzpglvt9f.fsf@torstar.com>
I had a similar problem with going through a firewall, and there are
quite a few FTP/HTTP parameters you can set.
However, the only way I discovered these was by pouring through the
source code.
Also, if you're using an external program like lynx, the man pages may
have some indications as to how you can configure it to use a
firewall.
good luck.
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.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 2593
**************************************