[12969] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 379 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Aug 5 06:07:25 1999

Date: Thu, 5 Aug 1999 03:05:09 -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           Thu, 5 Aug 1999     Volume: 9 Number: 379

Today's topics:
    Re: [offtopic]RE:Quot St and the Jeop Gm <nospam.newton@gmx.net>
    Re: Cannot get pws to run perl scripts <rhrh@hotmail.com>
        Complex data structure julmajuha@my-deja.com
    Re: Complex data structure <derek@dstc.com>
    Re: Cookie the only way? (Bart Lateur)
    Re: How can I know what modules are installed on server (Anno Siegel)
    Re: How do I open another browser window using Perl? (Graham Ashton)
    Re: How do I open another browser window using Perl? (Andreas Fehr)
    Re: How to turn off cashing in perl??? (I.J. Garlick)
        How to uninstall Perl on Unix ? <philippe.sockeel@cdn.fr>
    Re: IMPORTANT: "19$year" <matt.sergeant@bbc.co.uk>
        NT Apache Perl <saxbourne@yahoo.com>
    Re: NT Apache Perl (Andreas Fehr)
    Re: NT Apache Perl <saxbourne@yahoo.com>
    Re: NT Apache Perl (Andreas Fehr)
    Re: NT Apache Perl <saxbourne@yahoo.com>
    Re: NT Apache Perl (Andreas Fehr)
    Re: Perl & Win95 (Andreas Fehr)
    Re: Possible to get a HTML file from somewhere and use  (Andreas Fehr)
    Re: Problem: extracting terminology from text (Sam Holden)
        regex substitutions from static strings <matt@red.net>
    Re: regexp can be your friend (Abigail)
    Re: regexp can be your friend (Abigail)
    Re: regexp can be your friend <uri@sysarch.com>
    Re: regexp can be your friend (Bart Lateur)
    Re: Regular expression for matching an e-mail address. (Bart Lateur)
        Skipping . and .. with readdir <guertin@middlebury.edu>
    Re: Skipping . and .. with readdir <uri@sysarch.com>
    Re: Skipping . and .. with readdir (Anno Siegel)
    Re: Why no Perl books at Fry's? (Malcolm Ray)
        Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)

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

Date: Thu, 05 Aug 1999 11:09:19 +0200
From: "Philip 'Yes, that's my address' Newton" <nospam.newton@gmx.net>
Subject: Re: [offtopic]RE:Quot St and the Jeop Gm
Message-Id: <37A954BF.A90FF6D6@gmx.net>

Tom Christiansen wrote:
> 
> 3) Your message was illegal: it was missing a mandatory header.

Which one's that? (Is my posting missing it, too?)

Cheers,
Philip


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

Date: Thu, 05 Aug 1999 09:10:27 +0100
From: Richard H <rhrh@hotmail.com>
Subject: Re: Cannot get pws to run perl scripts
Message-Id: <37A946F3.FE8671A8@hotmail.com>

elephant wrote:
> 
> 99% Energy writes ..
> >I have tried configuring the registry at
> >
> >\HKEY_LOCAL_MACHINES\System\CurrentControlSet\Services\w3svc\parameters\Scri
> >pt Map
> >with the following entry:  Name: .pl Data: "c:\perl\bin\perl.exe %s %s" (I
> >also tried perlis.dll %s %s) according to the the MS Knowledge base article:
> >http://support.microsoft.com/support/kb/articles/Q150/6/29.asp (thanks to
> >"elephant" jason).
> 
> did you also read the ActiveState documentation on your machine ? ..
> specifically the question "How do I configure Microsoft Personal Web
> Server 1.0x for Windows 95 to support Perl for Win32?" in perlwin32faq6
> (Web Server Config) ? .. it'll probably help .. especially the bit about
> the virtual directory with execute access
> 
> read it

Try a re-install of PWS for no apparent reason !!
If you re-install PWS, and re-enter the script map registry entry it
will most likely work,

try comp.infosystems.www.servers.ms-windows for more help.

or try using apache instead!

Richard H


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

Date: Thu, 05 Aug 1999 08:40:56 GMT
From: julmajuha@my-deja.com
Subject: Complex data structure
Message-Id: <7obimn$tpb$1@nnrp1.deja.com>

