[25894] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 8122 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 27 18:05:29 2005

Date: Fri, 27 May 2005 15:05:08 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 27 May 2005     Volume: 10 Number: 8122

Today's topics:
    Re: finding the PID of a process running as an anonymou <nobull@mail.com>
    Re: Force interpolation of single quoted character <nobull@mail.com>
    Re: Force interpolation of single quoted character <nobull@mail.com>
        new how-to book about tit-fucking <69-no-spam@69.69.69.69.invalid>
    Re: new how-to book about tit-fucking <misterlister169@gmail.com>
    Re: output question <tadmc@augustmail.com>
        Regex - disincluding strings in a match <stevo@berkeley.edu>
    Re: Regex - disincluding strings in a match <emschwar@pobox.com>
    Re: Regex - disincluding strings in a match <pilkowsk@informatik.uni-marburg.de>
    Re: Regex - disincluding strings in a match <apeiron+usenet@coitusmentis.info>
    Re: Regex - disincluding strings in a match xhoster@gmail.com
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Fri, 27 May 2005 19:22:33 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: finding the PID of a process running as an anonymous pipe
Message-Id: <d77ohd$42o$1@slavica.ukpost.com>

Richard wrote:

> I need to find the PID of a process running as an anonymous pipe,

I know you've no RTDMed at Anno's suggestion so I won't adderess that.

>    $fh = new FileHandle;

In recent Perl the above is redundant - open() autovivifies.

>    open($fh, "tail -f $filename |") or die ..........

In recent perl rather than combining the mode and all the exec() 
arguments into a string and having perl (or even /bin/sh) pull them 
appart again, you can acually give them as a list.  This is far cleaner.

    open($fh, '-|', 'tail', '-f', $filename) or die ..........


------------------------------

Date: Fri, 27 May 2005 19:41:20 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: Force interpolation of single quoted character
Message-Id: <d77pkf$473$1@slavica.ukpost.com>

Scott Bass wrote:

> "Tad McClellan" <tadmc@augustmail.com> wrote in message 
> news:slrnd9edoo.ci8.tadmc@magna.augustmail.com...

[snip Tad ]

> Brian,

It would keep the thread cleaner if you were to post the follow-up to me 
as a follow-up to me.

> based on your replies, I skimmed all the FAQ's, esp. perlfaq4.  Can I 
> have a hint as to which FAQ this is explained?

The question you are asking _is_ frequently asked, but I think I'd 
confused myself and then in turn you too.

The FAQ "How do I unescape a string?" does _not_ answer your question. 
Nor does the FAQ "How can I expand variables in text strings?".

Both of these _should_ IMNSHO mention the chop-eval-heredoc solution if 
only so that they can explain when it is unsafe to use.  I have in the 
past battled with FAQ maintainers on this issue but never got very far.

I have to confess that I mis-remebered the FAQ "How do I unescape a 
string?" as giving Tad's solution.  May I be placed in virtual stocks 
and pelted with virtual rotten fruit for not checking my facts before I 
posted.


------------------------------

Date: Fri, 27 May 2005 19:53:57 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: Force interpolation of single quoted character
Message-Id: <d77qc7$480$1@slavica.ukpost.com>



Brian McCauley wrote:

> Both of these _should_ IMNSHO mention the chop-eval-heredoc solution if 
> only so that they can explain when it is unsafe to use.

BTW: here's a slightly safer eval based solution

