[16640] in Perl-Users-Digest
Perl-Users Digest, Issue: 4052 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Aug 17 21:10:33 2000
Date: Thu, 17 Aug 2000 18:10:20 -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: <966561020-v9-i4052@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 17 Aug 2000 Volume: 9 Number: 4052
Today's topics:
parsing if then statements in perl <djoiner@shodor.org>
Re: parsing if then statements in perl (Mike Stok)
Re: parsing if then statements in perl <elephant@squirrelgroup.com>
Re: parsing if then statements in perl (Richard J. Rauenzahn)
Re: Perl Flashes window <elephant@squirrelgroup.com>
Re: Pipe on WinNT <elephant@squirrelgroup.com>
Problems with CPAN.pm <mohlerb@troodon.saic.com>
Re: problems with Tk and NT4 <bkennedy@hmsonline.com>
Re: Regex Alternation Question <dfan@harmonixmusic.com>
Re: Regex Alternation Question <lr@hpl.hp.com>
Re: Regex Alternation Question (Mark-Jason Dominus)
Re: Regex Alternation Question (Mark-Jason Dominus)
Re: Regex Alternation Question (Mark-Jason Dominus)
regex question from newbie <g.chapman0749@home.com>
Re: regex question from newbie (Mark-Jason Dominus)
Re: remove entry from file --anyone!! <mercan.1@osu.edu>
Re: Running Perl-Script as NT-Service <elephant@squirrelgroup.com>
Re: Running Perl-Script as NT-Service <g.chapman0749@home.com>
Re: Search and replace character sections <lr@hpl.hp.com>
Re: Search and replace character sections <uri@sysarch.com>
test <ravikrishna10132@my-deja.com>
Re: test (Mark-Jason Dominus)
Re: wwwadmin.pl and deleting messages <timewarp@shentel.net>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 17 Aug 2000 15:56:02 -0400
From: David Joiner <djoiner@shodor.org>
Subject: parsing if then statements in perl
Message-Id: <399C4352.C9801F7A@shodor.org>
Howdy,
I'm trying to write a code to do some simple translation between two
different computer languages, and am having some trouble parsing out if
then else statements.
I'm trying to go from the following format
var = if (condition_a) then if (condition_b) then answer_a else answer_b
else answer_c
where every if then does have an else
to
if (condition_a) {
if (condition_b) {
var = answer_a;
} else {
var = answer_b;
}
} else {
var = answer_c;
}
I'd like to avoid any unusual modules, as I want this eventually to run
on Mac and Windows as well as UNIX.
Any ideas?
Dave Joiner
djoiner@shodor.org
--
=========================================================
David A. Joiner, Ph.D.
Staff Scientist The Shodor Education Foundation, Inc.
djoiner@shodor.org http://www.shodor.org/~djoiner
MWF 336 334 3278 TTh 919 286 1911
=========================================================
------------------------------
Date: Thu, 17 Aug 2000 23:06:21 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: parsing if then statements in perl
Message-Id: <Nd_m5.16$C5.5473@typhoon.austin.rr.com>
In article <399C4352.C9801F7A@shodor.org>,
David Joiner <djoiner@shodor.org> wrote:
> I'm trying to write a code to do some simple translation between two
>different computer languages, and am having some trouble parsing out if
>then else statements.
>
> I'm trying to go from the following format
>
>var = if (condition_a) then if (condition_b) then answer_a else answer_b
>else answer_c
>
>where every if then does have an else
>
>to
>
>if (condition_a) {
> if (condition_b) {
> var = answer_a;
> } else {
> var = answer_b;
> }
>} else {
> var = answer_c;
>}
>
>I'd like to avoid any unusual modules, as I want this eventually to run
>on Mac and Windows as well as UNIX.
Is Parse::RecDescent too unusual?
It's pure perl and lets you declare your grammar and associated actions.
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ |
GPG PGP Key 1024D/059913DA | Fingerprint 0570 71CD 6790 7C28 3D60
stok@colltech.com (CT - work) | 75D2 9EC4 C1C0 0599 13DA
------------------------------
Date: Thu, 17 Aug 2000 23:23:32 GMT
From: jason <elephant@squirrelgroup.com>
Subject: Re: parsing if then statements in perl
Message-Id: <MPG.1407116614052a599896c7@localhost>
David Joiner wrote ..
> I'm trying to write a code to do some simple translation between two
>different computer languages, and am having some trouble parsing out if
>then else statements.
>
> I'm trying to go from the following format
>
>var = if (condition_a) then if (condition_b) then answer_a else answer_b
>else answer_c
>
>where every if then does have an else
>
>to
>
>if (condition_a) {
> if (condition_b) {
> var = answer_a;
> } else {
> var = answer_b;
> }
>} else {
> var = answer_c;
>}
>
>I'd like to avoid any unusual modules, as I want this eventually to run
>on Mac and Windows as well as UNIX.
>
>Any ideas?
yes .. break down your input into tokens and create a parse tree .. then
replace the tokens with Perl's tokens and output the parse tree
--
jason -- elephant@squirrelgroup.com --
------------------------------
Date: 17 Aug 2000 23:50:37 GMT
From: nospam@hairball.cup.hp.com (Richard J. Rauenzahn)
Subject: Re: parsing if then statements in perl
Message-Id: <966556236.905804@hpvablab.cup.hp.com>
David Joiner <djoiner@shodor.org> writes:
>Howdy,
>
> I'm trying to write a code to do some simple translation between two
>different computer languages, and am having some trouble parsing out if
>then else statements.
>
> I'm trying to go from the following format
>
>var = if (condition_a) then if (condition_b) then answer_a else answer_b
>else answer_c
If your target language supports it, you might consider trying to change
it to this form instead:
var = condition_a ? (condition_b ? answer_a : answer_b) : answer_c
If the ()'s aren't necessary in the target language, you could simply
replace 'if (condition) then' with 'condition ?' and 'else' with ':'.
Rich
--
Rich Rauenzahn ----------+xrrauenza@cup.hp.comx+ Hewlett-Packard Company
Technical Consultant | I speak for me, | 19055 Pruneridge Ave.
Development Alliances Lab| *not* HP | MS 46TU2
ESPD / E-Serv. Partner Division +--------------+---- Cupertino, CA 95014
------------------------------
Date: Thu, 17 Aug 2000 22:49:27 GMT
From: jason <elephant@squirrelgroup.com>
Subject: Re: Perl Flashes window
Message-Id: <MPG.14070967221893309896c4@localhost>
Fillem wrote ..
>"Elhanan Maayan" <jmaayan@isdn.net.ilt> wrote in message
>news:8ngovq$gvg$1@news.ibm.net.il...
>> hi...
>> i have active state perl 5.6
>>
>> when i try to enter print "Hello World!\n"; in a file named hello.pl and
>> execute it all i see a quick black window which dissappears after a
>> second, what's going on?
>
>it actually opens up a dos window, executes the program then closes the
>window again, really fast :o)
>
>what you can do is just add this final line to your program:
>
><STDIN>
>
>or just
>
><>
>
>so this is what your hello world would look like:
>
>print "Hello World!\n";
>
><>
>
>now all you have to do is press a key (could be the Enter key) and the
>windows closes...
don't be (what's the word) an IDIOT !!! .. do NOT change your Perl
programs to counteract the lack of knowledge that you have about your
operating system
it's very simple .. Perl runs from the command prompt .. if there's no
command prompt window open then when you run your Perl program - first
Windows will open a command prompt .. then it will run the program ..
then (because it was only open for the program) Windows will close the
command prompt
if you want the command prompt to remain open - open it first .. then
run your Perl program FROM THE COMMAND PROMPT .. then when the program
has finished the command prompt will stay open
QED
the other alternative is to trick Windows into leaving the command
prompt open by changing the .pl mapping .. I think you'll find that
another poster's attempt at an example of this is incorrect .. they've
provided the /k option for command.com .. for command.com it's the /P
option .. and for cmd.exe it's the /K option
--
jason -- elephant@squirrelgroup.com --
------------------------------
Date: Thu, 17 Aug 2000 23:10:09 GMT
From: jason <elephant@squirrelgroup.com>
Subject: Re: Pipe on WinNT
Message-Id: <MPG.14070e40302861279896c6@localhost>
Peter Gunreben wrote ..
>Guenther Degenfelder wrote:
>>
>> You should use
>> perl -S update.pl
>> and not only
>> update.pl
>
>This didn't help!
are you sure ? .. certainly while the -S option is .. umm .. optional
*8^) .. you WILL need to call the actual Perl interpreter
>Anyway, the problem is not that the second script is not executed,
>but that the output of the second script doesn't occur at the input
>filehandle. As already stated: It works fine under UNIX but not under
>WinNT.
this comment would seem to indicate that you guessed that Guenther's
solution wasn't going to work because you knew that your code was being
executed
here's the thing .. when called via the extension association mechanism
as in
blah.pl
Windows does funny things with the output .. this is why you can't type
blah.pl | more
and expect it to work .. you have to type
perl blah.pl | more
otherwise Windows does something weird with the output from your script
and it never gets to the pipe .. the same is true when capturing output
from within your script .. the intuitive
open IN, 'somescript.pl |';
WILL NEVER WORK in Windows (at least the current versions) .. you MUST
put
open IN, 'perl somescript.pl |';
and that (all other things being equal) will work
[ jeopardectomy performed ]
--
jason -- elephant@squirrelgroup.com --
------------------------------
Date: Thu, 17 Aug 2000 15:00:01 -0700
From: "Bruce W. Mohler" <mohlerb@troodon.saic.com>
Subject: Problems with CPAN.pm
Message-Id: <399C6060.64840D2@troodon.saic.com>
I'm running Perl 5.00503 on a Compaq Alpha Server under Compaq Tru64
UNIX 4.0. I'm trying to get to get the CPAN module to install
Bundle::libnet.
I started Perl as "perl -MCPAN -eshell" and went through the initial
config
process and selected about 4 sites as archive sites. It wrote the
Config.pm
file. I then tried "install Bundle::libnet" and saw
...
Cannot fetch authors/01mailrc.txt.gz
...
Cannot fetch modules/02packages.details.txt.gz
...
Cannot fetch modules/03modlist.data.gz
Can't install Bundle::libnet, don't have an associated bundle file. :-(
The initial configuration found the ftp client program and so should be
able
to retrieve files. I specified 4 URLs.
Anyone have any suggestions on what I should look at to fix this?
Thanks, in advance.
Bruce
--
Bruce W. Mohler <>< 858-826-2675 (voice)
SAIC/ITS/Server Support 858-826-7806 (fax)
Sr UNIX system administrator 888-781-5697 (pager)
Semper fi mailto:bruce.w.mohler@saic.com
-- so much entropy, so little time --
Of course my password is the same as my pet's name.
My dog's name is ion6^gat, but I change it every 90 days.
------------------------------
Date: Thu, 17 Aug 2000 22:13:13 GMT
From: "Ben Kennedy" <bkennedy@hmsonline.com>
Subject: Re: problems with Tk and NT4
Message-Id: <ZrZm5.108541$A%3.1426759@news1.rdc2.pa.home.com>
"chris" <jemand@klop.com> wrote in message
news:8nglce$1ng$1@pollux.ip-plus.net...
> hi all
> i get perl of a NT4 box with sp6 .
> even when i try to start a perl with use::Tk i get a Dr.Watson.
> can help me somone ?
> cu chris
Maybe its a binary incompatibility? Try deleting whatever you have, and
install the latest version of perl from www.activestate.com, then (while
connected to the internet) type "ppm install Tk"
--Ben Kennedy
------------------------------
Date: 17 Aug 2000 17:28:17 -0400
From: Dan Schmidt <dfan@harmonixmusic.com>
Subject: Re: Regex Alternation Question
Message-Id: <wkk8dfbmry.fsf@turangalila.harmonixmusic.com>
mjd@plover.com (Mark-Jason Dominus) writes:
| In article <399BB4B9.B779C6F0@ppi.de>,
| Jonas Reinsch <Jonas.Reinsch@ppi.de> wrote:
| >The best solution I could think of is something like:
| >
| >for ($i = 0; $i<@parens; $i++) {
| > if ($parens[$i]) {$part = $alt[$i];last}
| >}
| >Is there a more direct way to do this?
|
| That's the only way I know of to do it, and when I've showed it in my
| classes at the Perl conference nobody has ever suggested a better way.
This is brutally ugly, and I don't know if it's any faster, but how about:
use re 'eval';
$i = 0;
$alt = "(" . join(")|(", map {"$_" . '(?{$found=' . ++$i . '})'} @alt) . ")";
if ($string =~ $alt) {
# $found now contains the number of the match
}
--
Dan Schmidt | http://www.dfan.org
Honest Bob CD now available! | http://www.dfan.org/honestbob/cd.html
------------------------------
Date: Thu, 17 Aug 2000 15:50:34 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Regex Alternation Question
Message-Id: <MPG.14060c11998dfd5398ac8e@nntp.hpl.hp.com>
In article <399bf89b.577$365@news.op.net> on Thu, 17 Aug 2000 14:37:15
GMT, Mark-Jason Dominus <mjd@plover.com> says...
> In article <399BB4B9.B779C6F0@ppi.de>,
> Jonas Reinsch <Jonas.Reinsch@ppi.de> wrote:
> >The best solution I could think of is something like:
> >
> >for ($i = 0; $i<@parens; $i++) {
> > if ($parens[$i]) {$part = $alt[$i];last}
> >}
> >Is there a more direct way to do this?
>
> That's the only way I know of to do it, and when I've showed it in my
> classes at the Perl conference nobody has ever suggested a better way.
Here's another way, using $+ to identify the match:
#!/usr/bin/perl -wl
use strict;
$_ = 'foo@bar.baz.com';
my @alt = qw( aaa bar xxx yyy zzz );
my $alt = join ')|(' => @alt;
my $regex = qr/($alt)/;
/$regex/ and print $+;
__END__
Output:
bar
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 17 Aug 2000 23:19:48 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: Regex Alternation Question
Message-Id: <399c7314.1e0e$128@news.op.net>
In article <MPG.14060c11998dfd5398ac8e@nntp.hpl.hp.com>,
Larry Rosler <lr@hpl.hp.com> wrote:
>Here's another way, using $+ to identify the match:
No, you've missed the point. You don't want to know what the matching
substring is; you want to know *which* pattern matched. When the
patterns are literal strings, then $+ is what you want, but if the
patterns are anything complicated, $+ is useless.
------------------------------
Date: Thu, 17 Aug 2000 23:25:32 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: Regex Alternation Question
Message-Id: <399c746b.1e50$301@news.op.net>
In article <wkk8dfbmry.fsf@turangalila.harmonixmusic.com>,
Dan Schmidt <dfan@harmonixmusic.com> wrote:
>$alt = "(" . join(")|(", map {"$_" . '(?{$found=' . ++$i . '})'} @alt) . ")";
Keen. I bet it's a little quicker to leave out $found and just use
$^R though:
>$alt = "(" . join(")|(", map {"$_" . '(?{' . ++$i . '})'} @alt) . ")";
>if ($string =~ $alt) {
> # $^R now contains the number of the match
>}
------------------------------
Date: Thu, 17 Aug 2000 23:31:10 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: Regex Alternation Question
Message-Id: <399c75bd.1e76$b9@news.op.net>
In article <399c746b.1e50$301@news.op.net>,
Mark-Jason Dominus <mjd@plover.com> wrote:
>Keen. I bet it's a little quicker to leave out $found and just use
>$^R though:
Well, only for very small values of 'little'.
------------------------------
Date: Thu, 17 Aug 2000 22:51:58 GMT
From: "Graham Chapman" <g.chapman0749@home.com>
Subject: regex question from newbie
Message-Id: <i0_m5.38854$c5.1369339@news2.rdc1.on.home.com>
Hi...
I'd like a user to enter an argument specifying a timeout value. Timeout
value will be in milliseconds so I'd like them to be able to enter say,
"5400000" (milliseconds) or "1 hour 30 mins" or "1.5 hrs" or "1 hour 30
mins 0 seconds" or any variation... and have it converted into milliseconds.
Any way of easily doing this with a regex or should I think of another
option..?
Thanks....
------------------------------
Date: Thu, 17 Aug 2000 23:47:08 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: regex question from newbie
Message-Id: <399c797b.1f16$50@news.op.net>
[mailed and posted]
In article <i0_m5.38854$c5.1369339@news2.rdc1.on.home.com>,
Graham Chapman <g.chapman0749@home.com> wrote:
>Any way of easily doing this with a regex or should I think of another
>option..?
I guess something like this *might* suit you, but I'm not sure:
chomp($t = <STDIN>);
$t2 = $t;
$m = 0;
$m += $1 * 86_400_000 while $t =~ s/([\d.]+)\s*da?ys?//;
$m += $1 * 3600_000 while $t =~ s/([\d.]+)\s*h(ou)?rs?//;
$m += $1 * 60_000 while $t =~ s/([\d.]+)\s*min(ute)?s?//;
$m += $1 * 1_000 while $t =~ s/([\d.]+)\s*sec(ond)?s?//;
$m += $1 while $t =~ s/([\d.]+)\s*m(illi)?s(ec(ond)?)?s?//;
$m += $1 while $t =~ s/([\d.]+)//;
if ($t =~ /\S/) {
die "Gack, me no understand that!\n";
}
print "$m millseconds.\n";
It does handle all the examples you gave in your original message.
------------------------------
Date: Thu, 17 Aug 2000 19:53:31 -0500
From: "Fatih C. Mercan" <mercan.1@osu.edu>
Subject: Re: remove entry from file --anyone!!
Message-Id: <399C890A.7E8914B3@osu.edu>
> hi all,
>
> simple question:
>
> I need to replace the user fred from the magic file.
> File magic looks like this:
>
> jill:nothappy:9034: gill hill
> fred:happy:9012:hill road
> nill:pop:983:jd houise
>
> I need to remove fred from the file and move nill up so that it looks
> like this:
>
> jill:nothappy:9034: gill hill
> nill:pop:983:jd houise
>
> thanks
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
You have to open the file to read, then store it to an array, then splice
that array
to exculde the line you want to delete, and at last write the remaining
array to
the same file again.. But you have to make sure to lock the file since if
other programs are using the file while you are writing on it, the data
may be corrupted or
lost at all.. Below is a sample code for this.
-- Code begins
#deleteuser.pl
#!/usr/bin/perl
use 5.004;
use Fcntl qw(:DEFAULT :flock);
# $user is the user you want to delete
#I assume that you already know how to parse this to the script
#if you are going to call the script from the command line remove comment
from below line. "deleteuser.pl fred"
#$user = $ARGV[0];
open (READ,"<magic") || die "Couldn't open magic file $!\n;
@lines= <READ>;
close (READ);
for ($i=0; $i < @lines; $i++){
@terms = split(/\:/, $lines[$i]);
if ( $terms[0] eq $user ){
$findex = $i;
last;
}
}
if ($findex != 0){
splice (@lines, $findex, 1 );
open (YZ, ">magic") || die "Couldn't write to file $!\n;
flock(YZ, LOCK_EX) || die "Couldn't lock the file $!\n";
print YZ @terms;
flock(YZ,LOCK_UN) || die "Couldn't unlock the file $!\n";
close (YZ);
}
--End of code
------------------------------
Date: Thu, 17 Aug 2000 22:59:58 GMT
From: jason <elephant@squirrelgroup.com>
Subject: Re: Running Perl-Script as NT-Service
Message-Id: <MPG.14070bdd8fb9e2969896c5@localhost>
Guenther Degenfelder wrote ..
>The script should run on Windows NT (and 2K). It should run ALLWAYS (without
>a user logged in - and without autologon hacks).
>
>I can't schedule it. The script will observe any services or applications -
>the scheduler too...
have a look at Win32::Daemon .. I haven't used it so I can't say that
everything nobull has said will not count against this module as well ..
but Roth are pretty good with the other things they produce .. so I
suspect that this will work well too
http://www.roth.net/perl/
--
jason -- elephant@squirrelgroup.com --
------------------------------
Date: Thu, 17 Aug 2000 23:06:19 GMT
From: "Graham Chapman" <g.chapman0749@home.com>
Subject: Re: Running Perl-Script as NT-Service
Message-Id: <Ld_m5.38872$c5.1370414@news2.rdc1.on.home.com>
Well said about NT ResKit...
How about trying the Win32::Daemon module by Dave Roth. It's a very good
idea though I haven't had enough time to fully try it out.
If you use ActivePerl from ActiveState you can always run ppm and point it
at Dave's site, there's instructions at http://www.roth.net/perl/packages
<nobull@mail.com> wrote in message news:u9vgwzn8us.fsf@wcl-l.bham.ac.uk...
> "Guenther Degenfelder" <guenther.degenfelder@datev.de> writes:
>
> > Yes. Very ugly. I know...
> >
> > The script should run on Windows NT (and 2K). It should run ALLWAYS
(without
> > a user logged in - and without autologon hacks).
> >
> > I can't schedule it. The script will observe any services or
applications -
> > the scheduler too...
> >
> > And i can't install LINUX first! ;-)
> >
> > Any hints?!
> >
> > Post it into NT newsgroup???!!!
>
> Someone may someday write a proper NT service Perl module. Problem is
> that for a process to act as a proper NT service necessarily implies
> threads, and what's more the OS creates new threads not the app.
> Until such time as Perl's threading is a bit more stable I don't see
> this happening. (I thought about it last time I needed a Perl script
> to run as an NT service).
>
> Simple solution: SRVANY from the "NT Resource Kit". This shim allows
> an simple EXE (e.g. Perl.exe) to run as a service.
>
> Note: "NT Resource Kit" = "The bits of NT you need to make it half-way
> usable as an OS but that Microsoft don't want to include in the
> standard release because they can't be bothered to QA them even to
> their usual standards".
>
>
> --
> \\ ( )
> . _\\__[oo
> .__/ \\ /\@
> . l___\\
> # ll l\\
> ###LL LL\\
------------------------------
Date: Thu, 17 Aug 2000 15:10:10 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Search and replace character sections
Message-Id: <MPG.1406029e32ffb5ab98ac8d@nntp.hpl.hp.com>
In article <spoio0ndr5j70@corp.supernews.com> on Thu, 17 Aug 2000
20:28:48 GMT, Greg Bacon <gbacon@HiWAAY.net> says...
> In article <8nhg33$kij$1@nnrp1.deja.com>,
> <msacks@my-deja.com> wrote:
>
> : Just to be sure I'm clear, the intent of the string is to
> : convert "jack1test@hotmail.com" to "jack1test@*******.com"
>
> $addr =~ s/^(.+)@(.+)\.(.+)$/$1 . '@' . ('*' x length $2) . ".$3"/e;
>
> Look, Ma, no /e:
>
> $addr =~ s/^(.+)@(.+)\.(.+)$/$1\@${\('*' x length $2)}.$3/
Look, Ma, no excessive capturing and copying.
$addr =~ s/@(.+)\./@@{['*' x length $1]}./;
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Thu, 17 Aug 2000 23:14:49 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Search and replace character sections
Message-Id: <x7n1ibwkd4.fsf@home.sysarch.com>
>>>>> "LR" == Larry Rosler <lr@hpl.hp.com> writes:
LR> In article <spoio0ndr5j70@corp.supernews.com> on Thu, 17 Aug 2000
LR> 20:28:48 GMT, Greg Bacon <gbacon@HiWAAY.net> says...
>>
>> Look, Ma, no /e:
>>
>> $addr =~ s/^(.+)@(.+)\.(.+)$/$1\@${\('*' x length $2)}.$3/
LR> Look, Ma, no excessive capturing and copying.
LR> $addr =~ s/@(.+)\./@@{['*' x length $1]}./;
look, ma, ahead! (and no ugly expression ref interpolation!)
$addr =~ s/[a-z](?=[a-z]*\.)/*/g ;
it makes assumptions but it works fine. here is the same with a
lookbehind check to make sure the domain followed a @. it needs the
while loop to deal with lookbehind not handling variable length
patterns. not no /g modifier
1 while $addr =~ s/(?<=[\@*])[a-z](?=[a-z]*\.)/*/'
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Thu, 17 Aug 2000 19:06:45 -0400
From: "Ravi Krishna" <ravikrishna10132@my-deja.com>
Subject: test
Message-Id: <8nhr7i08c9@news2.newsguy.com>
Pls ignore.
------------------------------
Date: Fri, 18 Aug 2000 00:45:20 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: test
Message-Id: <399c871f.2146$1cf@news.op.net>
In article <8nhr7i08c9@news2.newsguy.com>,
Ravi Krishna <ravikrishna10132@my-deja.com> wrote:
>Pls ignore.
>
>
Consider it done!
------------------------------
Date: Thu, 17 Aug 2000 18:34:37 -0400
From: Albert Dewey <timewarp@shentel.net>
Subject: Re: wwwadmin.pl and deleting messages
Message-Id: <399C687D.68094FA9@shentel.net>
Sorry to hear that . . . .
xlr6drone@my-deja.com wrote:
> Hi,
>
> I am using Matt's wwwboard (scriptarchive.com)
------------------------------
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 4052
**************************************