Hi!
I am struggling with the complex data structures
in PERL.
I use a hash of arrays like this :

	$Comp = "res1";
	$Codes{$Comp}[0] = 123;
	$Codes{$Comp}[1] = 321;
	$Codes{$Comp}[2] = 345;
	$Codes{$Comp}[3] = 543;

It works OK. However, I would like to do the
following :

	for $i (123, 321, 345, 543) {
		push @Codes{$Comp}, $i;
	}

The error message was :
  Scalar value @Codes{$Comp} better written as
$Codes{$Comp} at koe.pl line 6.
  Type of arg 1 to push must be array (not hash
slice) at koe.pl line 6, near "$i;"

I tried many variations of the syntax with no
success.
Eg. push @[$Codes{$Comp}], $i; ... etc.

Similarly, I want to print the codes using
foreach, something like this :

	foreach $i (@Codes{$Comp}) {
		print "Code = $i\n";
	}

Still no success. Could you give me a hint,
please.
I think the solution is easy once you know it
but...
I tried it with ActivePerl PERL 5.005_03 in WinNT
and with PERL 5.005 in Linux.

Juha Manninen


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Thu, 05 Aug 1999 19:22:12 +1000
From: Derek Thomson <derek@dstc.com>
To: julmajuha@my-deja.com
Subject: Re: Complex data structure
Message-Id: <37A957C4.6AF1FC7D@dstc.com>

julmajuha@my-deja.com wrote:
> 
> Hi!
> I am struggling with the complex data structures
> in PERL.
> I use a hash of arrays like this :
> 
>         $Comp = "res1";
>         $Codes{$Comp}[0] = 123;
>         $Codes{$Comp}[1] = 321;
>         $Codes{$Comp}[2] = 345;
>         $Codes{$Comp}[3] = 543;
> 
> It works OK. However, I would like to do the
> following :
> 
>         for $i (123, 321, 345, 543) {
>                 push @Codes{$Comp}, $i;
>         }
>
> [snip error message]
> 
> I tried many variations of the syntax with no
> success.
> Eg. push @[$Codes{$Comp}], $i; ... etc.

Instead of randomly thrashing, you could 'perldoc perldsc'. It even has
a section on hashes of lists.

> 
> Similarly, I want to print the codes using
> foreach, something like this :
> 
>         foreach $i (@Codes{$Comp}) {
>                 print "Code = $i\n";
>         }
> 
> Still no success. Could you give me a hint,
> please.
> I think the solution is easy once you know it
> but...

for $i (123, 321, 345, 543) {
  push @{$Codes{$Comp}}, $i;
}

You had created a hash to references to lists. $Codes{$Comp} gives you
the reference, and @{ ... } dereferences it, giving you the list.

This works just as well, too:

push @{$Codes{$Comp}}, (123, 321, 345, 543);

> I tried it with ActivePerl PERL 5.005_03 in WinNT
> and with PERL 5.005 in Linux.
> 
> Juha Manninen


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

Date: Thu, 05 Aug 1999 09:30:41 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Cookie the only way?
Message-Id: <37ae5802.13375500@news.skynet.be>

Jordan DeLozier wrote:

>        I need some way to pass information into the users browser and
>retrieve it if/when they click on a cgi link. Is a cookie the only way?

No. You can append extra data after the script's URL, as if the script
itself is a directory name. Look at $ENV{PATH_INFO} in your script.

>If so, could someone show me the source code to use or where to find the
>information.

There's some sample code included in the docs for CGI.pm, I believe (do
"perldoc CGI" on the command line to see them). Here's an extract:

  NETSCAPE COOKIES
        Netscape browsers versions 1.1 and higher support a so-
        called "cookie" designed to help maintain state within a
        browser session. CGI.pm has several methods that support
        cookies.

        A cookie is a name=value pair much like the named parameters...

(etc., for about 130 lines.) It  finishes with:

        See the cookie.cgi example script for some ideas on how to
        use cookies effectively.

	Bart.


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

Date: 5 Aug 1999 09:16:20 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: How can I know what modules are installed on server?
Message-Id: <7obkp4$dk9$1@lublin.zrz.tu-berlin.de>

Malcolm Ray <M.Ray@ulcc.ac.uk> wrote in comp.lang.perl.misc:

[jeopardy style quoting]

>I sometimes get the feeling that people who use your style of quoting
>don't want a dialogue at all: they just want to say their piece.

Indeed.  It is impossible to reasonably follow up to an article in
that style.  You have three choices:

