[13742] in Perl-Users-Digest
Perl-Users Digest, Issue: 1152 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 22 15:05:31 1999
Date: Fri, 22 Oct 1999 12:05:14 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <940619113-v9-i1152@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Fri, 22 Oct 1999 Volume: 9 Number: 1152
Today's topics:
Re: Card shuffling (Dan Wilga)
Re: Cookie-Problem with IE 4.0 <rootbeer@redcat.com>
Re: crypt function <lr@hpl.hp.com>
Re: Expr or block as 1st param: Compiler magic needed? <jon@midnightbeach.com>
Re: File "cgi-lib.pl" not found in @INC? KernelKlink@webtv.net
Re: Help substituting '/' ? <lr@hpl.hp.com>
Re: Help substituting '/' ? <aqumsieh@matrox.com>
Re: Help substituting '/' ? (Michael Budash)
Re: How do you split a string into fixed sized pieces? (Joe Petolino)
Re: How do you split a string into fixed sized pieces? <lr@hpl.hp.com>
Re: How to cut away decimals <newsposter@cthulhu.demon.nl>
Re: How to cut away decimals <ak@dasburo.de>
I'd like to know what are those CGIs and ASPs <prophile@netvision.net.il>
Re: Ignore the idiots <jon@midnightbeach.com>
Re: in need of example... (Randal L. Schwartz)
Re: Is @INC lying to me? <rootbeer@redcat.com>
Re: New short cut assignment operators? <lr@hpl.hp.com>
Re: Newbie needs help with script! Should be easy for a <lr@hpl.hp.com>
Re: Newbie needs help with script! Should be easy for a <CSRA@tci.telus.com>
Re: newbie problem writing/reading a file <laurensmith@sprynet.com>
Re: Perl and shadow passwords <rootbeer@redcat.com>
Re: Perl Exam Beta Testers Required - How good are you? <marcel.grunauer@lovely.net>
PostgreSQL interfaces (Jana Cole or John Sayre)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 22 Oct 1999 14:34:20 -0400
From: dwilgaREMOVE@mtholyoke.edu (Dan Wilga)
Subject: Re: Card shuffling
Message-Id: <dwilgaREMOVE-2210991434210001@wilga.mtholyoke.edu>
In article <38108BD7.4915FA02@earthlink.net>, andrew_lee
<andrew_lee@earthlink.net> wrote:
> Mikko Saari wrote:
>
> > I need a perl script to handle decks of cards. My first and most obvious
> > problem is shuffling, a problem which has bothered me previously. How do I
> > arrange an array in random order?
> >
>
> I am assuming that your issue is one of finding a 'good' random number
> generator.
What's wrong with the rand() function that is built-into Perl? While it's
probably not as random as most statisticians would like, it's probably
adequate for most things.
I think all the original poster was looking for is a quick script to take
an array and shuffle the elements randomly. This would do the trick,
though probably not optimally:
my @deck = ();
# populate the deck with your cards in indices 0..51 at this point
# shuffle
my $i;
for( $=0; $i<500; $i++ ) {
my( $card1, $card2 ) = ( int(rand(52)), int(rand(52)) );
my $temp = $deck[$card1];
$deck[$card1] = $deck[$card2];
$deck[$card2] = $temp;
}
You can, of course, change the number 500 to be anything you want, but 500
should be fairly likely not to leave any one card unmoved.
Dan Wilga dwilgaREMOVE@mtholyoke.edu
** Remove the REMOVE in my address address to reply reply **
------------------------------
Date: Fri, 22 Oct 1999 11:18:10 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Cookie-Problem with IE 4.0
Message-Id: <Pine.GSO.4.10.9910221117420.29843-100000@user2.teleport.com>
On Wed, 20 Oct 1999, Christoph Kuhlage wrote:
> On IE 5.0 and Netscape 4.x it works fine but on
> IE 4.x id doesn=B4t.
If you're following the proper protocol but some browser or server doesn't
cooperate, then it's the other program's fault. If you're not following
the protocol, then it's your fault. If you aren't sure about the protocol,
you should read the protocol specification. If you've read it and you're
still not sure, you should ask in a newsgroup about the protocol.
Hope this helps!
--=20
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Fri, 22 Oct 1999 10:49:51 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: crypt function
Message-Id: <MPG.127a43986fc7c44498a0ff@nntp.hpl.hp.com>
In article <38109401.2AB4AC0E@dasburo.de> on Fri, 22 Oct 1999 18:42:41
+0200, Alexander Knack <ak@dasburo.de> says...
> Mohd Idaham wrote:
...
> > $salt = substr($etcpasswd, 0, 2);
> > if (crypt($userentered, $salt) ne $etcpasswd) {
> > die "Sorry...\n";
> > } else {
> > print "ok\n";
> > }
> >
> > This program will compare the entered password and the password inside
> > /etc/passwd. Eg: Assume the /etc/passwd value is hello99.
> > If user entered hello99123 or hello99bla..bla... the program will accept and
> > print ok.
Are you quite sure of that? The first eight characters are significant,
not seven.
> > Can anybody tell me why and how to overcome this.
> not exactly, but
> 1) passwords unter unix are max 8 chars long (hello99 are 7, i know ...)
Not exactly. The password can be any length, but only the first eight
characters enter into forming the encryption. This is 'well known', but
I haven't found it documented in `perldoc -f crypt` or in `man 3 crypt`
or in `man 1 crypt`.
> 2) use if (crypt($userentered, $etcpasswd) ne $etcpasswd)) {
> instead of what you've did above.
That is trivially more efficient, but doesn't change the behavior. Only
the first two characters of the 'salt' string are used.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 22 Oct 1999 11:28:18 -0700
From: Jon Shemitz <jon@midnightbeach.com>
Subject: Re: Expr or block as 1st param: Compiler magic needed?
Message-Id: <3810ACC2.A921BFCF@midnightbeach.com>
Larry Rosler wrote:
> I hate to reward you for submitting the identical post twice in two
> days. But I thought the question was instructive the first time I saw
> it, and hadn't had time to put together and test a solution. So here
> goes anyway. Next time, please show a little more patience.
I'm sorry! I really am. I didn't notice that I was reposting only a day
after the first post: sometimes my time sense is based more on how often
I stop to check mail and news than on how often I stop to sleep.
The pattern I've seen in other busy newsgroups has been that if a
question isn't answered by the Usual Suspects pretty much right away, it
isn't going to get answered. Usually that means one of three things: No
one knows the answer; the question is too dumb to be bothered with; or
no one even looked at the body because the subject wasn't catchy in the
right way. Based on what I've seen of the Perl community and this
newsgroup so far, I couldn't imagine the first was true; I hoped the
second wasn't; so I renamed it.
(Maybe, with practice, I'll get as laconic as y'all. Most of my writing
over the past decade or so, though, has been aimed at people who will
*not* take the time to figure out what you mean but *will* grab every
opportunity to misunderstand you.)
> > returned a simple boolean scalar, rather than a list of all matches.
>
> In scalar context, grep() returns the number of matches, not the list of
> all matches.
I know that that's the effect - but is that what 'really' happens?
Reverse engineering, I assume that there is only one grep primitive,
which always returns a list, and the scalar context pretty much comes
down to slapping an implicit "scalar" in front of the grep, to get the
list length.
> perlfaq4: "How can I tell whether a list or array
> contains a certain element?"
Hmm, I didn't even look in the FAQ for that - just too obvious how to do
it. But thanks for the pointer - I'd skimmed right over the description
of "vec" in the camel book without really registering it.
> > Is it possible to do what I want, here? Or does this sort of overloading
> > rely on compiler magic?
>
> Yes. No.
>
> Here is a simple single function that does what you want. I refuse to
> name it with jaggy caps, though. Those belong to Java, not here.
while (unconverted) {print "Perl culture.\n";}
- but though in my younger days I was a big fan of alllowercase, I've
really come to think that MixedCase is much more legible. I actually
think the javaStyle is anAbomination and hateTheWayYouHaveTo use a
stupid convention to use Java class libraries; anyExpr and anyBlock were
artifacts of splitting my first any into two pieces. But that's
irrelevant.
> sub any_expr_or_block {
> defined(my $match = shift) or
> die "\nNo first argument.\n";
> unless (ref $match) {
> foreach (@_) { return 1 if m/$match/; }
> } elsif (ref $match eq 'CODE') {
> foreach (@_) { return 1 if &$match; }
> } else {
> die "\nFirst argument must be an expr or a block.\n"
> }
> return 0;
> }
>
> print any_expr_or_block(qw(foo foobar)), "\n";
> print any_expr_or_block(qw(foo baz)), "\n";
> print any_expr_or_block(sub { /foo/ }, qw(foobar)), "\n";
> print any_expr_or_block(sub { /foo/ }, qw(baz)), "\n";
Thanks, that's actually pretty similar to my first any(), which gives me
warm fuzzies. However, grep and map let you say either of
grep /foo/, @bar
grep {m/foo/} @bar
and that's the syntax that I was unable to get with my any().
--
http://www.midnightbeach.com - Me, my work, my writing, and
http://www.midnightbeach.com/hs - my homeschool resource pages
------------------------------
Date: Fri, 22 Oct 1999 12:08:53 -0400 (EDT)
From: KernelKlink@webtv.net
Subject: Re: File "cgi-lib.pl" not found in @INC?
Message-Id: <28490-38108C15-36@storefull-215.iap.bryant.webtv.net>
Andrew wrote:
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
I recommend getting rid of cgi-lib.pl and upgrading to CGI.pm -- it's a
much better module and is still being supported. You'll have to rewrtie
your CGI scripts, however. For the benefit of the original poster, not
much rewriting need be involved, thanks to CGI.pm's "pretend to be
cgi-lib.pl" mode. Just replace your:
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0require "cgi-lib.pl";
with:
=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0use CGI qw(:cgi-lib);
and Bob's your proverbial close relation. Nothing else need be changed
in your script.
Cheers,
Andrew.
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
When following the recommendation above,does the cgi-lib.pl file still
need to be present along with CGI.pm? Also, is ANY script that is a
valid usable script with cgi-lib.pl going to be usable with "use CGI
qw(:cgi-lib);" ?
------------------------------
Date: Fri, 22 Oct 1999 10:11:21 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Help substituting '/' ?
Message-Id: <MPG.127a3a903e0239ef98a0fc@nntp.hpl.hp.com>
In article <380F8FDC.EE10C402@home.com> on Thu, 21 Oct 1999 22:12:33
GMT, Rick Delaney <rick.delaney@home.com> says...
> Sebastian wrote:
> >
> > $line =~ s!/!!g;
> > $line =~ s=/==g;
> > $line =~ s?/??g;
> > You can use any non-alphanumeric, non-whitespace delimiters you want.
>
> You can use alphanumeric delimiters.
>
> $line =~ s g/ggg;
>
> You can also use the quicker op.
>
> $line =~ y d/ddd;
You'd better not leave out the space in either of those constructs!
But where is this behavior documented? The only statement about the
delimiters in perlop (under s///) reads:
Any non-alphanumeric, non-whitespace delimiter may replace the
slashes.
There is no statement at all under tr///.
So there is surely an error here, either in the documentation or in the
overly-liberal implementation.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 22 Oct 1999 11:18:08 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Help substituting '/' ?
Message-Id: <x3yk8of8lw0.fsf@tigre.matrox.com>
Rick Delaney <rick.delaney@home.com> writes:
> Sebastian wrote:
> >
> > $line =~ s!/!!g;
> > $line =~ s=/==g;
> > $line =~ s?/??g;
> > You can use any non-alphanumeric, non-whitespace delimiters you want.
>
> You can use alphanumeric delimiters.
>
> $line =~ s g/ggg;
>
> You can also use the quicker op.
>
> $line =~ y d/ddd;
Damn. I didn't know that! perlop certainly doesn't say so:
If "/" is the delimiter then the initial m is
optional. With the m you can use any pair of non-
alphanumeric, non-whitespace characters as
delimiters. This is particularly useful for matching
Unix path names that contain "/", to avoid LTS
(leaning toothpick syndrome). If "?" is the
delimiter, then the match-only-once rule of
?PATTERN? applies. If "'" is the delimiter, no
variable interpolation is performed on the PATTERN.
Is this a secret? Why isn't it documented?
It will sure make my JAPH's a lot more interesting :)
--Ala
#!/usr/local/bin/perl -w
# a simple program to print "Just another Perl hacker, "
open _,$0and<_>and$_=<_>and s o.*\o ooo and eval;
------------------------------
Date: Fri, 22 Oct 1999 12:01:09 -0700
From: mbudash@sonic.net (Michael Budash)
Subject: Re: Help substituting '/' ?
Message-Id: <mbudash-2210991201090001@adsl-216-103-91-123.dsl.snfc21.pacbell.net>
In article <MPG.127a3a903e0239ef98a0fc@nntp.hpl.hp.com>, Larry Rosler
<lr@hpl.hp.com> wrote:
>In article <380F8FDC.EE10C402@home.com> on Thu, 21 Oct 1999 22:12:33
>GMT, Rick Delaney <rick.delaney@home.com> says...
>> Sebastian wrote:
>> >
>> > $line =~ s!/!!g;
>> > $line =~ s=/==g;
>> > $line =~ s?/??g;
>> > You can use any non-alphanumeric, non-whitespace delimiters you want.
>>
>> You can use alphanumeric delimiters.
>>
>> $line =~ s g/ggg;
>>
>> You can also use the quicker op.
>>
>> $line =~ y d/ddd;
>
>You'd better not leave out the space in either of those constructs!
>
>But where is this behavior documented? The only statement about the
>delimiters in perlop (under s///) reads:
>
> Any non-alphanumeric, non-whitespace delimiter may replace the
>slashes.
>
another point to remember is documented via the camel p.42 and in perlop:
If the PATTERN is delimited by
bracketing quotes, ...
(paren, bracket, brace, angle bracket)
... the REPLACEMENT has its own
pair of quotes, which may or may not be bracketing
quotes, e.g., s(foo)(bar) or s<foo>/bar/.
and only via the camel p.42 (afaict):
White space is allowed between the two inner quote
characters, so you could write...:
tr [a-z]
[A-Z];
hth-
--
Michael Budash ~~~~~~~~~~ mbudash@sonic.net
------------------------------
Date: 22 Oct 1999 17:21:11 GMT
From: petolino@joe.Eng.Sun.COM (Joe Petolino)
Subject: Re: How do you split a string into fixed sized pieces?
Message-Id: <7uq6e7$15k$1@engnews2.Eng.Sun.COM>
lt lindley <lee.lindley@bigfoot.com> wrote:
>Neko <tgy@chocobo.org> wrote:
>:> @a = split /(?<=\G....)/s;
>Oh, COOL!!! When I first saw it I thought that it would bomb
>on one of the end cases, but it doesn't. I also thought
>that a m//g modifier would be required to make the \G work,
>but it is apparently implied by the split.
What is the general feeling about using undocumented obscure features
like this? The perlre documentation says that \G "works only with /g",
specifically "to chain global matches (using m//g)", from which one might
conclude that it doesn't work inside a split() pattern. You could say
"Oh yeah, split() must set the g-modifier internally", but then you're
presuming something about how split() was implemented. The only way you
could know that Neko's code would work is by experimenting with test
cases (well, I suppose you could pore over the source code instead). Is
it valid to conclude that if it works in perl 5.005_03, then it's part of
Perl the language?
I've just had a brief email exchange with Larry R. about a similar point
(coincidentally also involving split() ), and I thought my question would
be of general interest.
-Joe
------------------------------
Date: Fri, 22 Oct 1999 11:23:13 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: How do you split a string into fixed sized pieces?
Message-Id: <MPG.127a4b67398b755498a101@nntp.hpl.hp.com>
In article <7uq6e7$15k$1@engnews2.Eng.Sun.COM> on 22 Oct 1999 17:21:11
GMT, Joe Petolino <petolino@joe.Eng.Sun.COM> says...
> lt lindley <lee.lindley@bigfoot.com> wrote:
> >Neko <tgy@chocobo.org> wrote:
>
> >:> @a = split /(?<=\G....)/s;
>
> >Oh, COOL!!! When I first saw it I thought that it would bomb
> >on one of the end cases, but it doesn't. I also thought
> >that a m//g modifier would be required to make the \G work,
> >but it is apparently implied by the split.
>
> What is the general feeling about using undocumented obscure features
> like this? The perlre documentation says that \G "works only with /g",
> specifically "to chain global matches (using m//g)", from which one might
> conclude that it doesn't work inside a split() pattern. You could say
> "Oh yeah, split() must set the g-modifier internally", but then you're
> presuming something about how split() was implemented. The only way you
> could know that Neko's code would work is by experimenting with test
> cases (well, I suppose you could pore over the source code instead). Is
> it valid to conclude that if it works in perl 5.005_03, then it's part of
> Perl the language?
>
> I've just had a brief email exchange with Larry R. about a similar point
> (coincidentally also involving split() ), and I thought my question would
> be of general interest.
Here is the general part of the email:
J> I don't think that, in general, one can draw meaningful conclusions
J> about undocumented or under-documented features just by
J> experimentation - that's not how computer languages are supposed to
J> work.
L> I know how they are supposed to work. I worked for years as a leader
L> of the ANSI/ISO C Standards Committee, where many minds scrutinized
L> every word of the specification intensely. But Perl has no standard
L> (nor will it ever, I predict), and the scrutiny is ad hoc at best.
L> So to a large degree the language is what the implementation says it
L> is, particularly if there is only one, widely accepted,
L> implementation.
There is another current thread about the undocumented use of an
alphabetic character as a regex delimiter, though the documentation
explicitly says it must be non-alphanumeric. Is that a feature of the
language or a bug in the implementation or a bug in the documentation?
God (The Larry) Only Knows (and hasn't said, yet).
Language Lawyers of the world, unite! Perl needs you!
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 22 Oct 1999 17:05:49 GMT
From: Erik van Roode <newsposter@cthulhu.demon.nl>
Subject: Re: How to cut away decimals
Message-Id: <7uq5hd$4l1$1@internal-news.uu.net>
Acacia <acacia@online.no> wrote:
> I've checked the faq's, and could only find stuff about rounding the
> numbers...
> I need to cut away all decimals of any given number without rounding...
> for instance,
> 32.951251 --> 32
> does this have anything to do with int() ?
Yes. From the perlfunc manual page:
int EXPR
Returns the integer portion of EXPR. If EXPR is
omitted, uses $_.
Erik
------------------------------
Date: Fri, 22 Oct 1999 19:21:08 +0200
From: Alexander Knack <ak@dasburo.de>
To: Acacia <acacia@online.no>
Subject: Re: How to cut away decimals
Message-Id: <38109D04.C3DEB612@dasburo.de>
> 32.951251 --> 32
>
> does this have anything to do with int() ?
try
my $x = int (32.951251);
print $x;
:))
--
+--------------------------------------------------------------------+
| Alexander Knack ........Entropie erfordert keine Wartung .........|
| dasburo.de ..................................................|
+--------------------------------------------------------------------+
------------------------------
Date: Fri, 22 Oct 1999 18:30:19 GMT
From: Profisios <prophile@netvision.net.il>
Subject: I'd like to know what are those CGIs and ASPs
Message-Id: <s11b9rsbr0118@corp.supernews.com>
I'd like to know what are those CGI and ASP scirpts and what languages it
concerns.
Thanks in advance.
--
Posted via CNET Help.com
http://www.help.com/
------------------------------
Date: Fri, 22 Oct 1999 10:43:39 -0700
From: Jon Shemitz <jon@midnightbeach.com>
Subject: Re: Ignore the idiots
Message-Id: <3810A24B.A9A2E1CB@midnightbeach.com>
Greg Snow wrote:
> Jonathan Stowe <gellyfish@gellyfish.com> wrote:
> >
> >I dont believe we want any stuff posted that people only 'think' might
> >work - if you dont 'know' it works dont post it - there are confused
> >newbies cutting and pasting broken cargo cult code as it is and I dont
> >think that we should do anything to make this worse.
>
> Good point, I phrased that poorly, how about if it is changed to:
>
> ... a statement like "I'm not an expert yet, this soulution works
> for the example you gave, however there may be other solutions that are
> faster/more elegant/easier to understand/won't break on situations more
> complex than your example/etc."
That disclaimer is getting a little long, however I think the general
idea is good. People burn out on newgroups after a while: It takes a
true saint to patiently and thoroughly answer easy questions for years,
and this has never been a species noted for a preponderance of
beatitude. Relying on 'experts' to answer questions is a risky
proposition both because the pool keeps draining and because those
getting sucked into the vortex tend to be a bit, well, surly. But when
an 'advanced beginner' or an 'intermediate' Perl programmer spots a
question that she can answer (having perhaps just run into it herself)
both sides win: The questioner gets an answer that might well be pitched
at just about the right depth, and the answerer gets the benefit of
having written up her knowledge. ("I write to learn what I think.")
--
http://www.midnightbeach.com - Me, my work, my writing, and
http://www.midnightbeach.com/hs - my homeschool resource pages
------------------------------
Date: 22 Oct 1999 11:12:07 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: in need of example...
Message-Id: <m1emen9seg.fsf@halfdome.holdit.com>
>>>>> "Peter" == Peter J Kernan <pete@theory2.phys.cwru.edu> writes:
Peter> and to avoid 1)
Peter> my @files = grep -f,<*.jpg *.gif>;
No, the problem is when foo.jpg is a directory and you use ls *.jpg...
you get the CONTENTS of foo.jpg. This is nastier than simply
including in the list, which might be perfectly fine depending on the
original criteria. No grep needed on the glob.
print "Just another Perl hacker,"
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Fri, 22 Oct 1999 11:48:01 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Is @INC lying to me?
Message-Id: <Pine.GSO.4.10.9910221135590.29843-100000@user2.teleport.com>
On Thu, 21 Oct 1999, Nick Condon wrote:
> % make test
> perl -e 'use Test::Harness qw(&runtests $verbose); $verbose=0; runtests
> @ARGV;' t/*.t
> Can't locate loadable object for module Apache::Constants in @INC
> (@INC contains <..snip..> /usr/local/lib/perl5/5.005/sun4-solaris-thread
> <..snip>)
>
> % find /usr/local/lib/perl5 -name 'Constants*' -print
> /usr/local/lib/perl5/5.005/sun4-solaris-thread/Apache/Constants
> /usr/local/lib/perl5/5.005/sun4-solaris-thread/Apache/Constants.pm
>
> What's going on?
I'd say it's not finding the "loadable object". Are both of those files
readable, and are all of the relevant directories readable? Is your perl
going to look in sun4-solaris-thread? Is that module properly compiled and
installed for sun4-solaris-thread? (Have fun digging up the answers to
these questions!)
> (bandwidth wasting flames by email, please)
Okay, that too. :-)
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Fri, 22 Oct 1999 10:35:22 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: New short cut assignment operators?
Message-Id: <MPG.127a40334b8fb11198a0fe@nntp.hpl.hp.com>
In article <x3yln8v8n3b.fsf@tigre.matrox.com> on Fri, 22 Oct 1999
10:52:11 -0400, Ala Qumsieh <aqumsieh@matrox.com> says...
> email55555@aol.com (Email55555) writes:
> > For example :
> > We have $a -= $b; which is like $a = $a - $b;
> > And for $a = $b - $a; why not $a =- $b;
...
> Besides, there is a simple solution: $a += -$b
That results in the negative of the desired result, $b - $a.
> > Another example :
> > $a .= $b; ( it's like $a = $a . $b; )
> > Why not $a =. $b; (it's like $a = $b . $a; )
> > ... etc
> >
> > The space (or newline) between operator and operant is important to avoid
> > ambiguity,
The last time this subject came up, I suggested introducting unambiguous
operators by extending the operator to the left of the =:
--= //= %%= ..= <<<= >>>=
This avoid the syntactic problems that =op presents. But the proposal
got no support.
> > The choice of writing is open, maybe not =-, =/, =., =||, =&& ... etc maybe
> > !-=, !/=, !.=, ...etc or ...
That is another possibility, also better than =op, which simply won't
fly.
> > I do not want to complicate Perl, I'm just curious. If we invented -=, /=,
> > ...etc.
> > Why not the same for the converse?
If 'we' means 'Perl', not so. They were invented by 'C'.
> Those were invented for efficiency reasons.
>
> '$x += $y' is faster than '$x = $x + $y'.
All the more so if the left-hand operand is a function that can serve as
both an rvalue and an lvalue. The function (and its side effects) gets
invoked once only.
But until some of the Perl big guns get behind it, these reversed
assignment ops won't fly either.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 22 Oct 1999 11:08:27 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Newbie needs help with script! Should be easy for an expert.
Message-Id: <MPG.127a47f51f1ee2398a100@nntp.hpl.hp.com>
In article <01bf1cad$261fa030$54b2b28e@M26160> on 22 Oct 1999 16:47:25
GMT, CSRA <CSRA@tci.telus.com> says...
> This is my first time posting to this ng.
> I just started programming perl and I am already in trouble.
Who isn't? It comes with the territory. :-)
> I need help with the following problem
You will get more help if you leave the words 'newbie' and 'expert' out
of your Subject:, and provide something more descriptive.
> I need a script that scans a .txt file for an a character X then writes
> the previous 3 characters to a file.
> So basically I want to be able to scan through the entire document and
> every time an 'X' shows up, I want the previous 3 characters written to a
> file.
> The source file would appear as such:
>
> Hello_my_name_is_MrX.
> I_am_very_pleased_to_meet_you_X.
> I_have_excommunicated_you
You say 'X', but you mean 'X' or 'x'.
> So the new file when done would look something like this. I want the
> spacing in the new file equal and on the same line. its going to be
> imported into a database so
> I need the spacing right. (That is 2 spaces between writes)
>
> _Mr _ou e_e
>
> Can anyone help me out with this? I managed to successfully mess around
> with files and grep and reading and writing arguments but cant put it
> together. I dont have any perl books other than the web (which I am
> searching as I type this.)
> Any help would be appreciated.
It is essentially a one-liner.
There are conditions that you haven't specified:
What if the 'X' or 'x' is in the first three characters on a line? The
example program gobbles the preceding newline into the result. Changing
this behavior is very simple. One way would be to process one line at a
time instead of all at once as shown. Another way is left as an
exercise.
What if two 'X's don't have at least three characters between them?
#!perl -w
use strict;
$_ = do { local $/; <DATA> };
print join " " => /(...)(?=[Xx])/gs;
__DATA__
Hello_my_name_is_MrX.
I_am_very_pleased_to_meet_you_X.
I_have_excommunicated_you
x1234x12x
> Can anyone help me out with this? I managed to successfully mess around
> with files and grep and reading and writing arguments but cant put it
> together. I dont have any perl books other than the web (which I am
> searching as I type this.)
All the documentation you need is on your hard disk. For example, you
should learn more about the regular expression used above by doing the
command:
man perlre
or
perldoc perlre
All the documentation is also on the web, under
<URL:http://www.perl.com>. Where else? :-)
> Any help would be appreciated.
> My email
> Foghorn@NOSPAM.Telusplanet.net
If you want email to a particlar address other than the one you are
submitting from, use the Reply-To: header. Even then, most people here
won't do it.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 22 Oct 1999 18:41:43 GMT
From: "CSRA" <CSRA@tci.telus.com>
Subject: Re: Newbie needs help with script! Should be easy for an expert.
Message-Id: <01bf1cbd$1dc96dc0$54b2b28e@M26160>
Snip
ahhh cheers!
Ran that script and I see what you are saying about the special rules.
I had an overview of the problem but never got dirty with it before I
started asking questions so
didnt see what problems would arise.
www.perl.com
Ever read the Purloined Letter? :)
Thanks for the help!
------------------------------
Date: Fri, 22 Oct 1999 10:33:36 -0700
From: "Lauren Smith" <laurensmith@sprynet.com>
Subject: Re: newbie problem writing/reading a file
Message-Id: <7uq75k$eaf$1@brokaw.wa.com>
Rik Driever wrote in message ...
>>open(MYFILE, >>$file);
>Why is this wrong? Because of the space? According to a tutorial this
>would be the code for appending to a file...right?
open (MYFILE, ">>$file") or die "$file: $!";
>
>>#!/usr/local/bin/perl
>Why add -w? What does it do?
It turns on warnings, very handy!
>
>>use strict;
>What does it? Why use it?
It's a compile time program checker. It checks for dangerous code and
global variables. Basically it will catch your bad programming habits
before you get to form them.
>
>I think you all will have a good laugh at me, because this will seem
>rather stupid, but I have know idea where to find awnsers on questions
>like this, so I hope someone will be so kind to awnser my questions, so
>I can upload a code that actually works.
We can give you the fish or we can teach you to fish.
Here's what you can do to answer your own questions:
At your prompt, type: "perldoc perldoc"
This will show you command line flags that you can pass to perldoc, your
online answer finder.
Next, try "perldoc -f open" and get the documentation for the 'open'
function.
Lauren
As a side note, your post was in Jeopardy style, a style not looked upon
too kindly 'round these parts. Tom Christiansen posts an article about
it once or twice a week, you can take a look at that and adjust your
posting style (at least in this ng) accordingly.
------------------------------
Date: Fri, 22 Oct 1999 12:03:58 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Perl and shadow passwords
Message-Id: <Pine.GSO.4.10.9910221200180.29843-100000@user2.teleport.com>
On Thu, 21 Oct 1999 nate237@my-deja.com wrote:
> I am attempting to create a process to add new users to Solaris and
> Linux boxes via Perl. I couldn't find a module that would do this
> (with shadow passwords), so I've started on writing something myself.
Hmmmm. There should be something. But okay...
> Does anyone have an example of what module and/or syntax to use to
> encrypt a password with MD5 into a format suitable for the shadow
> file?
You do know about the MD5 module, right? But if you need to know how
Linux's shadow file works, check the manpages and Linux newsgroups. Good
luck with it!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Fri, 22 Oct 1999 17:06:51 GMT
From: Marcel Grunauer <marcel.grunauer@lovely.net>
Subject: Re: Perl Exam Beta Testers Required - How good are you?
Message-Id: <5qYQOIfLDLau7yEv=1npoqlQGWht@4ax.com>
On Fri, 22 Oct 1999 09:58:21 -0400, "Munish Suri"
<msuri@recruitsource.com> wrote:
> My company is working on an online technical screening system that is
> to-be-shortly released. We are looking for experienced individuals to test
> our Perl exams.
>
> Please respond ASAP if you are interested.
Oh, please let me take the test! They are usually a good reason to
invite some friends, buy a case of beer and have a good laugh.
Of course, it'd be even more fun if Matt Wright designed the test, but
I guess you can't have everything...
--
Marcel, Perl Padawan
sub AUTOLOAD{$_=$AUTOLOAD;s;.*::;;;y;_; ;;print}&Just_Another_Perl_Hacker;
------------------------------
Date: Fri, 22 Oct 1999 18:57:42 GMT
From: quikscor@ix.netcom.com (Jana Cole or John Sayre)
Subject: PostgreSQL interfaces
Message-Id: <3810b22c.55382008@nntp.ix.netcom.com>
My ISP allows me access to PostgreSQL. I am new to Perl.
At the CPAN site I see two ways to interface with PostgreSQL: a Pg
module that "permits you to access all functions of the Libpq
interface of PostgreSQL" and I see DBD::Pg which "works with the DBI
module to provide access to PostgreSQL databases."
Is one of these "better" than the other? Are there any major
differences in functionality or ease of use?
I'm going to be doing super-simple database searches like
city AND country AND price_range
I don't anticipate anything more comlicated than this type of thing.
-j
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V9 Issue 1152
**************************************