[16713] in Perl-Users-Digest
Perl-Users Digest, Issue: 4125 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Aug 24 21:10:38 2000
Date: Thu, 24 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: <967165819-v9-i4125@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 24 Aug 2000 Volume: 9 Number: 4125
Today's topics:
Re: Just another silly post. <reljr_2@yahoo.com>
Re: Just another silly post. <reljr_2@yahoo.com>
Re: Just another silly post. <reljr_2@yahoo.com>
Re: Just another silly post. (Marcel Grunauer)
Re: Just another silly post. (Martien Verbruggen)
Re: Just another silly post. (Martien Verbruggen)
Re: Just another silly post. (Tramm Hudson)
Re: Just another silly post. (brian d foy)
Re: Just another silly post. <reljr_2@yahoo.com>
Re: Just another silly post. (Martien Verbruggen)
Re: Just another silly post. (Martien Verbruggen)
Re: Just another silly post. <lauren_smith13@hotmail.com>
Re: Just another silly post. (Craig Berry)
Re: Just another silly post. <reljr_2@yahoo.com>
Listing files in Subdirectories satyapal_deja@my-deja.com
Re: Please wait... [was: Perl - Blinking Text] (David Wall)
Re: Quick way to determine if a method is implemented i (Abigail)
Re: RegEx (Jakob Schmidt)
Re: RegEx <dietmar.staab@t-online.de>
Re: RegEx <dietmar.staab@t-online.de>
SMTP in formmail james_69yay@my-deja.com
Stumped by Reg Exp Problem - help?? <shamilton@plateausystems.holdthespam.com>
Re: Stumped by Reg Exp Problem - help?? (Jakob Schmidt)
Re: trying to pull each string from file to evaluate... <travis.cox@itron.com>
Re: Where is the Perl Newbie or Begginers group? (Tony L. Svanstrom)
Word in the middle. johnvert@my-deja.com
Re: Word in the middle. (Jakob Schmidt)
Re: Word in the middle. <lauren_smith13@hotmail.com>
Re: Word in the middle. <mauldin@netstorm.net>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 24 Aug 2000 17:28:54 -0500
From: Policy Man <reljr_2@yahoo.com>
Subject: Re: Just another silly post.
Message-Id: <39A5A1A6.7DE6079D@yahoo.com>
Martien Verbruggen wrote:
> On Wed, 23 Aug 2000 18:42:17 -0500,
> Policy Man <reljr_2@yahoo.com> wrote:
>
> > -- The code may employ at most a single ';' and then only as the final
> > item/character.
>
> Don't need no steenkin' semicolon.
>
> > -- @given may only appear once and must not be modified.
>
> Just replace @ARGV if you need to.
>
> > -- Generous use of whitespace to add clarity is appreciated.
>
> You have a space bar, don't you? :)
>
> > Do not employ:
> > -- objects, packages, modules, methods.
> > -- '::'
> > -- keywords: 'use', 'do', 'require', 'bless', `` (backticks), 'exec',
> > 'system', 'fork'.
> > -- external programs of any kind.
> > -- named variables other than specials like: '$_ @_ $1 $2 $#' etc. and
> > the array @given.
> > -- named subroutines other than functions included in the basic perl
> > 5.xxx install.
>
> You take the fun out of Perl.
>
> Notes:
> - Do not use a csh or derivative for this. bash, zsh, ksh, will do. If
> you can't stand that, escape the exclamation points.
> - The wrap is here for the post. it's not necessary or even wanted in
> the real thing.
>
> $ perl -Mstrict -wle 'sub f(){opendir(D,$/=$_)&&map{-d&&!-l&&&f,print} \
> map"$//$_",grep!/^\.\.?$/,readdir D}map{f,print}@ARGV'
>
> \begin[out of order]{quote}
> > The challenge code must not in any way clutter up the name space of a
> > program it might be included in.
> \end{quote}
>
> You didn't include that it couldn't clobber or overwrite any global
> variable values. If you don't want that to happen, pass an argument to
> the sub, and use @_. It's more typing than the above, so I'll leave that
> up to you.
>
> > Prize: The sweet feeling of success in the face of a difficult task.
>
> Pfff. 15 minutes for a good feeling? Does that sound familiar? The only
> thing difficult about it was the misleading stuff about @given and the
> semicolon that could be used.
>
> Martien
> --
> Martien Verbruggen |
> Interactive Media Division | This matter is best disposed of from
> Commercial Dynamics Pty. Ltd. | a great height, over water.
> NSW, Australia |
You violated the rule concerning using named subroutines other than those
available in the base perl install. 'f' is a named subroutine. Can you make it work
with that rule in place?
------------------------------
Date: Thu, 24 Aug 2000 17:37:08 -0500
From: Policy Man <reljr_2@yahoo.com>
Subject: Re: Just another silly post.
Message-Id: <39A5A394.C4571B4A@yahoo.com>
Abigail wrote:
> Policy Man (reljr_2@yahoo.com) wrote on MMDL September MCMXCIII in
> <URL:news:39A504AA.1BBFF40F@yahoo.com>:
> //
> // You of course would fail the single requirement of 'Don't try to be cute'.
> // So far all I've seen is a juvenile attempt to avoid solving the actual proble
> // I expected as much when I first wrote the challenge. I knew that
> // cheap answers would be the first to come pouring out. As I stated in the
> // original post: I could just 'use File::Find' and be done with it.
> //
> // Is the real problem too difficult?
>
> What "real" problem? You make up a problem that can trivially be
> sold by using File::Find, you come with a list of arbitrary, silly,
> restrictions, and now you are pissed people don't come with "serious"
> solutions? Get real.
>
> Abigail
> --
> map{${+chr}=chr}map{$_=>$_^ord$"}$=+$]..3*$=/2;
> print "$J$u$s$t $a$n$o$t$h$e$r $P$e$r$l $H$a$c$k$e$r\n";
And yet no solution is forthcoming. Even if you were to apply your
machinations to the code, would you not still employ those things
that the challenge forbids? Just because you hide behind octal strings,
they will ultimately represent perl code? And won't that perl code
potentially violate the rules?
Are you saying that restrictions of the type mentioned make the problem
too difficult for you to resolve?
------------------------------
Date: Thu, 24 Aug 2000 17:40:26 -0500
From: Policy Man <reljr_2@yahoo.com>
Subject: Re: Just another silly post.
Message-Id: <39A5A45A.91B763C4@yahoo.com>
brian d foy wrote:
> In article <39A5080F.3FB38B79@yahoo.com>, Policy Man <reljr_2@yahoo.com> posted:
>
> > brian d foy wrote:
> >
> > > In article <39A48859.B8FA1697@yahoo.com>, Policy Man <reljr_2@yahoo.com> posted:
>
> > > > eval (<>) ;
>
> > > > apparently produces nothing.
>
> > > give it some input. see the docs on the <> operator.
>
> > Brian, perhaps I'm unable to communicate the basic fact that
> > this code must actually function inside a larger body of code.
>
> i think you are unable to communicate why i should care. if you
> don't like the solution, ignore it.
>
> > I am aware of the <> operator. I just don't see how it fits with the requirements I made.
>
> i don't see how it doesn't.
>
> you wanted a solution. i gave you one. don't cry because i got
> around your contrived and stupid requirements.
>
Actually I would be very pleased if you had 'gotten around' my requirements!
Are you saying that you believe you have a solution,
but are unable to show working code?
------------------------------
Date: Thu, 24 Aug 2000 22:45:02 GMT
From: marcel@codewerk.com (Marcel Grunauer)
Subject: Re: Just another silly post.
Message-Id: <slrn8qb9bb.3l1.marcel@gandalf.local>
On Thu, 24 Aug 2000 17:37:08 -0500, Policy Man <reljr_2@yahoo.com> wrote:
>Abigail wrote:
>
>> What "real" problem? You make up a problem that can trivially be
>> sold by using File::Find, you come with a list of arbitrary, silly,
>> restrictions, and now you are pissed people don't come with "serious"
>> solutions? Get real.
>
>And yet no solution is forthcoming. Even if you were to apply your
>machinations to the code, would you not still employ those things
>that the challenge forbids? Just because you hide behind octal strings,
>they will ultimately represent perl code? And won't that perl code
>potentially violate the rules?
>
>Are you saying that restrictions of the type mentioned make the problem
>too difficult for you to resolve?
No, I think the idea is that there are enough real (read: not purposely
constructed) issues to deal with than your homework.
*plonk*
--
Marcel Gr\"unauer - Codewerk plc . . . . . . . . . . . <http://www.codewerk.com>
Perl Consulting, Programming, Training, Code review . . . <marcel@codewerk.com>
mod_perl, XML solutions - email for consultancy availability
sub AUTOLOAD{($_=$AUTOLOAD)=~s;^.*::;;;y;_; ;;print} Just_Another_Perl_Hacker();
------------------------------
Date: Thu, 24 Aug 2000 23:12:36 GMT
From: mgjv@verbruggen.comdyn.com.au (Martien Verbruggen)
Subject: Re: Just another silly post.
Message-Id: <slrn8qbaue.ma.mgjv@verbruggen.comdyn.com.au>
On Thu, 24 Aug 2000 17:28:54 -0500,
Policy Man <reljr_2@yahoo.com> wrote:
> Martien Verbruggen wrote:
> >
> > $ perl -Mstrict -wle 'sub f(){opendir(D,$/=$_)&&map{-d&&!-l&&&f,print} \
> > map"$//$_",grep!/^\.\.?$/,readdir D}map{f,print}@ARGV'
>
> You violated the rule concerning using named subroutines other than those
> available in the base perl install. 'f' is a named subroutine. Can you make it work
> with that rule in place?
More clobbering of builtins.
{$~=sub{opendir(D,$/=$_)&&map{!-l&&$~->(),print}map"$//$_",\
grep!/^\.\.?$/,readdir D}}map{$~->(),print}@ARGV
Slightly less, again, but longer
{$~=sub{opendir(D,$_[0])&&map{!-l&&$~->($_),print}map"$_[0]/$_",\
grep!/^\.\.?$/,readdir D}}map{$~->($_),print}@ARGV
Well placed encapsulating blocks with local could prevent that, but it
would make it all unnecessarily long.
Martien
--
Martien Verbruggen |
Interactive Media Division | That's not a lie, it's a
Commercial Dynamics Pty. Ltd. | terminological inexactitude.
NSW, Australia |
------------------------------
Date: Thu, 24 Aug 2000 23:13:50 GMT
From: mgjv@verbruggen.comdyn.com.au (Martien Verbruggen)
Subject: Re: Just another silly post.
Message-Id: <slrn8qbb0n.ma.mgjv@verbruggen.comdyn.com.au>
On Thu, 24 Aug 2000 05:57:38 GMT,
Joe C. Hecht <joehecht@code4sale.com> wrote:
> > I have a challenge for you.
>
> Is this a homework assignment you need help with?
Anyone coming up with homework assignments like that shouldn't be
teaching Perl. Half of those restrictions are arbitrary, silly, and
contrary to good programming practice.
Martien
--
Martien Verbruggen |
Interactive Media Division | Hi, John here, what's the root
Commercial Dynamics Pty. Ltd. | password?
NSW, Australia |
------------------------------
Date: 24 Aug 2000 23:18:24 GMT
From: hudson@swcp.com (Tramm Hudson)
Subject: Re: Just another silly post.
Message-Id: <8o4ag0$alo$1@sloth.swcp.com>
Martien Verbruggen wrote a reasonable answer to a silly problem:
> $ perl -Mstrict -wle 'sub f(){opendir(D,$/=$_)&&map{-d&&!-l&&&f,print} \
> map"$//$_",grep!/^\.\.?$/,readdir D}map{f,print}@ARGV'
To which Policy Man <reljr_2@yahoo.com> contested:
>You violated the rule concerning using named subroutines other than those
>available in the base perl install. 'f' is a named subroutine. Can you
>make it work with that rule in place?
Ok, so assign it as a code reference. If you don't like using a named
function, then use one of those "special" variables that you allow,
such as $1:
perl -Mstrict -wle '*1=sub{opendir(D,$/=$_)&&map{-d&&!-l&&&{*1},print} \
map"$//$_",grep!/^\.\.?$/,readdir D}and map{&{*1},print} @ARGV'
>> > -- named variables other than specials like: '$_ @_ $1 $2 $#' etc. and
>> > the array @given.
You forgot to point out that he used the glob D. How can you claim
to be pedantic?
--
o hudson@swcp.com hudson@turbolabs.com O___|
/|\ http://www.swcp.com/~hudson/ H 505.323.38.81 /\ \_
<< KC5RNF @ N5YYF.NM.AMPR.ORG W 505.986.60.75 \ \/\_\
0 U \_ |
------------------------------
Date: Thu, 24 Aug 2000 19:53:22 -0400
From: brian@smithrenaud.com (brian d foy)
Subject: Re: Just another silly post.
Message-Id: <brian-ya02408000R2408001953220001@news.panix.com>
In article <39A5A45A.91B763C4@yahoo.com>, Policy Man <reljr_2@yahoo.com> posted:
> brian d foy wrote:
> Actually I would be very pleased if you had 'gotten around' my requirements!
no you wouldn't.
> Are you saying that you believe you have a solution,
> but are unable to show working code?
i showed a family of solutions. the rest is just details, and
uninteresting ones at that.
my guess is that you can't come up with a solution yourself,
which means you have nothing to add.
--
brian d foy
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Mongers <URL:http://www.perl.org/>
------------------------------
Date: Thu, 24 Aug 2000 19:09:31 -0500
From: Policy Man <reljr_2@yahoo.com>
Subject: Re: Just another silly post.
Message-Id: <39A5B93B.2338D07A@yahoo.com>
Marcel Grunauer wrote:
>
> >Are you saying that restrictions of the type mentioned make the problem
> >too difficult for you to resolve?
>
> No, I think the idea is that there are enough real (read: not purposely
> constructed) issues to deal with than your homework.
>
> *plonk*
>
What is your point? The original challenge message begins with:
<<EOT;
Please feel very free to ignore this silly post. If you find yourself
irritated or angered by this post please review the previous sentence.
This is for those of us with disposable time to spare, who love to be
clever with perl, and who don't mind being challenged by some idiot
like me with a crazy notion in his head.
I have a challenge for you.
EOT
If there were a requirement that usenet keep its nose to the grindstone,
and perhaps you think there should be one, this challenge would be
out of place. I don't remember any such restrictions on this newsgroup.
I must confess being amused by the fact that more than one person has
assumed that my post is homework. Even if it was, what difference would
it make to you? "Oh my goodness, that evil man got caught with his hands
in the forbidden usenet cookie jar" said the Usenet prude.
Live a little!
------------------------------
Date: Fri, 25 Aug 2000 00:31:40 GMT
From: mgjv@verbruggen.comdyn.com.au (Martien Verbruggen)
Subject: Re: Just another silly post.
Message-Id: <slrn8qbfim.ma.mgjv@verbruggen.comdyn.com.au>
On 24 Aug 2000 23:18:24 GMT,
Tramm Hudson <hudson@swcp.com> wrote:
>
> You forgot to point out that he used the glob D. How can you claim
> to be pedantic?
In my other post I was being more pedantic, but incorrect. You
probably meant that the dirhandle D is named, not a predefined
or builtin. The fact that there is no glob involved is really beside
the issue...
To fix, replace D with *_. It's one character longer, since you can
get rid of a space.
{$~=sub{opendir(*_,$_[0])&&map{!-l&&$~->($_),print}map"$_[0]/$_",\
grep!/^\.\.?$/,readdir*_}}map{$~->($_),print}@ARGV
*sigh*
I should probably kill the thread now.
Martien
--
Martien Verbruggen |
Interactive Media Division | We are born naked, wet and hungry.
Commercial Dynamics Pty. Ltd. | Then things get worse.
NSW, Australia |
------------------------------
Date: Fri, 25 Aug 2000 00:37:39 GMT
From: mgjv@verbruggen.comdyn.com.au (Martien Verbruggen)
Subject: Re: Just another silly post.
Message-Id: <slrn8qbfts.ma.mgjv@verbruggen.comdyn.com.au>
On 24 Aug 2000 23:18:24 GMT,
Tramm Hudson <hudson@swcp.com> wrote:
>
> You forgot to point out that he used the glob D. How can you claim
> to be pedantic?
Well... pedants would probably point out that I am not really using
the glob, but the dirhandle, which is not the whole glob :)
Martien
--
Martien Verbruggen |
Interactive Media Division | If at first you don't succeed,
Commercial Dynamics Pty. Ltd. | destroy all evidence that you tried.
NSW, Australia |
------------------------------
Date: Thu, 24 Aug 2000 17:27:03 -0700
From: "Lauren Smith" <lauren_smith13@hotmail.com>
Subject: Re: Just another silly post.
Message-Id: <8o4ecv$bbg$1@brokaw.wa.com>
Policy Man <reljr_2@yahoo.com> wrote in message
news:39A5B93B.2338D07A@yahoo.com...
<snip conversation>
Hi Policy Man. Instead of whacking everyone here over the head with a
yardstick, how about showing us the solution that you've got? I think it'd
be an interesting thing to see.
Lauren
--
print grep ord $_,map{y/a-zA-Z//d;$x.="+ $_";chr(eval $x)}
'J74u43-s2tA1-84n33o45th1er5-12-P3e13-82r48l21H13-a6-76
c40k25er2wx8-y6z13-81'=~m#([^!\n]{3})#g#tr/-0-9//d;print
------------------------------
Date: Fri, 25 Aug 2000 00:39:07 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Just another silly post.
Message-Id: <sqbg1bbt9184@corp.supernews.com>
Policy Man (reljr_2@yahoo.com) wrote:
: Please feel very free to ignore this silly post. If you find yourself
: irritated or angered by this post please review the previous sentence.
I'm not sure if this meets the named sub restriction or not, because of
its recursion:
#!/usr/bin/perl -w
# dirx - satisfy an insane dir-listing challenge
# Craig Berry (20000824)
use strict;
my @given = @ARGV;
print join "\n", dirx(@given);
sub dirx { map { -l $_ ? () : -d $_ ? (dirx(glob("$_/*")), $_) : $_ } @_ }
--
| Craig Berry - http://www.cinenet.net/~cberry/
--*-- "Every force evolves a form."
| - Shriekback
------------------------------
Date: Thu, 24 Aug 2000 19:57:59 -0500
From: Policy Man <reljr_2@yahoo.com>
Subject: Re: Just another silly post.
Message-Id: <39A5C497.340E9D50@yahoo.com>
Lauren Smith wrote:
> Policy Man <reljr_2@yahoo.com> wrote in message
> news:39A5B93B.2338D07A@yahoo.com...
> <snip conversation>
>
> Hi Policy Man. Instead of whacking everyone here over the head with a
> yardstick, how about showing us the solution that you've got? I think it'd
> be an interesting thing to see.
>
> Lauren
> --
> print grep ord $_,map{y/a-zA-Z//d;$x.="+ $_";chr(eval $x)}
> 'J74u43-s2tA1-84n33o45th1er5-12-P3e13-82r48l21H13-a6-76
> c40k25er2wx8-y6z13-81'=~m#([^!\n]{3})#g#tr/-0-9//d;print
Sorry for the whacking. The challenge is a bit brutal, but hey,
it wouldn't be a challenge w/o some silly restrictions.
Do you really want it now? I'm more than willing to do so, but
I'm afraid that someone may be diligently working on this in
the background, and if they had the same code I had it might
prove very disappointing to them.
If I get so much as one more request along these lines
I'll give it up, and btw it is a fun bit-o-code.
I really hope Brian D Foy can come up with a working version
using eval, as mine does not. I left eval in the list of acceptable
keywords because I had a sneaking suspicion it had the potential
to work.
------------------------------
Date: Fri, 25 Aug 2000 00:51:32 GMT
From: satyapal_deja@my-deja.com
Subject: Listing files in Subdirectories
Message-Id: <8o4fuc$ld$1@nnrp1.deja.com>
I can get list of all files in the current directory by using:
@files = <*.html>
How do I get list of all the files in all the subdirectories. Any file
thus listed should be having the directory name in front of it.
e.g. If I have a file myHtml.html in the sub directory 'mySubDirectory'
it should be listed as mySubDirectory/myHtml.html.
Basically I need to replace a piece of text in all the html files.
Appreciate any help...
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 24 Aug 2000 20:01:50 -0400
From: darkon@one.net (David Wall)
Subject: Re: Please wait... [was: Perl - Blinking Text]
Message-Id: <8F9AC091Ddarkononenet@206.112.192.118>
How about approximating e using random numbers? :-)
random_e(10000);
sub random_e {
my $max=shift;
my $l=length $max;
my ($t, $e) = (1, 0);
print "\n";
while ($t <= $max) {
my ($s, $n) = 0 x 2;
$n++, $s += rand(1) while $s < 1;
$e = ( ($t-1) * $e + $n)/$t;
printf "\te = %12.10f, t=%${l}u\r", $e, $t;
$t++;
}
print "Using $max trials, e was found to be approximately $e\n\n";
}
--
David Wall
darkon@one.net
------------------------------
Date: 24 Aug 2000 22:25:49 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Quick way to determine if a method is implemented in OO module
Message-Id: <slrn8qb861.tj3.abigail@alexandra.foad.org>
Jeffrey Horn (horn@wheel.cs.wisc.edu) wrote on MMDL September MCMXCIII in
<URL:news:8o3lbc$e62@spool.cs.wisc.edu>:
__ Given an OO module, what is the fastest (best?) way to determine if the modul
__ implements a given method?
You use "can". But no method, short of solving the halting problem, will
tell you whether something is implemented using AUTOLOAD.
__ The specific case I have in mind is determining whether or not a DBD module
__ implements the 'reauthenticate' method. Is there a way to check the internal
__ symbol table to look for given subroutines?
Yes, but that has nothing to do with the "best way" of solving your problem.
Abigail
--
echo "==== ======= ==== ======"|perl -pes/=/J/|perl -pes/==/us/|perl -pes/=/t/\
|perl -pes/=/A/|perl -pes/=/n/|perl -pes/=/o/|perl -pes/==/th/|perl -pes/=/e/\
|perl -pes/=/r/|perl -pes/=/P/|perl -pes/=/e/|perl -pes/==/rl/|perl -pes/=/H/\
|perl -pes/=/a/|perl -pes/=/c/|perl -pes/=/k/|perl -pes/==/er/|perl -pes/=/./;
------------------------------
Date: Fri, 25 Aug 2000 01:10:18 +0200
From: sumus@aut.dk (Jakob Schmidt)
Subject: Re: RegEx
Message-Id: <1efwas0.84ui7f1mcn35sN@[192.168.88.117]>
<zejames@my-deja.com> wrote:
> $name = "/usr/local/bin/perl";
>
> ($test) = ( $name =~ m#/(.*)# );
>
> print "$test\n";
>
> Why do I see usr/local/bin/perl on my screen
You see usr/local/bin/perl because . matches _any_ character (except
"\n" by default). Also '/'.
If what you expected was /usr/local/bin/perl you sould've included the
slash in the parens:
m#(/.*)#
If what you expected was 'perl' you could have done either
m#.*/(.*)#
which works because the first .* gets the first shot at being greedy or
m#/([^/]*)$#
since [^/] matches everything that's not '/' and $ indicates the end of
the string.
Now I know this wasn't very funny compared to the developments in other
parts of this thread but perhaps I actually answered the question?
--
Jakob
------------------------------
Date: Fri, 25 Aug 2000 01:40:00 -0500
From: "Dietmar Staab" <dietmar.staab@t-online.de>
Subject: Re: RegEx
Message-Id: <8o4bp4$4gf$14$1@news.t-online.com>
In article <39A57DBC.94DDF723@attglobal.net>, Drew Simonis
<care227@attglobal.net> wrote:
>
> This behaviour is discussed (although not very completely IMO) in the
> perlop manpage.
> http://www.perl.com/pub/doc/manual/html/pod/perlop.html#Regexp_Quote_Like_Operators
The manpage explains it quite clear, thanks.
------------------------------
Date: Fri, 25 Aug 2000 01:55:02 -0500
From: "Dietmar Staab" <dietmar.staab@t-online.de>
Subject: Re: RegEx
Message-Id: <8o4cl9$32f$10$1@news.t-online.com>
In article <MPG.140f1f11b9e4483198acdc@nntp.hpl.hp.com>, Larry Rosler
<lr@hpl.hp.com> wrote:
>
> Grüß!
>
Mache ich. Aber wen denn?
------------------------------
Date: Thu, 24 Aug 2000 22:35:01 GMT
From: james_69yay@my-deja.com
Subject: SMTP in formmail
Message-Id: <8o47uk$n8l$1@nnrp1.deja.com>
My server host tells me my perl script lacks a "send to address", which
it says is an SMTP address.
Could anyone tell me where (in my sendmail routine?) I need to place
such a reference?
I can post some excerpts from the script if that helps...
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 24 Aug 2000 22:30:01 GMT
From: "Scott" <shamilton@plateausystems.holdthespam.com>
Subject: Stumped by Reg Exp Problem - help??
Message-Id: <Jlhp5.68969$eS6.1004311@news1.rdc1.md.home.com>
In short, I want to be able to quickly scan through a file and convert all
web http addresses into HTML links. So far, this is fairly easy (after much
experimentation I came up with $data =~
s/(http:\/\/[\w\/\-~]*(\.[\w\/\-~]+)+)/<a href="$1">$1<\/a>/ig).
Here's what I can't figure out, though: if the link in question is ALREADY
formatted as an HTML link, then I don't want to perform the conversion,
otherwise things get REAL messy.
So, is there a way to format the reg exp such that it is only executed if
the target string is NOT found within certain other strings? For instance,
I'd like to say, replace all instances of XYZ so long as it is not residing
BETWEEN <a\s* and <\/a>.
Is it even possible?
Thanks in advance,
Scott
------------------------------
Date: Fri, 25 Aug 2000 01:21:55 +0200
From: sumus@aut.dk (Jakob Schmidt)
Subject: Re: Stumped by Reg Exp Problem - help??
Message-Id: <1efwbhu.synn371ehvck6N@[192.168.88.117]>
Scott <shamilton@plateausystems.holdthespam.com> wrote:
> replace all instances of XYZ so long as it is not residing
> BETWEEN <a\s* and <\/a>.
>
> Is it even possible?
It's possible. Check the explanation of '(?!regexp)' in perlre.
Oh and a bit of free advise: Use some other char than '/' ('#' for
instance) to separate the parts in your substitution. Then you won't
have to escape slashes with backslashes and the whole thing will be a
lot more readable.
s#/#slash#.....
--
Jakob
------------------------------
Date: Thu, 24 Aug 2000 15:30:15 -0700
From: TEC <travis.cox@itron.com>
Subject: Re: trying to pull each string from file to evaluate...
Message-Id: <39A5A1F7.C3AE8A40@itron.com>
I'm not real clear on if you just want to keep evaluating the last line of a file (as it gets written
to) or if you want to remove the last line and evaluate it. If the former then try this. I have used
this to parse lines in a log file as an application is running. This works on log files that are
appended to every time the application is ran if the script is started before the application. (The
seek(LOG, 0 1) resets the end of file condition so that a new line written to the file can be read).
$starttime = time;
$timeout = 3600;
open(LOG, $filename) || die $!;
seek(LOG, 0, 2); # goes to end of file. comment out if you want to start at beginning.
while ((time - $starttime) < $timeout) { # If application locks up don't loop forever
$line = <LOG>;
&ParseLogMessage($line); #Subroutine can exit script based on parsed messages
select(undef, undef, undef, 0.25); # Sleep for a quarter second so we don't use too many CPU's
seek(LOG, 0, 1);
}
HTH (Just another Abigail Fan)
Keith Gasper wrote:
> Hi everyone. I'm attempting to write a perl script that removes each string from
> a text file and evaluates it. I know it is possilbe to remove the last line of a text from the
> http://www.perl.com/pub/doc/manual/html/pod/perlfaq5.html#How_do_I_change_one_line_in_a_fi
> document... however, it doesn't give a description of how you go about actually removing
> from the very end of the file...
> I have written a batch file that stops various services on a server on our intranet remotely. The
> batch file fires all of the commands at once and oftentimes returns a success message before the
> services are actually stopped/started. I'm writing the script to repeatedly get the URL of the
> webpage whose service I'm stopping. Each time perl gets the text provided by the URL, I'd like
> to search for the error message that appears when the service is not running. The script will
> stop once the error message is not present (and the service is running). I just need to figure out
> how to grab the last line of the file, evaluate it, then throw it away and grab the next line.
> ANY IDEAS? Thanks so much. Much appreciation. happy coding
> Keith
------------------------------
Date: Fri, 25 Aug 2000 00:35:49 +0200
From: tony@svanstrom.com (Tony L. Svanstrom)
Subject: Re: Where is the Perl Newbie or Begginers group?
Message-Id: <1efw9hw.52wn3a1rfrc14N%tony@svanstrom.com>
sysnovice <gdonovanNOgdSPAM@jeffco.k12.co.us.invalid> wrote:
> I am a Unix SysAd with no programming experience looking for a discussion
> group for Perl beginners like myself that don't have a clue. I'm so new I
> don't even know where to find FAQ's. It's evident that from many postings
> here that the experienced Perl programmers are more than a bit annoyed
> with folks like myself posting "dumb" questions. Does someone out there
> know of a group for the retarded perl wanabes? If I could find such a
> place I would address all my questions there until the year 2025 when I
> may have a question intelligent enough for this discussion group.
Personally I feel that you learn a lot more when you always have to ask
yourself "is this a dumb question?" before you post; not that that
always helps. Right now I'm trying to forget the stupid \n-related
posting I made, I can't believe that I wrote what I wrote; and I'm
considering posting via anonymousremailers from now on... ;-)
/Tony
--
/\___/\ Who would you like to read your messages today? /\___/\
\_@ @_/ Protect your privacy: <http://www.pgpi.com/> \_@ @_/
--oOO-(_)-OOo---------------------------------------------oOO-(_)-OOo--
on the verge of frenzy - i think my mask of sanity is about to slip
---ôôô---ôôô-----------------------------------------------ôôô---ôôô---
\O/ \O/ ©99-00 <http://www.svanstrom.com/?ref=news> \O/ \O/
------------------------------
Date: Thu, 24 Aug 2000 23:06:45 GMT
From: johnvert@my-deja.com
Subject: Word in the middle.
Message-Id: <8o49pn$pbf$1@nnrp1.deja.com>
Hi, I have the following to extract word in the middle:
my $str = "hello world hello";
$str =~ s/\W+(\w)\W+/$1/;
print $str . "\n";
but it does not give me the right results. Why? I'm basically saying
"match non-word, followed by word which you keep in memory, and another
non-word, then put the word in memory in $str".
thanks,
-- John
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Fri, 25 Aug 2000 01:32:19 +0200
From: sumus@aut.dk (Jakob Schmidt)
Subject: Re: Word in the middle.
Message-Id: <1efwbwh.1362za8hh8hl1N@[192.168.88.117]>
<johnvert@my-deja.com> wrote:
> my $str = "hello world hello";
> $str =~ s/\W+(\w)\W+/$1/;
> print $str . "\n";
Well \w only matches a sincle char. If you want a word go \w+ inside
your parens.
my $str = "hello world hello";
$str =~ s/\W+(\w+)\W+/$1/;
print "$str\n";
Now it'll match and 'world' will be in $1. Thus 'helloworldhello' will
be in $str which probably isn't what you wanted either, was it?
Well you're substitutin the whitespace plus middle word plus whitespace
for just the word so you get what you ask for.
If what you wanted was for the middle word to be all that's left in $str
you could s/.*\W+(\w+)\W+.*/$1/ but I think
$str =~ /\W+(\w+)\W+/;
$str = $1;
or
( $str ) = $str =~ /\W+(\w+)\W+/;
is more elegant.
--
Jakob
------------------------------
Date: Thu, 24 Aug 2000 16:50:34 -0700
From: "Lauren Smith" <lauren_smith13@hotmail.com>
Subject: Re: Word in the middle.
Message-Id: <8o4c8i$ad8$1@brokaw.wa.com>
<johnvert@my-deja.com> wrote in message news:8o49pn$pbf$1@nnrp1.deja.com...
> Hi, I have the following to extract word in the middle:
>
> my $str = "hello world hello";
> $str =~ s/\W+(\w)\W+/$1/;
Your RE is matching one or more non-word characters, followed by a word
character, followed by one or more non-word characters. This particular RE
never matches your string.
> but it does not give me the right results. Why? I'm basically saying
> "match non-word, followed by word which you keep in memory, and another
> non-word, then put the word in memory in $str".
Something like:
$str = $1 if $str =~ /\W(\w+?)\W/;
But then again, why would you specify the second '\W' if you are going to
match all the characters of the second word?
$str = $1 if $str =~ /\W(\w+)/;
Of course this fails if the string has a space or some other non-word
character at the beginning. (i.e. ' hello world hello' => $str = 'hello')
This will search for a first word, then capture the second word:
$str = $1 if $str =~ /\w+\W+(\w+)/;
HTH,
Lauren
--
print grep ord $_,map{y/a-zA-Z//d;$x.="+ $_";chr(eval $x)}
'J74u43-s2tA1-84n33o45th1er5-12-P3e13-82r48l21H13-a6-76
c40k25er2wx8-y6z13-81'=~m#([^!\n]{3})#g#tr/-0-9//d;print
------------------------------
Date: Fri, 25 Aug 2000 00:45:06 GMT
From: Jim Mauldin <mauldin@netstorm.net>
Subject: Re: Word in the middle.
Message-Id: <39A5C10C.461E396D@netstorm.net>
johnvert@my-deja.com wrote:
>
> Hi, I have the following to extract word in the middle:
>
> my $str = "hello world hello";
> $str =~ s/\W+(\w)\W+/$1/;
> print $str . "\n";
>
To extract ($str is still the same after)
print +($str=~ /(\w+)/g)[1]; # See perlop (Regexp quote-like operators)
or (easier to understand)
my @q = $str=~ /(\w+)/g; print $q[1];
or
print (split ' ',$str)[1]; # perldoc -f split
or (easier to understand)
my @q = split ' ',$str; print $q[1];
To replace: ($str contains only second word)
$str =~ s/\w+\W(\w+).*/$1/;
-- Jim
------------------------------
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 4125
**************************************