- Succumb to the idiocy and put your own reply ahead of everything.
  Not only is that unpalatable, but it makes for a reply that is
  now very hard to follow.

- Interleave your reply with the material present.  Again, the flow
  of the dialog is distorted.  The connection to what went on before
  is almost impossible to find.

- Rearrange the material according to the flow of dialog.  This is
  a time-consuming task you do on behalf of the poster you are replying
  to.  It also requires you to intuit the purpose of each bit of the
  reply:  What part of the original posting is it referring to?
  And if you get it wrong, you open yourself up to the reproach of
  misrepresentation.

So the practice is not only lazy and inconsiderate, it is also
self-serving in the sense of shutting up possible objections.

Anno


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

Date: 5 Aug 1999 08:39:47 GMT
From: billynospam@mirror.bt.co.uk (Graham Ashton)
Subject: Re: How do I open another browser window using Perl?
Message-Id: <slrn7qijej.130.billynospam@wing.mirror.bt.co.uk>

In article <7obcgb$iq5$1@news.gstis.net>, DC wrote:

>I want to display a URL in another browser window and then be able to
>switch back to my original browser window where my Perl/CGI script is
>running.  Is it a simple print " line of code that ends up being HTML
>code after all?

your question would lose nothing if you removed "Perl/" from it. it's
not a Perl question, but the answer is "yes". look into the TARGET=
attribute, or ask in comp.infosystems.www.authoring.cgi (or whatever
it's called).

-- 
Graham

P.S. <billynospam@mirror.bt.co.uk> is a fully working address...


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

Date: Thu, 05 Aug 1999 08:51:20 GMT
From: backwards.saerdna@srm.hc (Andreas Fehr)
Subject: Re: How do I open another browser window using Perl?
Message-Id: <37a94cb1.11731699@news.uniplus.ch>

On Thu, 5 Aug 1999 00:56:40 -0600, "DC" <church@NOSPAMspinn.net>
wrote:

>I want to display a URL in another browser window and then be able to switch
>back to my original browser window where my Perl/CGI script is running.

Hmmm, where does your Perl run?

>                                                                         Is
>it a simple print " line of code that ends up being HTML code after all?

Don't understand...

Andreas


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

Date: Thu, 5 Aug 1999 09:25:55 GMT
From: ijg@connect.org.uk (I.J. Garlick)
Subject: Re: How to turn off cashing in perl???
Message-Id: <FFzJJ7.1Bt@csc.liv.ac.uk>

In article <37A8DDB8.C37F51F4@mail.cor.epa.gov>,
David Cassell <cassell@mail.cor.epa.gov> writes:
> Scott wrote:
> You'll want to look up buffering.  Type:
> 
>    perldoc -q buffer

Now I know why you lot are better at finding stuff in the docs than me.

Just tried that and got

Unknown option: q
perldoc [options] PageName|ModuleName|ProgramName...
perldoc [options] -f BuiltinFunction

So when was perldoc updated?
What version of Perl do I need?
If it's earlier than 5.004_04 what went wrong with this installation?

(Sorry for the multiple questions)

Damn, the easiest way of searching the best documentaion on earth and I
can't use it!!!!!

-- 
Ian J. Garlick
ijg@csc.liv.ac.uk

Science is facts; just as houses are made of stones, so is science made
of facts; but a pile of stones is not a house and a collection of facts
is not necessarily science.
                -- Henri Poincaire



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

Date: Thu, 05 Aug 1999 08:54:12 GMT
From: mizote <philippe.sockeel@cdn.fr>
Subject: How to uninstall Perl on Unix ?
Message-Id: <7objfh$u5k$1@nnrp1.deja.com>

Well, I just want to completely uninstall Perl on HP-UX10.20 before
reinstalling it with different options.
Is there any script or method or document to help me doing that ?

Thanks for answers
Philippe


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Thu, 05 Aug 1999 11:02:05 +0100
From: Matt Sergeant <matt.sergeant@bbc.co.uk>
Subject: Re: IMPORTANT: "19$year"
Message-Id: <37A9611D.D81F3EAF@bbc.co.uk>

Jeff Pinyan wrote:
> 
> Do not accept ANY substitutes.
> 
>   $date = 1900 + $year;

$year += 1900;

> If you don't fix this, you will look rather foolish when January 1, 2000
> -- or should I say, 19101 -- comes around.

That would be 19100. :)