s/(\\[^"\$\@]+)/qq("$1")/eeg;

Note that's not 100% infalible but AFAIK it's not a security problem and 
  copes with all reasonable strings.  It does have the interesting side 
effect of stripping \$ \" and \@ - but those have no buisness being in 
the strings you are talking about.


------------------------------

Date: Fri, 27 May 2005 21:50:46 +0200 (CEST)
From: "Agent 69" <69-no-spam@69.69.69.69.invalid>
Subject: new how-to book about tit-fucking
Message-Id: <cDIzMTA=.cf5fc0afc97131ac62259e9aef548d7b@1117223446.nulluser.com>


-- 
Agent 69
alt.drugs.hydromorphone

"...some say true comedy is the work of genius. I disagree, the 
funniest shit I ever saw was all the work of halfwits."
-- Si, in alt.drugs.hard, 5. May 2005




------------------------------

Date: Fri, 27 May 2005 20:16:26 GMT
From: Lister <misterlister169@gmail.com>
Subject: Re: new how-to book about tit-fucking
Message-Id: <fvve911la4kr5m9nbkpgv8752e4dikej2g@4ax.com>

On Fri, 27 May 2005 21:50:46 +0200 (CEST), "Agent 69"
<69-no-spam@69.69.69.69.invalid> wrote:



Did you mean to say something or were you too busy tit fucking
someone?


------------------------------

Date: Fri, 27 May 2005 16:10:38 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: output question
Message-Id: <slrnd9f36e.dl6.tadmc@magna.augustmail.com>

Huub <> wrote:

>> You do know that you don't need format() to make output, don't you?
> 
>  From the tutorial I'm studying, I understood I needed format() 
> to write to an outputfile.


Sounds like you are attempting to learn from a foolish tutorial
(there are lots of those).

Which tutorial are you studying?


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: Fri, 27 May 2005 13:25:14 -0700
From: "Steve Chiang" <stevo@berkeley.edu>
Subject: Regex - disincluding strings in a match
Message-Id: <d77vmu$1a42$1@geode.berkeley.edu>

Hello,

How would one disinclue a string in a match?  For example, I want to match 
the next animal that comes after "dog", but don't want to match "dog":

cat cow dog monkey zebra

 ... so I would want to match only "monkey".  However, the order of the items 
in the list may change anytime:

zebra monkey dog cow cat

 ... so I would want to match only "cow" in this case since it follows "dog" 
directly.  Further, I am limited in that I cannot use back-references for 
this.

Thanks,
Steve 




------------------------------

Date: Fri, 27 May 2005 14:36:48 -0600
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: Regex - disincluding strings in a match
Message-Id: <etohdgoiexr.fsf@wilson.emschwar>

"Steve Chiang" <stevo@berkeley.edu> writes:
> How would one disinclue a string in a match?  For example, I want to match 
> the next animal that comes after "dog", but don't want to match "dog":
>
> cat cow dog monkey zebra

my $string = "cat cow dog monkey zebra";
my $animal = "dog";
my (undef, $match) = $string =~ /(\Q$animal\E) (?!\1)(\w+)/;
print "Match: [$match]\n";

Look up "negative lookahead" in perlre for more details.

> ... so I would want to match only "cow" in this case since it follows "dog" 
> directly.  Further, I am limited in that I cannot use back-references for 
> this.

Why not?  Perl supports backreferences.  If you're trying to do this
in a non-Perl language that supports regexes, then you'd best ask
there; regexes very a LOT between languages, and the only way to know
for sure is to check the docs for whatever language you're using.

Anyway, I'm sure you can see how to avoid backreferences in that code;
I'll leave eliminating them as an exercise for the reader.

-=Eric
-- 
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
		-- Blair Houghton.


------------------------------

Date: Fri, 27 May 2005 23:11:17 +0200
From: Fabian Pilkowski <pilkowsk@informatik.uni-marburg.de>
Subject: Re: Regex - disincluding strings in a match
Message-Id: <3fpgmsF8u46hU1@individual.net>

* Steve Chiang schrieb:
> 
> How would one disinclue a string in a match?  For example, I want to match 
> the next animal that comes after "dog", but don't want to match "dog":
> 
> cat cow dog monkey zebra
> 
> ... so I would want to match only "monkey".

> Further, I am limited in that I cannot use back-references for 
> this.

You could use a technique called "zero-width positive look-behind" and
is described in `perldoc perlre`. Unless you have perl installed on your
system read this document at <http://perldoc.perl.org/perlre.html>.

    my $string = "cat cow dog monkey zebra";
    print $string =~ m/(?<=dog\s)\S*/g;
    __END__
    monkey

regards,
fabian


------------------------------

Date: 27 May 2005 21:45:05 GMT
From: Christopher Nehren <apeiron+usenet@coitusmentis.info>
Subject: Re: Regex - disincluding strings in a match
Message-Id: <slrnd9f571.4ad.apeiron+usenet@prophecy.dyndns.org>

On 2005-05-27, Steve Chiang scribbled these
curious markings:
> Further, I am limited in that I cannot use back-references for this.

Then perhaps you should ask your teacher for help if you can't figure it
out on your own.

Best Regards,
Christopher Nehren
-- 
I abhor a system designed for the "user", if that word is a coded
pejorative meaning "stupid and unsophisticated". -- Ken Thompson
If you ask the wrong people questions, you get "Joel on Software".
Unix is user friendly. However, it isn't idiot friendly.


------------------------------

Date: 27 May 2005 21:50:45 GMT
From: xhoster@gmail.com
Subject: Re: Regex - disincluding strings in a match
Message-Id: <20050527175045.877$iO@newsreader.com>

"Steve Chiang" <stevo@berkeley.edu> wrote:
> Hello,
>
> How would one disinclue a string in a match?  For example, I want to
> match the next animal that comes after "dog", but don't want to match
> "dog":

You either match the string, or you do not match the string.  You cannot
match part of a string.  You can *capture* part of a string.  Is that
what you meant to ask?

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


------------------------------

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.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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 8122
***************************************


home help back first fref pref prev next nref lref last post