[10735] in Perl-Users-Digest
Perl-Users Digest, Issue: 4335 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Dec 1 17:07:25 1998
Date: Tue, 1 Dec 98 14:01:38 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 1 Dec 1998 Volume: 8 Number: 4335
Today's topics:
Re: Perl compiler? (Can you get one?) (Martien Verbruggen)
Perl on Solaris 2.5.1 (#!/opt/LWperl/bin)? <removeMike@SinglepointSys.com>
Re: Perl on Solaris 2.5.1 (#!/opt/LWperl/bin)? (Erik)
Re: Problems with 'setenv' within .sh and .pl scripts u <barmar@bbnplanet.com>
Re: Q: Installed Modules (Martien Verbruggen)
Re: Remove non-alphabetic characters from string (Paul Neubauer)
Re: Strip and add, perl style (Mark D.)
Re: Strip and add, perl style (Mark D.)
Re: Strip and add, perl style (Martien Verbruggen)
Re: Strip and add, perl style (Mark D.)
Substitute <army.tennis@lineone.net>
Re: Substitute <erikd@zip.com.au>
System() <lferon@ifrance.com>
Re: System() (Erik)
Re: System() <jc@eddie.mit.edu>
Re: Terribly simply perl question about qw() (I R A Aggie)
Re: Terribly simply perl question about qw() (Andre L.)
Re: Terribly simply perl question about qw() (Andrew M. Langmead)
Re: to dbm or not to dbm? <dean2@darwin.biol.sc.edu>
Re: Using RCS in Perl scripts <merlyn@stonehenge.com>
Re: Using RCS in Perl scripts <zenin@bawdycaste.org>
Why is "... @foo ..." occasionally a syntax error? <jc@eddie.mit.edu>
Re: Why is "... @foo ..." occasionally a syntax error? (Erik)
Re: Why is "... @foo ..." occasionally a syntax error? (Martien Verbruggen)
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 01 Dec 1998 21:09:56 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Perl compiler? (Can you get one?)
Message-Id: <EWY82.10$Fn3.56@nsw.nnrp.telstra.net>
In article <740jil$3sl$1@nclient3-gui.server.ntli.net>,
Aidan Rogers <aidan@salvador.blackstar.co.uk> writes:
> After all these replies, I have a related question. Is it possible to get a
> compiler for Perl? It's all very well having a script that will run fine on
> any system that has Perl installed on it, but is it possible to compile to
> a binary executable?
# perldoc perlfaq5
# perldoc -q compile
[snip]
=head1 Found in /usr/local/lib/perl5/5.00502/pod/perlfaq3.pod
=head2 How can I compile my Perl program into byte code or C?
[snip]
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au |
Commercial Dynamics Pty. Ltd. | Can't say that it is, 'cause it ain't.
NSW, Australia |
------------------------------
Date: Tue, 1 Dec 1998 16:17:09 -0500
From: "Mike Marshall" <removeMike@SinglepointSys.com>
Subject: Perl on Solaris 2.5.1 (#!/opt/LWperl/bin)?
Message-Id: <741n0e$fam@sjx-ixn8.ix.netcom.com>
On Solaris 2.5.1, I'm loading Perl from the sunfreeware.com site. I'm
curious.
This package loads into /opt/LWperl. Perl scripts, in general, have a
sh-bang line (#!/usr/bin/perl) of /usr/bin/perl, or /usr/local/perl, etc...
I understand that /opt on Solaris 2.5.1 is for optional software, but do
Administrators leave Perl in /opt? Does this mean that they change sh-bang
lines on perl scripts? Or, Is there typically some sort of linking going on
to connect the two?
I'm sort of new to Solaris and Perl, and just wondered what the typical
environment looks like in the real world (if there is one.)
Any comments regarding the typical slicing of drives could help me out, too.
Lots of slices or just 2 ( / & swap)?
Any help is appreciated...
Mike Marshall
------------------------------
Date: 1 Dec 1998 21:53:10 GMT
From: eln@cyberhighway.net (Erik)
Subject: Re: Perl on Solaris 2.5.1 (#!/opt/LWperl/bin)?
Message-Id: <741og6$adj$3@news.cyberhighway.net>
In article <741n0e$fam@sjx-ixn8.ix.netcom.com>,
"Mike Marshall" <removeMike@SinglepointSys.com> writes:
> I understand that /opt on Solaris 2.5.1 is for optional software, but do
> Administrators leave Perl in /opt? Does this mean that they change sh-bang
> lines on perl scripts? Or, Is there typically some sort of linking going on
> to connect the two?
Depends on the administrator. It can be done both ways. Personally, I'd
just install the thing in /usr/local or /usr in the first place. /opt
is silly if you're planning on doing anything cross-platform.
Or, if you like /opt the way it is, link it or change the #! line in your
scripts...it's all the same to me, whichever way you decide.
> I'm sort of new to Solaris and Perl, and just wondered what the typical
> environment looks like in the real world (if there is one.)
Whatever the default partitions are...I think Solaris likes to have /,
/usr,/var,/opt, and /home, but it's been a while since I've let Solaris
try to figure out a good partition table for me.
Basically, it all depends on what the box is going to be used for.
> Any comments regarding the typical slicing of drives could help me out, too.
> Lots of slices or just 2 ( / & swap)?
Again, depends on what you want to do. However, it's almost never a good
idea just to have / and swap, because if something happens to hose its
partition, you lose your root filesystem in the bargain, which is generally
considered a bad thing. Limiting to those two, however, would be
a good idea for a home machine with a very small disk.
By the way, this is only very tangentially related to perl (the question can
just as easily be asked in reference to any interpretive language), and
thus doesn't really belong in c.l.p.m. c.u.s, however, seems to be
a good choice.
--
Erik Nielsen, Cyberhighway Internet Services NOC
Anybody want a binary telemetry frame editor written in Perl?
-- Larry Wall in <199708012226.PAA22015@wall.org>
------------------------------
Date: Tue, 01 Dec 1998 19:14:04 GMT
From: Barry Margolin <barmar@bbnplanet.com>
Subject: Re: Problems with 'setenv' within .sh and .pl scripts under AIX
Message-Id: <0eX82.15$5M.4092@burlma1-snr1.gtei.net>
In article <912537883.29169.0.nnrp-02.c1ed09c6@news.demon.co.uk>,
Craig Horton <CHorton@STSSystems.com> wrote:
>I want to change the ORACLE_SID environment variable within a perl script,
>so that I can automate the shutdown and startup of 3 instances of our
>databases, so we can back them up. However, I have found I can't seem to get
>setenv to make the change from within perl, using:
>
>system('setenv ORACLE_SID $instance');
The system() function executes the command in a new process, so environment
changes have no effect on the current process.
Perl provides the %ENV hash that maps to the current process's
environment. So the above would be done with:
$ENV{'ORACLE_SID'} = $install;
>so I tried doing this with a c-script, so I could then call the c-script
>within my perl script which runs the backup each night:
>
>
>#!/bin/csh
>setenv ORACLE_SID instancename
>
>
>however, while this runs, it does not change the environment variable. but
>if I just do a env in the script to list the variables, that works fine. I
>thought maybe I needed to export the change, however, if I understand
>correct, csh exports ALL variables anyhow.
Exported environment variables are inherited by subprocesses. They have no
effect on ancestor processes.
--
Barry Margolin, barmar@bbnplanet.com
GTE Internetworking, Powered by BBN, Burlington, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Don't bother cc'ing followups to me.
------------------------------
Date: Tue, 01 Dec 1998 21:29:06 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Q: Installed Modules
Message-Id: <CcZ82.16$Fn3.56@nsw.nnrp.telstra.net>
In article <7417os$k81@newssrv.igd.fhg.de>,
holzapfe@igd.fhg.de (Roland Holzapfel) writes:
> Hello,
>
> How do I find out which Modules (and their versions) are installed
> with my perl executable ?
# perldoc perllocal
# perl -MCPAN -e shell
cpan> r
[snip]
> Please answer by Mail.
Not a chance.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | The number of the beast is not 666. Its
Commercial Dynamics Pty. Ltd. | number is 95, and it's awake.
NSW, Australia |
------------------------------
Date: Tue, 1 Dec 1998 14:24:23 -0500
From: prn@bsu.edu (Paul Neubauer)
Subject: Re: Remove non-alphabetic characters from string
Message-Id: <MPG.10ce0c6ef01d197c9896f0@news.bsu.edu>
In article <ebohlmanF2ypz8.9q7@netcom.com>, ebohlman@netcom.com writes...
> David Lambert <dalambert@rocketmail.com> wrote:
> : My script gets last names as it's input, and I would like to remove any
> : non-alphabetic characters from the string, including spaces, punctuation,
> : and numerals, and output whether any changes were needed.
> [snip]
> : Could anyone suggest the best way to do this?
>
> tr is your friend (and it's almost certain to be faster than any
> regexp-based solution).
You (David) have not said just exactly why you are transforming the last
names in this way (or I have not seen it, at least), so this may or may
not be relevant. (And my comment here is certainly not specific to
perl.)
Regardless of the method you use to accomplish this transformation, be
sure that removing spaces and punctuation is actually appropriate. LOTS
of people have last names containing punctuation (remember that hyphens
are punctuation). Lots of other people have last names containing spaces
(and don't forget about "odd" capitalizations). Consider the following
examples of distinct last names: van Camp, Van Camp, VanCamp, Vancamp,
Vander Hill, van der Waals, Mies van der Rohe, de la Madrid, Garcia y
Ramos, Lloyd Webber, Smith-Jones, Macdonald, MacDonald. And then, don't
forget about the possibility of "suffixes", which are often combined with
last names: Jr., II, III, IV. "Jr." is often set off by a comma as in
William Strunk, Jr., but other people, such as Guy L. Steele Jr. do not
use a comma. Much will depend on how you handle these "suffixes", but
none of this is trivial.
I don't really know what you intend to do with the last names you gather,
but consider that if you simply throw away spaces and "punctuation" and
then attempt to *use* the resulting data, you will effectively be
misspelling people's names. You might further ponder the proposition
that many people do not *like* having their names misspelled, which could
be important if you attempt to use that data for such things as
correspondence, particularly where you might want to sell something to
the people whose names you have collected or persuade them to do
something. Misspelling someone's name certainly gets you off on the
wrong foot with them. At the very best, you will certainly increase
collisions in the namespace.
All in all, I would suggest that you be *very* careful before you
transform names in the way you have suggested.
Paul
--
Paul Neubauer prn@bsu.edu
http://home.bsu.edu/prn/
PGP Public Key at http://home.bsu.edu/prn/key.html
------------------------------
Date: Tue, 01 Dec 1998 20:27:39 GMT
From: mark@doddx.com (Mark D.)
Subject: Re: Strip and add, perl style
Message-Id: <3664501d.12327632@news.supernews.com>
On Tue, 01 Dec 1998 05:49:50 GMT, mgjv@comdyn.com.au (Martien
Verbruggen) wrote:
>In article <36647ed7.24576685@news.supernews.com>,
> mark@doddx.com (Mark D.) writes:
>
>> srand( time() ^ ($$ + ($$ << 15)) );
>> $cgi_client{'foo'} = $cgi_client{'foo'} . (int(rand(100000)) + 1);
>>
>> This adds a random number to the end of a string. how do I add it to
>> the beginning instead?
>
>$cgi_client{'foo'} = (int(rand(100000)) + 1) . $cgi_client{'foo'};
>
>Did you try anything before posting?
Yes, I tried it as you describe above, it does not work. The resulting
output only returns the original string without the random number
prior to it.
>
>this doesn't guarantee uniqueness though, and neither does your
>attempt. It just makes it very likely that it is unique.
Understood, thank you for your reply.
Mark
------------------------------
Date: Tue, 01 Dec 1998 20:30:57 GMT
From: mark@doddx.com (Mark D.)
Subject: Re: Strip and add, perl style
Message-Id: <3665514b.12629734@news.supernews.com>
>Mark D. <mark@doddx.com> wrote:
>: I havent been able to figure this one out and I was hoping someone
>: could help me along- I want to simplify the string below and then have
>: it append a 5 digit random number to the string. How is this possible?
>
>: $cgi_client{'foo'} =~ s/\s+//g;
>: $cgi_client{'foo'} =~ s/\&//;
>: $cgi_client{'foo'} =~ s/\.html//;
>: $cgi_client{'foo'} =~ s/\)//;
>: $cgi_client{'foo'} =~ s/\(//;
>
>: The code above strips the string of all spaces, ampersands, .html,
>
>No it doesn't. It will strip all spaces, but will only strip the first
>occurrence of any of the other junk.
Ha, you are right. sorry.
>
>$cgi_client{foo} =~ s/[&()\s]|\.html//gi;
>
>1) Literal hash keys don't need to be quoted.
>
>2) I assume you want '.HTML', '.HtMl', etc. to be stripped as well, thus
>the 'i' modifier.
Yes, that is indeed what I meant. I was basically unsure of how to
have multiple items within a single line. Thank you for your
sugeestion, I will try it.
>
>: and brackets. It is used in an upload routine and I want to ensure the
>: file name is truly unique as well.
>:
>: srand( time() ^ ($$ + ($$ << 15)) );
>: $cgi_client{'foo'} = $cgi_client{'foo'} . (int(rand(100000)) + 1);
>
>: This adds a random number to the end of a string. how do I add it to
>: the beginning instead?
>
>Just reverse the order of the operands to '.'
That's what I assumed, but it does not work. as written above it
appends the number to the end of the string; when reversed, as you
suggest, it merely returns the original string value without the
number. I just verified it again to make sure I didn't do a typo.
>
>: Sorry if this is not up to speed, I'm a newbie.
>
>Taking a look at the perlre and perlop (man pages || POD || HTML) will
>speed up your denewbification.
Thank you for your reply!
Mark
------------------------------
Date: Tue, 01 Dec 1998 21:04:13 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Strip and add, perl style
Message-Id: <hRY82.8$Fn3.56@nsw.nnrp.telstra.net>
In article <3664501d.12327632@news.supernews.com>,
mark@doddx.com (Mark D.) writes:
> On Tue, 01 Dec 1998 05:49:50 GMT, mgjv@comdyn.com.au (Martien
> Verbruggen) wrote:
>>$cgi_client{'foo'} = (int(rand(100000)) + 1) . $cgi_client{'foo'};
>>
>>Did you try anything before posting?
>
> Yes, I tried it as you describe above, it does not work. The resulting
> output only returns the original string without the random number
> prior to it.
Does not work?
> perl
$aa{foo} = "aabb";
$aa{foo} = (int(rand(100000)) + 1) . $aa{foo};
print "$aa{foo}\n";
__END__
15156aabb
>
It does work for me. Is there maybe something wrong with your perl?
Although I can't imagine what would cause the . operator to work in
the case you mention, and not in the case I describe.
Even without the outermost parentheses it should still work, since +
and . have the same precedence, but I'd leave them in place.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | I took an IQ test and the results were
Commercial Dynamics Pty. Ltd. | negative.
NSW, Australia |
------------------------------
Date: Tue, 01 Dec 1998 21:40:51 GMT
From: mark@doddx.com (Mark D.)
Subject: Re: Strip and add, perl style
Message-Id: <36666128.16691059@news.supernews.com>
Yes, it doesn't work on my system. I've got 5.04 installed, here's my
results:
$cgi_client{'foo'} = "test test again.gif";
srand( time() ^ ($$ + ($$ << 15)) );
$cgi_client{'foo'} = (int(rand(100000)) + 1) . $cgi_client{'foo'};
$cgi_client{'foo'} =~ s/[&()\s]|\.html//gi;
print "$cgi_client{'foo'}\n";
__END__
testtestagain.gif
I'm not sure what's going on. :(
On Tue, 01 Dec 1998 21:04:13 GMT, mgjv@comdyn.com.au (Martien
Verbruggen) wrote:
>In article <3664501d.12327632@news.supernews.com>,
> mark@doddx.com (Mark D.) writes:
>> On Tue, 01 Dec 1998 05:49:50 GMT, mgjv@comdyn.com.au (Martien
>> Verbruggen) wrote:
>
>>>$cgi_client{'foo'} = (int(rand(100000)) + 1) . $cgi_client{'foo'};
>>>
>>>Did you try anything before posting?
>>
>> Yes, I tried it as you describe above, it does not work. The resulting
>> output only returns the original string without the random number
>> prior to it.
>
>Does not work?
>
>> perl
>$aa{foo} = "aabb";
>$aa{foo} = (int(rand(100000)) + 1) . $aa{foo};
>print "$aa{foo}\n";
>__END__
>15156aabb
>>
>
>It does work for me. Is there maybe something wrong with your perl?
>Although I can't imagine what would cause the . operator to work in
>the case you mention, and not in the case I describe.
>Even without the outermost parentheses it should still work, since +
>and . have the same precedence, but I'd leave them in place.
>
>Martien
------------------------------
Date: Tue, 1 Dec 1998 21:17:09 -0000
From: "Todd R Koning" <army.tennis@lineone.net>
Subject: Substitute
Message-Id: <_6Z82.628$If.63@news-reader.bt.net>
Can anybody tell me why this script does not work? I have checked that
"tourndata.txt" does exist, and is in the same directory as the script.
What am I missing?
#!/usr/bin/perl -w
open(DATA, ">>tourndata.txt") || die "cannot open tourndata.txt: $!";
while (<DATA>) {
s/~/|/g;
}
close(DATA) || die "can't close tourndata.txt: $!";
Cheers
Tim
------------------------------
Date: Wed, 02 Dec 1998 08:36:25 +1100
From: Erik de Castro Lopo <erikd@zip.com.au>
Subject: Re: Substitute
Message-Id: <36646159.3FDB5FE3@zip.com.au>
Todd R Koning wrote:
>
> Can anybody tell me why this script does not work? I have checked that
> "tourndata.txt" does exist, and is in the same directory as the script.
> What am I missing?
>
> #!/usr/bin/perl -w
>
> open(DATA, ">>tourndata.txt") || die "cannot open tourndata.txt: $!";
>
> while (<DATA>) {
You are trying to read from a file you have open
for append/write.
Erik
--
+-------------------------------------------------+
Erik de Castro Lopo erikd@zip.com.au
+-------------------------------------------------+
With 22,100,000 legitimate businesses in the US alone,
allowing each to send only one UCE per *year* gets every
mailbox 60,547 emails per day. There will either be email
without UCE or there will be no email.
------------------------------
Date: 1 Dec 1998 21:09:31 GMT
From: "lferon" <lferon@ifrance.com>
Subject: System()
Message-Id: <01be1d6f$9b896240$d7b1fcc1@toto.wanadoo.fr>
Hi, The System function does not work with CGI. Why????
------------------------------
Date: 1 Dec 1998 21:29:08 GMT
From: eln@cyberhighway.net (Erik)
Subject: Re: System()
Message-Id: <741n34$adj$1@news.cyberhighway.net>
In article <01be1d6f$9b896240$d7b1fcc1@toto.wanadoo.fr>,
"lferon" <lferon@ifrance.com> writes:
> Hi, The System function does not work with CGI. Why????
Because there is no System() function. Perhaps you mean "system"?
It works okay for me...what are you trying to do?
Post the smallest bit of code you can that exhibits the problem,
what you expected it to do, and what it actually did do, and maybe we can
help you more.
--
Erik Nielsen, Cyberhighway Internet Services NOC
Just don't create a file called -rf. :-)
-- Larry Wall in <11393@jpl-devvax.JPL.NASA.GOV>
------------------------------
Date: Tue, 01 Dec 1998 16:29:09 -0500
From: John Chambers <jc@eddie.mit.edu>
Subject: Re: System()
Message-Id: <36645FA5.E67E61E2@eddie.mit.edu>
lferon wrote:
>
> Hi, The System function does not work with CGI. Why????
Well, I use it all the time. What's your problem, fella?
Actually, I could make a few guesses. It's often rather
surprising what the server gives you as $ENV{PATH}. You
should make sure this is correct for your applications.
The best approach is probably to just forget about the
value passed to your script, and overwrite it with what
you know to be the correct path.
The other likely problem is that the CGI script is run
with permissions that may surprise you. It's typical
that anything called by a CGI script needs to be world
execable.
You might also be surprised to discover what directory
your script is running in. Have it tell you, and insert
a call of chdir to get it to where it needs to be.
------------------------------
Date: Tue, 01 Dec 1998 13:55:35 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Terribly simply perl question about qw()
Message-Id: <fl_aggie-0112981355350001@aggie.coaps.fsu.edu>
In article <741dop$7f8@tekka.wwa.com>, chadbour@news.wwa.com (James
Weisberg) wrote:
+ However, I would have checked the docs if
+ indeed I had them to look at from where I was hacking.
Any (distribution|installation) that does not include the on-line doc
set is broken. Complain to the appropriate authorities.
James
------------------------------
Date: Tue, 01 Dec 1998 14:59:55 -0500
From: alecler@cam.org (Andre L.)
Subject: Re: Terribly simply perl question about qw()
Message-Id: <alecler-0112981459550001@dialup-714.hip.cam.org>
In article <7418et$3b6@tekka.wwa.com>, chadbour@news.wwa.com (James
Weisberg) wrote:
[...]
> #!/usr/local/bin/perl
>
> $one = "foo";
> $two = "bar";
> @string = qw($one $two);
> print "string: @string\n";
> foreach $id (@string) {
> print "id: $id\n";
[...]
>
> Why aren't the variables interpolated inside the qw() function?
Maybe you meant,
@string = ($one, $two); # an array composed of those 2 strings.
HTH,
Andre
------------------------------
Date: Tue, 1 Dec 1998 21:32:36 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Terribly simply perl question about qw()
Message-Id: <F3B2ID.KIL@world.std.com>
chadbour@news.wwa.com (James Weisberg) writes:
> After receiving many [not-so] cordial invitations to RTFM, I
>thank all who replied. I suppose this is testimony to the level of
>support found here. However, I would have checked the docs if
>indeed I had them to look at from where I was hacking.
I'm sorry if you felt some of the replies were harsh. Unfortunately,
the more and more people start using comp.lang.perl.misc, the more
people who either don't have, can't find, or can't navigate through
the documentation. And then we have a newsgroup littered with
questions that the people have read the documentation already know,
followed by answers with varying degrees of correctness.
Don't take it personally. You're experiencing about four years of
built up fustrations. But don't think the people doing the flaming
enjoy this any more than you enjoy getting flamed. Some of them have
spend a huge amount of time with hopefully more productive remedies.
For example, many people have converted the perl documentation to
alternate file formats, hoping that if someone prefers HTML, PDF,
Info, Newtonbook, man, Postscript, ASCII or some other format, they
will be more likely to consult the docs. Some of them are at
<URL:http://www.perl.com/CPAN/manual/>
CPAN sites have the documentation online as a set of HTML pages, check
<URL:http://www.perl.com/CPAN/doc/manual/html/pod/perl.html> and the
links that go off from there.
Others have spent time trying to improve the documentation when the
see areas that are missing or confusing.
These people are all doing this in hopes that when someone has a
question that can be unequivocally answered in one of the standard
reference works, they will avoid asking them on Usenet, which
unfortunately requires human intervention.
> As for your question, I expected variables to be interpolated
>because in my scanning through some of the libraries, I saw many
>instances of lines like the following:
> @EXPORT = qw(&GetOptions $REQUIRE_ORDER $PERMUTE $RETURN_IN_ORDER);
I'm sorry if this is viewed as picking on you, but I find it slightly
amusing that when you saw what qw() did do, you assumed that you were
right, the interpreter was wrong, and used as proof to yourself a code
snippet which you didn't understand. Oh well, I'm told hubris is a
virtue.
Are you the type of person that can remember things through anecdotes
better then plain dry facts? If so, you might be interested in knowing
that qw() was added to the lanuage because traditional way of creating
import or export lists grew to be tedious with all their parens,
quotes and commas.
@EXPORT = ('&GetOptions', '$REQUIRE_ORDER', '$PERMUTE', '$RETURN_IN_ORDER');
@EXPORT needs to know the subroutines, scalars, etc. to export, not
their values. Interpolation would ruin things.
--
Andrew Langmead
------------------------------
Date: 30 Nov 1998 11:03:01 -0500
From: Dean Pentcheff <dean2@darwin.biol.sc.edu>
Subject: Re: to dbm or not to dbm?
Message-Id: <m3hfvhb22y.fsf@darwin.biol.sc.edu>
moseley@best.com (Bill Moseley) writes:
> I working on a web-based workshop registration cgi script in Perl -- multiple
> workshops, multiple times and locations, and so on. A bunch of it will be
> relational, of course. I'll want to do lookups by name, by workshop dates, and
> by workshop location, for example.
>
> My question is: when does it make sense to use dbm file(s) instead of keeping
> just plain text files (and filling related hashes when the script runs from the
> text files)?
>
> And if I use dbm, does it make sense, speed wise, to use one or just a few
> files, or use a separate file for each record structure? (I'm an old Pascal
> programmer that's used to building the files all by record structure.)
>
> I want a fast method so I'm not holding the files open for very long.
>
> Vague question, I know, but I'm looking for some general design guidelines.
If your searches can be done directly using the keys of a hash (or
dbm), then that's probably a win: you don't need to code the searching
and you get fast lookups. If, on the other hand, you'll end up
clawing through all of the keys (or values) with some sort of regexp
search anyway, then the hash may not buy you much. For example, if
you want to be able to search on partial names, then you can't
directly use a hash keyed on names: you'll need to fetch all the keys
to search for the partial name.
On the other hand... if that sort of searching is infrequent, but
insertions and deletions based on exact keys are frequent, the time
loss in occasionally clawing through the whole hash may not matter
much.
In terms of open files, make sure you check into file locking with
Perl (see the Perl FAQ at http://www.perl.org). No matter how quick
you are with the files, you'll get bitten with an overwrite sometime
if you don't lock.
> Thanks,
You're welcome - have fun!
-Dean
--
N. Dean Pentcheff <dean2@mail.biol.sc.edu>
Biological Sciences, Univ. of South Carolina, Columbia SC 29208 (803-777-7068)
------------------------------
Date: Tue, 01 Dec 1998 19:39:18 GMT
From: Randal Schwartz <merlyn@stonehenge.com>
Subject: Re: Using RCS in Perl scripts
Message-Id: <8c67bvhctk.fsf@gadget.cscaper.com>
>>>>> "Chris" == Chris N Hinds <chris.hinds@arm.com> writes:
Chris> Two questions:
Chris> 1. How can the RCS markers (such as $Revision$) be used in
Chris> Perl? I can't seem to find a way to do the following:
Chris> print("$Revision$\n") ;
Chris> The additional $ at the end of the string causes a syntax
Chris> error here and in other attempts, such as creating a
Chris> scalar with the string and regexp-ing out the '$'.
My favorite trick (and I can't remember where I saw it, but it
wasn't my idea) is:
my $VERSION_ID = q$Id: proxy,v 1.21 1998/11/15 20:05:06 merlyn Exp $;
my $VERSION = (qw$Revision: 1.21 $ )[-1];
and then I can use $VERSION as "1.21". Cool.
Chris> 2. RCS doesn't maintain the 'execute' mode on the script.
Chris> Is there a way to keep it after a ci -u operation?
Odd. It works for me. Make sure your ",v" file is the same mode
as what you want the co (or ci -u) to be.
print "Just another Perl RCS user,"
--
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: 01 Dec 1998 21:15:23 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: Using RCS in Perl scripts
Message-Id: <912547001.485655@thrush.omix.com>
Randal Schwartz <merlyn@stonehenge.com> wrote:
>snip<
: My favorite trick (and I can't remember where I saw it, but it
: wasn't my idea) is:
:
: my $VERSION_ID = q$Id: proxy,v 1.21 1998/11/15 20:05:06 merlyn Exp $;
: my $VERSION = (qw$Revision: 1.21 $ )[-1];
:
: and then I can use $VERSION as "1.21". Cool.
Which, if you're using $VERSION in a module, will break
UNIVERSAL::VERSION(), as 1.10 is seen as lower then 1.9, nore will
it won't do anything useful if you branch to a 1.2.3.4 style.
This is a little long, but it gets the job done nicely:
$VERSION = do { sprintf '%d.%03d'.'%02d' x ($#r-1), (q$Revision: 2.10 $ =~ /\d+/g) };
It's a modified version of something I also picked up from someone
else. Adjust the %d formats if you use more or less sub revisions.
--
-Zenin (zenin@archive.rhps.org) From The Blue Camel we learn:
BSD: A psychoactive drug, popular in the 80s, probably developed at UC
Berkeley or thereabouts. Similar in many ways to the prescription-only
medication called "System V", but infinitely more useful. (Or, at least,
more fun.) The full chemical name is "Berkeley Standard Distribution".
------------------------------
Date: Tue, 01 Dec 1998 16:16:06 -0500
From: John Chambers <jc@eddie.mit.edu>
Subject: Why is "... @foo ..." occasionally a syntax error?
Message-Id: <36645C96.430B1AA3@eddie.mit.edu>
A long stint of digging thru TFM and TFFAQ should surely have
discovered this one, but if it's there, I can't guess the right
keywords, so I'll break down and ask ...
My code has lots and lots of examples of using an array inside
a string, as in "... @foo ...", and it almost always does just
what TFM says: It interpolates the values of the array's values,
separated by the $" string. But I just spent most of a day trying
to find why a subprocess of a of a subprocess of a CGI script was
evaporating, and at long last tracked it down to the message:
In string, @resource now must be written as \@resource at ralsched.pm line 414, near "@resource"
This was a fatal syntax error. Here's the offending line:
$extra = "@resource" if ($typ eq 'lab');
There doesn't seem anything special here. @resource has been
used happily by the code, and things like $resource[1] give the
correct value. $typ is a char string (sometimes 'lab' and at
other times something else). There doesn't seem anything the
least bit tricky about this instruction. But it's a fatal error,
and the problem was fixed when I rewrote it:
$extra = join(' ',@resource) if ($typ eq 'lab');
This solves this particular case, but it isn't extenable to
cases where you want other junk inside the quotes. Well, I
guess it is, but it takes a bunch of extra code and at least
one temp variable, so it's not what you'd call an elegant way
to solve the problem.
Higher up in the same file, there are several examples of @foo
inside a double-quoted string, such as:
VM("$id: list=(@list)") if $V>3;
None of the others seems to cause any problems for perl, just
the one.
Any clues? Why is this construct usually legal, but sometimes
illegal? Does it depend on some magic that I can't guess? Is
it documented somewhere that I can't find?
There are certainly places in TFM that imply that it should be
legal. For example, in "man perldata" we find, without any sort
of qualifications, the statement:
... The following are equivalent:
$temp = join($",@ARGV);
system "echo $temp";
system "echo @ARGV";
Anyone know the answer? Is this a compiler bug?
(This is perl, version 5.004_04 built for alpha-dec_osf)
------------------------------
Date: 1 Dec 1998 21:42:19 GMT
From: eln@cyberhighway.net (Erik)
Subject: Re: Why is "... @foo ..." occasionally a syntax error?
Message-Id: <741nrr$adj$2@news.cyberhighway.net>
In article <36645C96.430B1AA3@eddie.mit.edu>,
John Chambers <jc@eddie.mit.edu> writes:
> This was a fatal syntax error. Here's the offending line:
>
> $extra = "@resource" if ($typ eq 'lab');
Interesting...the only way I'm able to reproduce this error is if @resource
is not defined at this point. Is this perhaps in a part of the code where
@resource is out of scope? Maybe @resource is a my() variable in another
block, and is not inherited by this block? Perhaps it's declared local in
another block? When you use the join() syntax you describe below, does
$extra contain anything? list values? the empty string?
Perl will correctly interpolate "@array", unless it cannot find
a variable anywhere called @array, in which case it assumes you mean the
literal "@" character, followed by the literal string "array", and advises
you that the "@" character needs to be escaped to print.
> There doesn't seem anything special here. @resource has been
> used happily by the code, and things like $resource[1] give the
> correct value. $typ is a char string (sometimes 'lab' and at
When does $resource[1] give the correct value? Within the same block?
What does print "$resource[1]" give you if it's placed immediately
above the assignment statement?
> $extra = join(' ',@resource) if ($typ eq 'lab');
>
> This solves this particular case, but it isn't extenable to
> cases where you want other junk inside the quotes. Well, I
> guess it is, but it takes a bunch of extra code and at least
> one temp variable, so it's not what you'd call an elegant way
> to solve the problem.
Well, no, all it requires is something like:
$extra = "string" . join(' ',@resource) . "string";
But that's not really the point here.
> Higher up in the same file, there are several examples of @foo
> inside a double-quoted string, such as:
>
> VM("$id: list=(@list)") if $V>3;
>
> None of the others seems to cause any problems for perl, just
> the one.
Are they all in the same block? Higher up in the file doesn't mean
anything if they're in a completely different block (such as a different
subroutine).
> Any clues? Why is this construct usually legal, but sometimes
> illegal? Does it depend on some magic that I can't guess? Is
> it documented somewhere that I can't find?
It's always legal, provided the array exists.
> Anyone know the answer? Is this a compiler bug?
I seriously doubt it.
HTH!
--
Erik Nielsen, Cyberhighway Internet Services NOC
But I know what's important to me, and what isn't. And I think I know what
people can get used to, and what they can even learn to like. (It just takes
some people longer than others. :-)
-- Larry Wall in <199809230518.WAA19312@wall.org>
------------------------------
Date: Tue, 01 Dec 1998 21:48:17 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Why is "... @foo ..." occasionally a syntax error?
Message-Id: <BuZ82.22$Fn3.56@nsw.nnrp.telstra.net>
In article <36645C96.430B1AA3@eddie.mit.edu>,
John Chambers <jc@eddie.mit.edu> writes:
> In string, @resource now must be written as \@resource at ralsched.pm line 414, near "@resource"
# perldoc perldiag
[snip]
In string, @%s now must be written as \@%s
(F) It used to be that Perl would try to guess whether
you wanted an array interpolated or a literal @. It did
this when the string was first used at runtime. Now
strings are parsed at compile time, and ambiguous
instances of @ must be disambiguated, either by
prepending a backslash to indicate a literal, or by
declaring (or using) the array within the program before
the string (lexically). (Someday it will simply assume
that an unbackslashed @ interpolates an array.)
[snip]
You say that @resource has been happily used by the code, but are you
sure of that? In any case, it is never a bad idea to run with 'use
strict' and to declare all your variables. if you do, you shouldn't
see this message.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | A Freudian slip is when you say one
Commercial Dynamics Pty. Ltd. | thing but mean your mother.
NSW, Australia |
------------------------------
Date: 12 Jul 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 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
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 4335
**************************************