Matt.


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

Date: Thu, 5 Aug 1999 09:16:40 +0100
From: "rezn8" <saxbourne@yahoo.com>
Subject: NT Apache Perl
Message-Id: <7obh8j$9hj$1@pegasus.csx.cam.ac.uk>

Help! I can't seem to get file permissions running properly.
I get the following error when accessing a valid .pl file
Internal Server Error
The server encountered an internal error or misconfiguration and was unable
to complete your request.
Please contact the server administrator, webmaster@chu.cam.ac.uk and inform
them of the time the error occurred, and anything you might have done that
may have caused the error.

More information about this error may be available in the server error log.



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

Apache/1.3.6 Server at cic Port 80

How do I fix this problem?
ICQ #34337857




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

Date: Thu, 05 Aug 1999 08:34:51 GMT
From: backwards.saerdna@srm.hc (Andreas Fehr)
Subject: Re: NT Apache Perl
Message-Id: <37a94c7b.11677601@news.uniplus.ch>

On Thu, 5 Aug 1999 09:16:40 +0100, "rezn8" <saxbourne@yahoo.com>
wrote:

>
>More information about this error may be available in the server error log.
>

What did you find there?

Andreas


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

Date: Thu, 5 Aug 1999 09:55:36 +0100
From: "rezn8" <saxbourne@yahoo.com>
Subject: Re: NT Apache Perl
Message-Id: <7objhi$bdt$1@pegasus.csx.cam.ac.uk>

No such file or directory: couldn't spawn child process:
e:/cgi-bin/news/news.pl

Andreas Fehr <backwards.saerdna@srm.hc> wrote in message
news:37a94c7b.11677601@news.uniplus.ch...
> On Thu, 5 Aug 1999 09:16:40 +0100, "rezn8" <saxbourne@yahoo.com>
> wrote:
>
> >
> >More information about this error may be available in the server error
log.
> >
>
> What did you find there?
>
> Andreas




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

Date: Thu, 05 Aug 1999 09:19:37 GMT
From: backwards.saerdna@srm.hc (Andreas Fehr)
Subject: Re: NT Apache Perl
Message-Id: <37a955de.14080556@news.uniplus.ch>

On Thu, 5 Aug 1999 09:55:36 +0100, "rezn8" <saxbourne@yahoo.com>
wrote:

>No such file or directory: couldn't spawn child process:
>e:/cgi-bin/news/news.pl
>
>> >
>> >More information about this error may be available in the server error
>log.
>> >
>>
>> What did you find there?
>>

This might be the Outlook way to write messages in ngs. (Some others)
and I prefer:

First Quote.
Then Answer.

Does e:/cgi-bin/news/news.pl exist?

BTW. this does not look like a Perl problem.
Andreas


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

Date: Thu, 5 Aug 1999 10:23:52 +0100
From: "rezn8" <saxbourne@yahoo.com>
Subject: Re: NT Apache Perl
Message-Id: <7obl6j$csu$1@pegasus.csx.cam.ac.uk>

Yes it does
Andreas Fehr <backwards.saerdna@srm.hc> wrote in message
news:37a955de.14080556@news.uniplus.ch...
> On Thu, 5 Aug 1999 09:55:36 +0100, "rezn8" <saxbourne@yahoo.com>
> wrote:
>
> >No such file or directory: couldn't spawn child process:
> >e:/cgi-bin/news/news.pl
> >
> >> >
> >> >More information about this error may be available in the server error
> >log.
> >> >
> >>
> >> What did you find there?
> >>
>
> This might be the Outlook way to write messages in ngs. (Some others)
> and I prefer:
>
> First Quote.
> Then Answer.
>
> Does e:/cgi-bin/news/news.pl exist?
>
> BTW. this does not look like a Perl problem.
> Andreas




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

Date: Thu, 05 Aug 1999 10:01:18 GMT
From: backwards.saerdna@srm.hc (Andreas Fehr)
Subject: Re: NT Apache Perl
Message-Id: <37a95e3d.16223928@news.uniplus.ch>

On Thu, 5 Aug 1999 10:23:52 +0100, "rezn8" <saxbourne@yahoo.com>
wrote:

>Yes it does

Yes it does what?
Where does this answer belongs to!!!

Please, change the way you write messages in this group.


