[19448] in Perl-Users-Digest
Perl-Users Digest, Issue: 1643 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Aug 29 00:05:41 2001
Date: Tue, 28 Aug 2001 21:05:12 -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: <999057911-v10-i1643@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 28 Aug 2001 Volume: 10 Number: 1643
Today's topics:
64 bit perl <wai@hpeswai.fc.hp.com>
Re: Avoiding symbolic references. <goldbb2@earthlink.net>
Re: Beginner PERL Book <bwalton@rochester.rr.com>
Re: Beginner PERL Book <rob_13@excite.com>
Re: Can't install a DBD::DB2 on AIX <tom.hoffmann@worldnet.att.net>
Re: changing users within a perl script <gbouris@toxo.com>
Re: changing users within a perl script (David Efflandt)
crypt function and upgrading perl/libc <rmang@submariner.org>
Re: crypt function and upgrading perl/libc <bwalton@rochester.rr.com>
Re: Evaluation order of object methods <goldbb2@earthlink.net>
Re: Help with Piped command, capturing output <goldbb2@earthlink.net>
Re: how to do 'c' - 'a' = 2 in perl? (Abigail)
Re: how to get character from string one by one? <godzilla@stomp.stomp.tokyo>
Re: how to get character from string one by one? <goldbb2@earthlink.net>
Re: how to get character from string one by one? <godzilla@stomp.stomp.tokyo>
Line Breaking in Japanese (Tim)
Matching "bar" not preceded by "foo" (Tobin Baker)
Re: Matching "bar" not preceded by "foo" <krahnj@acm.org>
Re: Matching "bar" not preceded by "foo" <goldbb2@earthlink.net>
Re: Matching "bar" not preceded by "foo" <godzilla@stomp.stomp.tokyo>
Re: MLDBM <bwalton@rochester.rr.com>
Re: newbie regexp question <goldbb2@earthlink.net>
Re: Performance : Shell X Perl (Abigail)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 28 Aug 2001 11:53:40 -0600
From: James Wai <wai@hpeswai.fc.hp.com>
Subject: 64 bit perl
Message-Id: <3B8BDAA4.93ED8402@hpeswai.fc.hp.com>
Hi All,
I need help on installing perl 5.6.1 on a HPUX 11.0 machine.
I have no problem installing in using the default
"Config.sh;make;make test;make install" method. However,
I am trying to install DBD/DBI module that will talk to
Oracle 9.0.1. It seems that I need everything to be 64 bit.
I try adding +DA2.0W to the ccflags, but did not go very far.
Has anyone sucessfully install a 64 bit perl on HPUX 11.0?
thanks for any help.
--
----------------------------------------------------------------------
- James Wai
----------------------------------------------------------------------
------------------------------
Date: Tue, 28 Aug 2001 22:29:52 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Avoiding symbolic references.
Message-Id: <3B8C53A0.40C2882E@earthlink.net>
Anno Siegel wrote:
>
> According to Benjamin Goldberg <goldbb2@earthlink.net>:
> > Anno Siegel wrote:
> > >
> > > According to Benjamin Goldberg <goldbb2@earthlink.net>:
> > >
> > > [calculating Euler's number]
[snip calculation of e, which is "euler's number"]
> > Umm, this is a different Euler's constant I'm calculating. ...
>
> Uh... Errm... Okay.
If you do a web search for "euler's constant", the whole first page, and
then some, is about gamma, not about e.
http://www.google.com/search?q=euler%27s-constant
On the other hand, if you search for "euler's number", then you get
information about e.
http://www.google.com/search?q=euler%27s-number
I guess it's a bit wierd for two different constants to have such
similar names, but what can we do?
--
I'm not a programmer but I play one on TV...
------------------------------
Date: Wed, 29 Aug 2001 02:22:28 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Beginner PERL Book
Message-Id: <3B8C51C0.41AD899C@rochester.rr.com>
at wrote:
>
> Can someone tell me which is the "best" beginner PERL book out there? I have
> taken a 2 day course for PERL where they shoved quite a bit of info and am
> having a hard time remembering anything at all...I want to start from the
> basics. I bought two books. PERL Annotated Archives and PERL from the ground
> up.
>
> Or should I just go to a university and take the time to learn?
...
> Jason B. Swaim
Hey, imagine this: that is a FAQ! perldoc -q book
--
Bob Walton
------------------------------
Date: Wed, 29 Aug 2001 02:24:27 GMT
From: "Rob - Rock13.com" <rob_13@excite.com>
Subject: Re: Beginner PERL Book
Message-Id: <Xns910BE3EDB128Frock13com@64.8.1.226>
<news:3b8bad5d_1@newsa.ev1.net>:
>
> Can someone tell me which is the "best" beginner PERL book out
> there?
'Learning Perl' is good or 'Perl and CGI for the WWW' by Liz Castro
as others suggested. The former has a broader scope while, as the
title indicates, the later is focused on learning enough Perl to
use CGI. If you main reason is to use Perl on websites then go for
Castro's book.
If you want a reference to hold in your hand, Programming Perl. I
liked any of the O'Reilly & Assoc books on Perl that I've bought.
> I have taken a 2 day course for PERL where they shoved
> quite a bit of info and am having a hard time remembering
> anything at all...I want to start from the basics. I bought two
> books. PERL Annotated Archives and PERL from the ground up.
I'm questioning how good a course that was if they didn't teach you
Perl was was not all caps.
--
Rob - http://rock13.com/
Web Stuff: http://rock13.com/webhelp/
------------------------------
Date: Tue, 28 Aug 2001 22:09:54 GMT
From: Tom Hoffmann <tom.hoffmann@worldnet.att.net>
Subject: Re: Can't install a DBD::DB2 on AIX
Message-Id: <SEUi7.1749$KV3.133884@bgtnsc04-news.ops.worldnet.att.net>
On Tuesday 28 August 2001 03:37, Jens Jespersen wrote:
> Hi
>
> I am trying to compile a DBD::DB2 in to my perl, but no sucess. I got
> this
>
> root@elna:/tmp/DBD-DB2-0.75 > make test
> PERL_DL_NONLAZY=1 /usr/bin/perl -Iblib/arch -Iblib/lib
> -I/usr/opt/perl5/lib/5.00503/aix -I/usr/opt/perl5/lib/5.00503 -e 'use
> Test::Harness qw(&runtests $verbose); $verbose
> =0; runtests @ARGV;' t/*.t
> t/base..............install_driver(DB2) failed: Can't load
> 'blib/arch/auto/DBD/DB2/Constants/Constants.so' for module
> DBD::DB2::Constants: dlopen: blib/arch/auto/DBD/DB2/Constants
> /Constants.so: A file or directory in the path name does not exist. at
> /usr/opt/perl5/lib/5.00503/aix/DynaLoader.pm line 169.
>
> at blib/lib/DBD/DB2.pm line 31
> BEGIN failed--compilation aborted at blib/lib/DBD/DB2.pm line 31.
> Perhaps a required shared library or dll isn't installed where
> expected
> at t/base.t line 16
> dubious
> Test returned status 2 (wstat 512, 0x200)
> DIED. FAILED tests 4-5
> Failed 2/5 tests, 60.00% okay
> t/main..............ok
> Failed Test Status Wstat Total Fail Failed List of failed
>
-------------------------------------------------------------------------------
> t/base.t 2 512 5 2 40.00% 4-5
> Failed 1/2 test scripts, 50.00% okay. 2/6 subtests failed, 66.67%
> okay.
> make: 1254-004 The error code from the last command is 2.
>
>
> Stop
>
> All the files it ask for is there, but the make can't find it.
>
> this is my perl setup.
>
> root@elna:/tmp/DBD-DB2-0.75 > perl -V
> Summary of my perl5 (5.0 patchlevel 5 subversion 3) configuration:
> Platform:
> osname=aix, osvers=4.3.3.0, archname=aix
> uname='aix funny 3 4 000001716600 '
> hint=recommended, useposix=true, d_sigaction=define
> usethreads=undef useperlio=undef d_sfio=undef
> Compiler:
> cc='cc', optimize='-O', gccversion=
> cppflags='-D_ALL_SOURCE -D_ANSI_C_SOURCE -D_POSIX_SOURCE
> -qmaxmem=16384'
> ccflags ='-D_ALL_SOURCE -D_ANSI_C_SOURCE -D_POSIX_SOURCE
> -qmaxmem=16384'
> stdchar='unsigned char', d_stdstdio=define, usevfork=false
> intsize=4, longsize=4, ptrsize=4, doublesize=8
> d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=8
> alignbytes=8, usemymalloc=n, prototype=define
> Linker and Libraries:
> ld='ld', ldflags ='-s'
> libpth=/lib /usr/lib /usr/ccs/lib
> libs=-lnsl -ldbm -ldl -lld -lm -lc -lcrypt -lbsd -lPW -lC_r
> libc=/lib/libc.a, so=a, useshrplib=false, libperl=libperl.a
> Dynamic Linking:
> dlsrc=dl_aix.xs, dlext=so, d_dlsymun=undef,
> ccdlflags='-bE:perl.exp'
> cccdlflags=' ', lddlflags='-bhalt:4 -bM:SRE
> -bI:$(PERL_INC)/perl.exp -bE:$(BASEEXT).exp -b noentry -lc'
>
>
> Characteristics of this binary (from libperl):
> Built under aix
> Compiled at Aug 14 1999 08:59:55
> @INC:
> /usr/opt/perl5/lib/5.00503/aix
> /usr/opt/perl5/lib/5.00503
> /usr/opt/perl5/lib/site_perl/5.005/aix
> /usr/opt/perl5/lib/site_perl/5.005
> .
> root@elna:/tmp/DBD-DB2-0.75 >
>
> I think it is a path missing but which path?
I had the same problem with DBD::Oracle. The messages drove me crazy
since the files it claimed it could not find were right where it was
looking for them. Sound familiar?
In desparation, I got thte latest DBI source from CPAN and reinstalled,
making sure to run 'make test' and verifying all tests worked. I was
then able to install DBD::Oracle without any problems.
Not sure if this will be the same for you, but ...
------------------------------
Date: Wed, 29 Aug 2001 02:37:48 +0300
From: "George Bouris" <gbouris@toxo.com>
Subject: Re: changing users within a perl script
Message-Id: <9mh9vj$db5$1@usenet.otenet.gr>
If i got it right.....
To do that, you must set the system's permission on the script file.
Let's say you are runing windows NT.
Right click on the file -> properties -> security -> (the add the user you
want)
"justme" <none@westriv.com> wrote in message
news:ton8qjklc2mbd4@corp.supernews.com...
> I'm new to programming in perl, so this may be an easy question. I have a
> program that I need to run as a certain user. Does anyone know how to
> switch to a different user or run a program as a different user within a
> perl script?
>
> Thanks
> Doug
>
>
------------------------------
Date: Wed, 29 Aug 2001 02:49:41 +0000 (UTC)
From: see-sig@from.invalid (David Efflandt)
Subject: Re: changing users within a perl script
Message-Id: <slrn9oom25.108.see-sig@typhoon.xnet.com>
On Tue, 28 Aug 2001 07:57:36 -0600, justme <none@westriv.com> wrote:
> I'm new to programming in perl, so this may be an easy question. I have a
> program that I need to run as a certain user. Does anyone know how to
> switch to a different user or run a program as a different user within a
> perl script?
Depends upon the OS. A Windows reply was posted. In Unix you could set
the owner you want it to run as and suid bit of the script (chmod 4750 or
4755 depending upon who should be able to run it) and use suidperl instead
of perl in the first line. Then read 'perldoc perlsec' about untainting.
However, on some systems suidperl is not suid root for security reasons,
so you may need to make suidperl suid root before it will work.
To arbitrarily change users, the script itself would have to be running
suid root, but you better know what you are doing before you attempt that.
--
David Efflandt (Reply-To is valid) http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://cgi-help.virtualave.net/ http://hammer.prohosting.com/~cgi-wiz/
------------------------------
Date: 29 Aug 2001 01:32:06 GMT
From: Robert mangiafico <rmang@submariner.org>
Subject: crypt function and upgrading perl/libc
Message-Id: <Xns910BDB04282BArmanglexiconncom@198.99.146.10>
We recently upgraded our OS from RH5.x to RH6.x, from libc5 to glibc2, and
from perl 5.004_04 to 5.6.0. Once script that uses the perl 'crypt'
function to encrypt passwords no longer works, as it seems the passwords it
created with 'crypt' and 'salt' in the old OS are different from the ones
it creates/compares under the new OS.
Is there a way to make this backwards compatible so that passwords
encrypted under the old OS with 'crypt' will still be valid under the new
OS?
TIA.
- Rob
------------------------------
Date: Wed, 29 Aug 2001 02:53:00 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: crypt function and upgrading perl/libc
Message-Id: <3B8C58E3.27B1DA24@rochester.rr.com>
Robert mangiafico wrote:
>
> We recently upgraded our OS from RH5.x to RH6.x, from libc5 to glibc2, and
> from perl 5.004_04 to 5.6.0. Once script that uses the perl 'crypt'
> function to encrypt passwords no longer works, as it seems the passwords it
> created with 'crypt' and 'salt' in the old OS are different from the ones
> it creates/compares under the new OS.
>
> Is there a way to make this backwards compatible so that passwords
> encrypted under the old OS with 'crypt' will still be valid under the new
> OS?
...
> - Rob
The Crypt::UnixCrypt module might help. You might also check to see if
your upgraded system was configured to use MD5 passwords rather than
conventional passwords.
--
Bob Walton
------------------------------
Date: Tue, 28 Aug 2001 22:14:23 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Evaluation order of object methods
Message-Id: <3B8C4FFF.1F11AD3E@earthlink.net>
Mr. Sunblade wrote:
>
> <snip,snip>
>
> > That's why there's that fun wantarray() function. Return $self or
> > the new object if wantarray is false, otherwise return an array.
>
> Doesn't work. If you chain a method, then 'defined wantarray' will
> return true for the immediately preceding method.
>
> -- a very basic array package ---
> package Set::Array;
> use strict;
>
> sub new{
> my($class, @list) = @_;
> return bless \@list, ref($class) || $class;
> }
>
> sub length{
> my $self = shift;
> return scalar(@$self);
> }
>
> sub unique{
> my $self = shift;
> my %seen;
>
> if(wantarray){
> return grep !$seen{$_}++, @$self;
> }
> elsif(defined wantarray){
> return [grep !$seen{$_}++, @$self];
In my example, everything was in the "ARRAY" class, so a line like the
above worked perfectly ok, since an anonymous array is always an
instance of type ARRAY, even without blessing it. Your code, however,
is in class Set::Array, not ARRAY. So you need to bless the thing
before you return it.
elsif(defined wantarray){
return bless [grep !$seen{$_}++, @$self], ref($self);
and now chaining will work.
> }
> else { # void context
> @$self = grep !$seen{$_}++, @$self;
> }
> }
> 1;
>
> -- using our package --
> my $array = My::Array->new(1,2,3,1,2);
> my @unique = $array->unique(); # 'wantarray' true, returns list
> my $uniqref = $array->unique(); #'defined wantarray' true, returns ref
The problem of course is that it returns a ref of type ARRAY, not a ref
of type Set::Array.
> # Now, I'll chain method calls without an lvalue...
> $array->unique()->length(); # 'defined wantarray' true, CRASH!
>
> Problem is, because of the call to 'length', the 'defined wantarray'
> will evaluate to 'true' within 'unique'. Consequently, the 'unique'
> method will try to return an unblessed value to the 'length' method
> and that will cause it to crash.
The solution is to return a blessed instead of unblessed value.
> But if I return $self if 'defined wantarray' evaluates to true, then I
> get an object when all I wanted was the length. It's a catch 22.
You're getting confused. You want unique to return something which you
can call length on. You don't want to return $self, of course, since
that hasn't been uniqued. length of course needs a blessed reference,
and you're returning an unblessed reference. Solution: return a blessed
reference. Not by calling new, as you seem to think is the only way to
get an object, but just by calling bless.
> This makes using "defined wantarray" a *bad idea* if you want to
> support method chaining for any class.
Bzzt. It makes returning unblessed refs a *bad idea* if you want to
support method chaining for any class... *unless* that class is ARRAY,
HASH, SCALAR, GLOB, or CODE. I put my sub into class ARRAY, so I could
simply return an anonymous array, which would automatically be in the
correct class without my blessing it. If you want chainable methods for
other classes, then you need to bless the return value, when you're in
scalar context.
> This is crux of the problem. Is there a way to tell Perl, "hey, if
> 'defined wantarray' evaluates to true and I'm being passed to an
> object method, return $self (or at least a blessed array reference
> that presumably is a copy of $self). Otherwise, just return a normal
> value." ?
First, for the purpose of this discussion *always* assume you're in an
object method -- otherwise we wouldn't be thinking about object
chaining. Second, there's no reason whatsoever to assume that a blessed
arrayref is a copy of $self. Third, instead of thinking in terms of 'if
defined(wantarray) is true', you should be thinking of "list context",
"scalar context" and "void context" ... the fact that you learn what
your context is, is with wantarray, does not change what the contexts
are called. Also, in perl6, the function will be called context() [I
think]. Fourth, if you want a method to support, you simply test if
you're in scalar context, and if so, return a blessed reference to an
instance of the class -- generally *not* $self.
> I'm just accepting reality at this point and returning blessed array
> references in most cases (or $self) for methods where I want a little
> flexibility.
If you want chaining, then you MUST return a blessed ref.
If your class is one of the builtins, [like ARRAY, HASH, etc], then the
blessing is magically there. Where you got the idea that you could
return an unblessed array ref, without the class being ARRAY, and still
get chaining, I don't know.
--
I'm not a programmer but I play one on TV...
------------------------------
Date: Tue, 28 Aug 2001 22:42:45 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Help with Piped command, capturing output
Message-Id: <3B8C56A5.55B2E03E@earthlink.net>
Jonathan Cunningham wrote:
[snip]
> This does about 98% of what I'm trying to do, which is to pass text to
> PGP and encrypt it. When this is run all output is printed to the
> screen (STDOUT), including the encrypted message. This is fabulous,
> however I'd also (or alternatively) like to capture the output to a
> variable within this program and then do something else to it (TBD).
It's oft been said that the first 90% of the job takes 10% of the time,
and the last 10% of the job takes 90% of the time.
Considering how your problem most likely derives from dealing with
processes, either the fault of pgp, or win2k, or open2, you might
instead want a pure-perl solution which does not run any seperate
process. Specifically, Crypt::OpenPGP.
use strict;
my ($passphrase, $pubKey, $message) = @ARGV;
my $pgp = Crypt::OpenPGP->new;
my $ciphertext = $pgp->encrypt(
Passphrase => $passphrase,
Recipients => $pubKey,
Data => $message,
Armour => 1, # ascii-armour the output.
);
die $pgp->errstr if !$ciphertext;
print $ciphertext;
--
I'm not a programmer but I play one on TV...
------------------------------
Date: 28 Aug 2001 22:59:40 GMT
From: abigail@foad.org (Abigail)
Subject: Re: how to do 'c' - 'a' = 2 in perl?
Message-Id: <slrn9oo8j0.sa2.abigail@alexandra.xs4all.nl>
Craig Berry (cberry@cinenet.net) wrote on MMCMXIX September MCMXCIII in
<URL:news:Xns910B8B94E9FD4cberrycinenetnet1@207.126.101.92>:
__ tadmc@augustmail.com (Tad McClellan) wrote in
__ news:slrn9onck7.sc0.tadmc@tadmc26.august.net:
__ > cheng huang <cheng@cs.wustl.edu> wrote:
__ >>Say I have a $letter variable and want to know what it is exactly, can
__ >>sb.
__ >
__ > What is "sb"?
__
__ I first read it as 'antimony', but that's just me. :) I think it's a
__ pointless hyperabbreviation of 'somebody'.
I thought it stands for 'son of a bitch'.
Abigail
--
perl -swleprint -- -_='Just another Perl Hacker'
# A pair of tigers stalking.
# A rabbit under a
# she-oak tree. Two dogs.
------------------------------
Date: Tue, 28 Aug 2001 19:05:43 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: how to get character from string one by one?
Message-Id: <3B8C4DF7.BE2EA595@stomp.stomp.tokyo>
John W. Krahn wrote:
> Craig Berry wrote:
> > Yves Orton aka The CLPM Troll wrote:
(snipped)
> > > done in this area to the thread 'one character at a time'. There are
> > > a variety of methods (5 basic ideas) to achieve it
> > Let's see...substr, split, unpack, m/(.)/sg, and...what?
> vec()
seek / truncate
Godzilla! Queen Of Perl Heretics.
--
#!perl
print "Content-type: text/plain\n\n";
$size = (stat ("test.txt")) [7];
open (DATA, "+<test.txt");
for ($iterate = 0; $iterate < $size; $iterate++)
{
seek (DATA, -1, 2);
while (<DATA>)
{ print "$_\n"; }
seek (DATA, -1, 2);
truncate(DATA, tell(DATA))
}
close (DATA);
------------------------------
Date: Tue, 28 Aug 2001 23:12:53 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: how to get character from string one by one?
Message-Id: <3B8C5DB5.B463785A@earthlink.net>
Kira, who apparently thinks that all strings are files, wrote:
[snip]
> > > > There are a variety of methods (5 basic ideas) to achieve it
> > > Let's see...substr, split, unpack, m/(.)/sg, and...what?
>
> > vec()
>
>
> seek / truncate
>
> Godzilla! Queen Of Perl Heretics.
> --
>
> #!perl
>
> print "Content-type: text/plain\n\n";
>
> $size = (stat ("test.txt")) [7];
>
> open (DATA, "+<test.txt");
>
> for ($iterate = 0; $iterate < $size; $iterate++)
> {
> seek (DATA, -1, 2);
> while (<DATA>)
> { print "$_\n"; }
> seek (DATA, -1, 2);
> truncate(DATA, tell(DATA))
> }
>
> close (DATA);
And I suppose that if the data is in a scalar, as the OP asked for,
rather than a file, you would advocate a combination of this method and
IO::Stringy?
--
I'm not a programmer but I play one on TV...
------------------------------
Date: Tue, 28 Aug 2001 20:27:02 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: how to get character from string one by one?
Message-Id: <3B8C6106.C1C07ECD@stomp.stomp.tokyo>
Benjamin Goldberg aka The CLPM Troll blathered:
(shoveled out most of his mule manure)
> Kira, who apparently thinks that all strings are files, wrote:
> > seek / truncate
> And I suppose that if the data is in a scalar, as the OP asked for,
> rather than a file, you would advocate a combination of this method and
> IO::Stringy?
My ingenuity certainly deflates your fragile masculine ego, yes?
Godzilla! Just Amazing Perl Hacker.
------------------------------
Date: 28 Aug 2001 20:13:02 -0700
From: tim.heilmann@tfn.co.jp (Tim)
Subject: Line Breaking in Japanese
Message-Id: <575faae0.0108281913.276b189f@posting.google.com>
I'm trying to break a long string into lines. The string is encoded in
Japanese EUC format. There are various scripts to break the line at a
certain number of characters, but none that seem to follow the Kinsoku
line breaking rules.
Has anyone had similar experiences or found other ways to break lines
in Japanese? For example, separate utility programs or commerical
software.
thanks,
Tim..
------------------------------
Date: 28 Aug 2001 18:34:20 -0700
From: senderista@hotmail.com (Tobin Baker)
Subject: Matching "bar" not preceded by "foo"
Message-Id: <dbbeaaa3.0108281734.7fdc3e7a@posting.google.com>
What is the simplest way to do this? Lookaheads are out of the
question. Negated character classes work for one or two characters,
but this gets out of hand quickly:
/[^f]..|.[^o].|..[^o](bar)/
There must be a better way!
------------------------------
Date: Wed, 29 Aug 2001 01:43:43 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Matching "bar" not preceded by "foo"
Message-Id: <3B8C4940.3BC297FB@acm.org>
Tobin Baker wrote:
>
> What is the simplest way to do this? Lookaheads are out of the
> question. Negated character classes work for one or two characters,
> but this gets out of hand quickly:
> /[^f]..|.[^o].|..[^o](bar)/
> There must be a better way!
Use negative look-behind.
/(?<!foo)bar/
John
--
use Perl;
program
fulfillment
------------------------------
Date: Tue, 28 Aug 2001 21:47:23 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Matching "bar" not preceded by "foo"
Message-Id: <3B8C49AB.507B55AF@earthlink.net>
Tobin Baker wrote:
>
> What is the simplest way to do this? Lookaheads are out of the
> question. Negated character classes work for one or two characters,
> but this gets out of hand quickly:
> /[^f]..|.[^o].|..[^o](bar)/
> There must be a better way!
/(?<!foo)bar/
This matches a 'bar' which isn't imediately preceded by a 'foo'.
You might also consider:
/bar/ && $` !~ /foo/
Which evaluates to true if there is a bar which hasn't got a foo
*anywhere* prior to it.
--
I'm not a programmer but I play one on TV...
------------------------------
Date: Tue, 28 Aug 2001 20:00:39 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Matching "bar" not preceded by "foo"
Message-Id: <3B8C5AD7.9E784F18@stomp.stomp.tokyo>
Tobin Baker wrote:
> What is the simplest way to do this?
To do what?
> There must be a better way!
There are certainly better ways to write a coherent article.
Godzilla! Queen Of Watership Down.
--
#!perl
print "Content-type: text/plain\n\n";
$string = "Godzilla Rocks And Rolls!";
if ((index ($string, "Rolls")) > (index ($string, "Rocks")))
{ print "Easter Bunny Asks, \"Will This Hurt?\"\n\n"; }
if ((index ($string, "Godzilla")) < (index ($string, "Rocks")))
{ print "Roger Rabbit Says, \"This Won't Hurt A Bit, Did It.\""; }
PRINTED RESULTS:
________________
Easter Bunny Asks, "Will This Hurt?"
Roger Rabbit Says, "This Won't Hurt A Bit, Did It."
------------------------------
Date: Wed, 29 Aug 2001 01:10:01 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: MLDBM
Message-Id: <3B8C40CC.9149D594@rochester.rr.com>
G Harper wrote:
>
> I am searching desperately for good documentation on the usage of MLDBM. I
> need to store/retreive a DBM hash with 7 keys, each key storing an array
> with up to 40 entries. MLDBM is the only reasonable method I've found so
> far but the documentation has been thin for the quasi-newbie.
...
"Perl Cookbook" by Christiansen and Torkington (O'Reilly) has a couple
of recipies on MLDBM that should help a lot.
--
Bob Walton
------------------------------
Date: Tue, 28 Aug 2001 21:24:53 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: newbie regexp question
Message-Id: <3B8C4465.C3C696CE@earthlink.net>
Tassos Chatzithomaoglou wrote:
>
> $string = [1.2.3.4.5.6];
This creates an anonymous array with one item, the string "1.2.3.4.5.6"
You probably want either:
$string = '[1.2.3.4.5.6]';
or:
$string = q[1.2.3.4.5.6];
>
> $string =~ s/[\[\]]//g;
Assuming that you used the version with '' around the [] thing, then:
$string =~ s/^\[(.*)\]$/$1/;
> @string_temp = split(/\./,$string);
> $string = join(".", $string_temp[0], $string_temp[1],
> $string_temp[2], $string_temp[3]);
No need to do this as two steps.
$string = join( ".", (split /\./, $string)[0..3] );
>
> print "str=$string\n";
>
> desired output
> --------------
> str=1.2.3.4
--
I'm not a programmer but I play one on TV...
------------------------------
Date: 28 Aug 2001 22:52:56 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Performance : Shell X Perl
Message-Id: <slrn9oo86b.sa2.abigail@alexandra.xs4all.nl>
Brian Cantin (bcc@eswssol001.elsegundoca.ncr.com) wrote on MMCMXIX
September MCMXCIII in <URL:news:7nn14k0wfn.fsf@eswssol001.elsegundoca.ncr.com>:
;; abigail@foad.org (Abigail) writes:
;;
;; > Brian Cantin (bcc@eswssol001.elsegundoca.ncr.com) wrote on MMCMXV
;; > September MCMXCIII in
;; > <URL:news:7nlmk9tmzb.fsf@eswssol001.elsegundoca.ncr.com>:
;; > == mjd@plover.com (Mark Jason Dominus) writes:
;; > == > In my experience it's a lot easier to write a portable Perl program
;; > == > than a portable shell script. In 1995 you might have had to worry
;; > == > that the target system didn't have Perl, but these days Perl is almost
;; > == > everywhere.
;; > ==
;; > == True, Perl is available nearly everywhere, but it may not be the same
;; > == version. I run into problems all the time with machines running 5.001
;; > == on scripts that were coded and tested against later versions. The
;; > == Bourne shell and the UNIX toolkit definition is pretty much static, so
;; > == it is easier to test on a bunch of different platforms and assure
;; > == things will run.
;; >
;; > *Which* Unix toolkit definition are you talking about? That's the problem
;; > - there are many "standards" for the Unix toolkit definitions. Big vendors
;; > like HP and SUN have to problem committing themselves to standards, too
;; > bad they don't always agree to take the same one. And on top of that,
;; > tools for Linux at best follow a POSIX standard, but not always.
;; True enough. Even though the vendors vary, you can determine what
;; platform you are running on and often do the appropriate thing. Ugly,
;; but it works. Having the Perl version change from machine to machine
;; is a different sort of a problem.
But one that's far, far easier to deal with. Perl tends to be backwards
compatible, and writing a program that has to work on all versions since
a particular version is quite easy.
Knowing what to do on the myriad of twisty little Unix systems, all
different, out there is a hard problem. Not many people have more than
5 Unix systems available to them. But you need only one box to run 36
versions of Perl.
Abigail
--
srand 123456;$-=rand$_--=>@[[$-,$_]=@[[$_,$-]for(reverse+1..(@[=split
//=>"IGrACVGQ\x02GJCWVhP\x02PL\x02jNMP"));print+(map{$_^q^"^}@[),"\n"
__END__
A young girl beside // a river. Lao Tse // dies near the harbor.
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 1643
***************************************