>>
>> >No such file or directory: couldn't spawn child process:
>> >e:/cgi-bin/news/news.pl
>> >
>> >> >More information about this error may be available in the server error
>> >log.
>> >>
>> >> What did you find there?
>> >>
>>
>> Does e:/cgi-bin/news/news.pl exist?
>>

Strange, I thought I read somewhere that Apache has changed this,
but I have tested it on my server and it is still there...

So set a correct #! and you will be fine.

Andreas


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

Date: Thu, 05 Aug 1999 08:17:41 GMT
From: backwards.saerdna@srm.hc (Andreas Fehr)
Subject: Re: Perl & Win95
Message-Id: <37a9486a.10636324@news.uniplus.ch>

On Thu, 05 Aug 1999 06:40:26 GMT, "Thomas Fvrtsch"
<thomas@dreamsister.de> wrote:

>What do I have to write exactly?
>It does not work at all.
>

You'll find an example with

perldoc -q system\(\)

Andreas


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

Date: Thu, 05 Aug 1999 08:19:41 GMT
From: backwards.saerdna@srm.hc (Andreas Fehr)
Subject: Re: Possible to get a HTML file from somewhere and use it as string?
Message-Id: <37a948ff.10785388@news.uniplus.ch>

On Thu, 05 Aug 1999 07:52:53 GMT, lpwong@my-deja.com wrote:

>Thanks a lot

44 lines to say 'thank you'?

Andreas


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

Date: 5 Aug 1999 08:39:44 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Problem: extracting terminology from text
Message-Id: <slrn7qijf5.rbg.sholden@pgrad.cs.usyd.edu.au>

On Wed, 04 Aug 1999 12:08:54 +0200, Denis Pleic <dpleic@close.open.hr> wrote:
>Hi,
>
>So, the basic idea is to have a "dictionary" of "standard" 
>words/terms, which would be used for "exceptions", i.e. for 
>comparison.
>
>For example, when you get a new text, you'd compare it against this 
>standard "dictionary", and extract into a separate file all words 
>which do not appear in the dictionary. This list would, naturally, 
>be much shorter than the original text, and thus easier (and faster) 
>to "clean" by hand, leaving only new terms which need translating...

fmt -w 1 new.txt | tr A-Z a-z | tr -cd a-z\\n- | \
   sort | uniq | comm -23 - words.txt

Is one simple way, which doesn't work very well due to punctuation,
words that are split over two lines, etc.

>
>I'd also like to hear any ideas regarding how to set about doing 
>this (the original text should be split into lexical units - words, 
>for comparing them with the dictionary)...

Students in our 'programming practice in a Unix environment' did this
as an assignment last year. 

They had to write a program (in python for that assignment) which was
given a file containing stop-words and a text file. They had to output
all the words in the text file that weren't in the stop-words list along
with line numbers where they occured.

The only hard bits are extracting the words from the text file and
defining the rules you use to generating words from the stop-words base
list. 

I did it by adding each stop-word to a hash (as the key) and also adding
all the words I could generate from that word (in the assignment the
stop-word list wasn't huge, and the production rules only generated 10 or
so words for each base, and the text file was 'Alice in Wonderland', if
the text was was shorter, or the word list longer, you would try
to 'trim' the words in the text rather than expanding the stop words).

Then I just looped over the words in the text file (after handling 
punctuation and all that) and checked if it was in the hash, if not then
it was a added to the found words.

As for perl content - my solution was done in perl.

-- 
Sam

Perl was designed to be a mess (though in the nicest of possible ways). 
	--Larry Wall


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

Date: Thu, 05 Aug 1999 10:14:51 +0100
From: "Matt Willsher" <matt@red.net>
Subject: regex substitutions from static strings
Message-Id: <7obkmf$j07$1@supernews.com>

Hi all. 
I have a config file that contains a set of substitions as follows:

john => joe
^james => jim

etc.

These are then split at the \s+=>\s+ and each part is used in a substitution
s/$part[0]/$part[1]/.
This works fine for most cases, but not for more complex substitions of the
type:

(\d{1,3})dog(s) => $1cat$2

The result of this is that the regex on the left get matched and directly
subsituted as '$1cat$2'. Not ideal :/.

Is there any way around this behaviour?

TIA,
Matt

--
Matt Willsher, UNIX Systems Administrator, REDNET Ltd.
E - matt@red.net        T - +44 (0)1494 751883
W - http://www.red.net  F - +44 (0)1494 443374


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

Date: 5 Aug 1999 03:13:58 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: regexp can be your friend
Message-Id: <slrn7qihsv.tvu.abigail@alexandra.delanet.com>

Jerrad Pierce (belg4mit@mit.edu) wrote on MMCLXIV September MCMXCIII in
<URL:news:37A8CAEB.26275078@mit.edu>:
|| IS it possible, with a single RE, to replace the first occurence of a substri
|| within a string IFF the substring occurs multiple times?


Overlapping or non-overlapping?

If my substring is 'foofoo', and the string is 'barfoofoofoobar', how
many 'foofoo's does that contain? IMO, it contains 2 of them.


For non-overlapping, it's easy:

    $str    =  quotemeta $substring;
    $string =~ s/$str(?=.*$str)/replacement/s;


For overlapping, I fail to come up with a single RE, unless I use some
kind of evalling - be it with (?{code}) or /e in the replacement. (That
in my book doesn't consist of "a single RE" anymore, as you can stuff in
anything you want.)



Abigail
-- 
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$r=-2449231+gm_julian_day+time);do{until($r<$#r){$_.=$r[$#r];$r-=$#r}for(;
!$r[--$#r];){}}while$r;$,="\x20";print+$_=>September=>MCMXCIII=>()'


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: 5 Aug 1999 03:16:31 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: regexp can be your friend
Message-Id: <slrn7qii1q.tvu.abigail@alexandra.delanet.com>

Uri Guttman (uri@sysarch.com) wrote on MMCLXIV September MCMXCIII in
<URL:news:x7907ri0ey.fsf@home.sysarch.com>:
;; 
;; perl -pe 's/(ab)(.*\1)/xx$2/'
;; 
;; i tried a lookahead version but it doesn't seem to work:
;; 
;; perl -pe 's/(ab)(?=\1)/xx/'
;; 
;; maybe ilya could exlain why? and i am sure he has new tricks which can
;; do this too.


Will I do as well?

    s/(ab)(?=\1)/xx/ 

asks for ab, followed by ab.

You are (correctly) using .* in the version without lookahead (but
you should have used /s). Why you think you don't need .* when using
lookahead, is beyond me.



Abigail
-- 
srand 123456;$-=rand$_--=>@[[$-,$_]=@[[$_,$-]for(reverse+1..(@[=split
//=>"IGrACVGQ\x02GJCWVhP\x02PL\x02jNMP"));print+(map{$_^q^"^}@[),"\n"


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: 05 Aug 1999 04:20:47 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: regexp can be your friend
Message-Id: <x7pv12hc4g.fsf@home.sysarch.com>

>>>>> "A" == Abigail  <abigail@delanet.com> writes:

  A>     s/(ab)(?=\1)/xx/ 

  A> asks for ab, followed by ab.

  A> You are (correctly) using .* in the version without lookahead (but
  A> you should have used /s). Why you think you don't need .* when using
  A> lookahead, is beyond me.

if you would read the rest of the thread, you would see i learned of my
mistake already. i know you have a lousy newsfeed but that is
ridiculous.

in any case i was blinded by the lookahead and didn't think about .*

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com
"F**king Windows 98", said the general in South Park before shooting Bill.


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

Date: Thu, 05 Aug 1999 09:22:10 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: regexp can be your friend
Message-Id: <37ad5693.13007722@news.skynet.be>

Abigail wrote:

>If my substring is 'foofoo', and the string is 'barfoofoofoobar', how
>many 'foofoo's does that contain? IMO, it contains 2 of them.

>For overlapping, I fail to come up with a single RE

How about:

	$_ = 'barfoofoofoobar';
	$pattern = 'foofoo';

	/(?=$pattern).+?$pattern/;

	print "$`\n$&\n$'\n";

->
	bar
	foofoofoo
	bar

That doesn't replace, but it's a single regex.

	Bart.


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

Date: Thu, 05 Aug 1999 08:59:08 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Regular expression for matching an e-mail address.
Message-Id: <37ab51a1.11742470@news.skynet.be>

Abigail wrote:

>"" I remember reading somewhere many months ago a really good regular
>"" expression for matching e-mail address.  Now I need to use it, and I
>"" can not seem to find it anymore.  Can someone please provide me with
>"" the best possible regular expression for matching an e-mail address?
>
>You must have read it in the appendix of MRE.

Actually, TomC quotes it in one of his scripts, avialable through
<www.perl.com>. Most of it tests for rubbish input or rude words, which
doesn't make it an invalid e-mail address, in my book, but only an
unlikely one.

	Bart.


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

Date: 04 Aug 1999 11:51:13 -0400
From: David Guertin <guertin@middlebury.edu>
Subject: Skipping . and .. with readdir
Message-Id: <x6i907r1r4e.fsf@caddis.middlebury.edu>

Hi folks,

I've got a script with a readdir function that's set up like this:

while ($_ = readdir (INPUT_DIR)) {
	dostuff;
}

This works fine, except it includes . and .. in the list.  I want to
exclude these, and according to the camel book I can exclude them
with:

@allfiles = grep !/^\.\.?$/, readdir INPUT_DIR;

OK, this regexp makes sense and I can see how it's working.  So I've
tried combining this into my "while" function:

while ($_ = grep !/^\.\.?$/, readdir (INPUT_DIR)) {
	dostuff;
}

But this syntax is screwed up in a way that I don't understand.  Can
someone please help me put this grep into a while function in a way
that works?

Many thanks,
-- 
Dave Guertin
guertin@middlebury.edu


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

Date: 05 Aug 1999 04:25:18 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Skipping . and .. with readdir
Message-Id: <x7lnbqhbwx.fsf@home.sysarch.com>

>>>>> "DG" == David Guertin <guertin@middlebury.edu> writes:


  DG> @allfiles = grep !/^\.\.?$/, readdir INPUT_DIR;

that is getting all the dirs and filtering them.

  DG> while ($_ = grep !/^\.\.?$/, readdir (INPUT_DIR)) {
  DG> 	dostuff;
  DG> }

that is getting all the dirs and assigning then number of dirs other
than . and .. to $_. you need to do the filter in the loop and not in
the while condition. do this:

	next if /^\.\.?$/ ;

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com
"F**king Windows 98", said the general in South Park before shooting Bill.


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

Date: 5 Aug 1999 09:53:20 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Skipping . and .. with readdir
Message-Id: <7obmug$dmr$1@lublin.zrz.tu-berlin.de>

Uri Guttman  <uri@sysarch.com> wrote in comp.lang.perl.misc:
>>>>>> "DG" == David Guertin <guertin@middlebury.edu> writes:
>
>
>  DG> @allfiles = grep !/^\.\.?$/, readdir INPUT_DIR;
>
>that is getting all the dirs and filtering them.
>
>  DG> while ($_ = grep !/^\.\.?$/, readdir (INPUT_DIR)) {
>  DG> 	dostuff;
>  DG> }
>
>that is getting all the dirs and assigning then number of dirs other
>than . and .. to $_. you need to do the filter in the loop and not in
>the while condition. do this:
>
>	next if /^\.\.?$/ ;

Of course, if you insist on using grep there is

foreach ( grep !/^\.\.?$/, readdir( INPUT_DIR) ) {

But that means you read the directory into memory before processing,
which is EVIL.  Forget you've seen that.  It'll give you bad dreams.

Anno


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

Date: 5 Aug 1999 09:45:57 GMT
From: M.Ray@ulcc.ac.uk (Malcolm Ray)
Subject: Re: Why no Perl books at Fry's?
Message-Id: <slrn7qinal.6sj.M.Ray@carlova.ulcc.ac.uk>

On Wed, 4 Aug 1999 20:37:17 +0100, Paul <paul@mccombes.demon.co.uk> wrote:
>In article <slrn7qf1ab.s67.abigail@alexandra.delanet.com>, Abigail
><abigail@delanet.com> writes
>>
>>Lecture Notes in Computer Science; Springer Verlag. They also have a
>>yellow wall, for their Math series. Yellow and grey walls are usually
>>found in academic libraries, although there's at least one book shop in
>>London (I can't remember the name, but I sure will be able to find it)
>>that does have a grey wall.
>>
>Probably Foyle's in Charing Cross Road, as (a) it has a huge academic
>stock and (b) it displays by publisher (even in the fiction department).

 ...but since old Christena Foyle died recently, there's no guarantee that
it won't become just another bookshop, even if the family manage to hold
onto it.
-- 
Malcolm Ray                           University of London Computer Centre


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

Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 1 Jul 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.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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


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