[16956] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4368 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Sep 18 21:10:31 2000

Date: Mon, 18 Sep 2000 18:10:18 -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: <969325818-v9-i4368@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 18 Sep 2000     Volume: 9 Number: 4368

Today's topics:
    Re: perl and web (Martien Verbruggen)
    Re: Perl Praise & This Newsgroup <david.obrien@ssmb.com.au>
    Re: Perl Praise & This Newsgroup <lr@hpl.hp.com>
    Re: Perl Praise & This Newsgroup <bigiain@mightymedia.com.au>
    Re: Please explain how this filename extraction works? <anmcguire@ce.mediaone.net>
    Re: Possible to generate html frames from perl ??? (Alone)
    Re: Possible to generate html frames from perl ??? (Alone)
    Re: print and CGI scripts <david.obrien@ssmb.com.au>
    Re: printer administration under NT <elephant@squirrelgroup.com>
    Re: Problem running script from within a script <david.obrien@ssmb.com.au>
    Re: Range operator with "... /^$/" <bcaligari@my-deja.com>
    Re: Range operator with "... /^$/" <yanick@babyl.sympatico.ca>
    Re: Range operator with "... /^$/" ollie_spencer@my-deja.com
    Re: Range operator with "... /^$/" <lr@hpl.hp.com>
    Re: Range operator with "... /^$/" <ren.maddox@tivoli.com>
    Re: Range operator with "... /^$/" ollie_spencer@my-deja.com
        readir nodo70@my-deja.com
    Re: readir (Colin Watson)
    Re: Regular Expressions: Counting matches? <dfan@harmonixmusic.com>
    Re: Regular Expressions: Counting matches? <lr@hpl.hp.com>
    Re: Running a perl program as a daemon? (Dave Sherohman)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Mon, 18 Sep 2000 22:05:33 GMT
From: mgjv@verbruggen.comdyn.com.au (Martien Verbruggen)
Subject: Re: perl and web
Message-Id: <slrn8sd4cs.2cp.mgjv@verbruggen.comdyn.com.au>

On Mon, 18 Sep 2000 13:05:58 -0400,
	Albert Dewey <timewarp@shentel.net> wrote:
> daud11@hotmail.com wrote:
> 
> > Hi
> >
> > I installed Perl in my windows NT server. I wanted to use it from the
                           ^^^^^^^^^^^^^^^^^
> > web as a CGI program. At first I got it working ie I was able to
> > execute it from the web server using http://www..../cgi-bin/script.pl.
> >
> > Now it is no longer working. When the above url is tested it seems to
> > download the file. Why? and how do i fix it?
> >
> > thanks
> > Daud11
> >
> > Sent via Deja.com http://www.deja.com/
> > Before you buy.
> 
> Have you set the permissions to execute only?
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^
> If they are read only, then the script will not execute and be considered
> a downloadable file.
> I set all my scripts to the bare minimum and that is chmod 711 on a unix
                                                       ^^^^^^^^^
> machine.
> Not sure how this translates into NT speak but there it is....

It doesn't. NT doesn't have execute permissions and stuff like that.
If there is any of this stuff, it's a server issue, and it should be
discussed in another group.

BTW, 711 isn't the bare minimum, and it may not always be sufficient
either, depending on who owns the file. Perl needs to be able to read
the file, as well as execute it.

$ who am i
verbruggen.comdyn.com.au!mgjv     pts/4    Sep  6 15:18
$ ls -l hello
-rwxr-xr-x   1 mgjv     users          48 Sep 19 09:00 hello
$ ./hello
Hello World
$ chmod 111 hello
$ ./hello
Can't open perl script "./hello": Permission denied

And with root in another window changing permissions and ownership:

$ ls -l hello
-rwx--x--x   1 root     users          48 Sep 19 09:00 hello
$ ./hello
Can't open perl script "./hello": Permission denied
$ ls -l hello
-rwxr-x--x   1 root     users          48 Sep 19 09:00 hello
$ ./hello
Hello World

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | Can't say that it is, 'cause it
Commercial Dynamics Pty. Ltd.   | ain't.
NSW, Australia                  | 


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

Date: Tue, 19 Sep 2000 09:28:14 +1000
From: Dave O'Brien <david.obrien@ssmb.com.au>
Subject: Re: Perl Praise & This Newsgroup
Message-Id: <39C6A50E.9EA00D3B@ssmb.com.au>



rathmore@tierceron.com wrote:
> 
> <!--Begin Mawkish Praise Here--!>
> 
> I just wanted to take a minute and thank everyone in this newsgroup who
> took the time to respond to the inquiries that I posted to this
> newsgroup. Everyone was helpful and considerate. When I was learning
> another language, which I won't mention (C++), I went to a newsgroup
> associated with that language, which I also won't mention
> (comp.lang.c++) and got lambasted after my first two posts. This wasn't
> an isolated occurrence--I took the time to read other questions and
> responses because my experience was so poor.
> 
> I was a little leery about posting here, but I wanted to give everyone
> the benefit of the doubt. I'm glad I did, I'm sticking around, and I
> hope to eventually be good enough with Perl to assist others who are
> trying to learn the language.
> 
> As far as Perl goes, I love it! I've had a lot of fun with this
> project, I've learned a lot about the language, and I'm going to stick
> with this language. I hope to earn the classification of guru!
> 
> I've found that Perl does what you want it to. When I wasn't sure of an
> exact syntax, or how to code a particular algorithm, I would write up a
> test script and see what happens. About 80% of the time the script
> would work just like I wanted it to. That same technique, when applied
> to C++, had about a 25% success rate. There was always something I
> forgot (usually had to do with deallocating memory or pointer cleanup).
> 
> Thanks all! And, thanks to everyone who reads this message who has had
> a hand in the development of this very cool programming language!
> 
> Rathmore
> 
> <!--End Mawkishness Here--!>
> 
> Sent via Deja.com http://www.deja.com/
> Before you buy.

You are right.  This is a good group.  People are very helpful, and
willing to dissect problems that you might have.  My first post has been
very helpful, and I've learnt a lot about how to post (as well as about
perl of course :)

Well done perl philanthropists!

Dave


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

Date: Mon, 18 Sep 2000 16:35:50 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Perl Praise & This Newsgroup
Message-Id: <MPG.143046aebf0844e998ad88@nntp.hpl.hp.com>

In article <39C6A50E.9EA00D3B@ssmb.com.au> on Tue, 19 Sep 2000 09:28:14 
+1000, Dave O'Brien <david.obrien@ssmb.com.au> says...

 ...

> You are right.  This is a good group.  People are very helpful, and
> willing to dissect problems that you might have.  My first post has been
> very helpful, and I've learnt a lot about how to post (as well as about
> perl of course :)

I doubt that you learned much about perl.

> Well done perl philanthropists!

You haven't learned enough about Perl.

perlfaq1: "What's the difference between ``perl'' and ``Perl''?"

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Mon, 18 Sep 2000 17:58:22 -0700
From: Iain Chalmers <bigiain@mightymedia.com.au>
Subject: Re: Perl Praise & This Newsgroup
Message-Id: <bigiain-12916D.17582218092000@news.pacbell.net>

In article <8q5trl$b1m$1@nnrp1.deja.com>, rathmore@tierceron.com wrote:

> <!--Begin Mawkish Praise Here--!>

Off topic, comp.lang.perl.misc.posters.praise.moderated is over there -->

<GRIN>

big


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

Date: Mon, 18 Sep 2000 17:42:16 -0500
From: "Andrew N. McGuire " <anmcguire@ce.mediaone.net>
Subject: Re: Please explain how this filename extraction works?
Message-Id: <Pine.LNX.4.21.0009181738150.497-100000@hawk.ce.mediaone.net>

[ my apologies if this shows up more than once, but I can't seem to type
  well today. :-( ]

On Mon, 18 Sep 2000, ladesigner1@my-deja.com quoth:

> I have this snippet of Perl code that I hope someone can explain (in
> simple English terms) how it works. It works great for extracting
> filenames within a URL:
> 
> if (m|^.*/(\w+).html|) {
>       print "Extracted $1 from $_\n";
> 
> Please explain what the pattern matching process is doing to take the
> mystery out of recognizing the filenames of any character length...
> 

[ snip ]

Well, to start out, '^' is a pattern anchor that will only match at
the beginning of the string.  In other words, it matches the "nothing"
at the very beginning of the string. The '.' matches ~ANY~ character,
except the newline ("\n") in this case.  The '*' matches 0 or more
occurrences of the previous character (which in this case is any char-
acter).  When used in combination, '^.*' means "match the maximum amount
of anything at the front of the string while still allowing the rest of
the pattern to match if possible."

The '/' is of course a literal slash, but the '.' following the slash
in this case should most likely be preceded by a backslash ('\'), as 
in the current pattern the '.' will match any character.  By preceding 
it with a backslash, you are saying "match a literal .".

The 'html' part is obvious.  If you know that the 'html' is guaranteed
to be the last part of your string, it would be a good idea to append
a '$' to it, '$' is a pattern anchor that will only match at the
end of the string (the corollary to '^').  '^' and '$' are called 
anchors as they help to narrow the scope of your regex, they will help
the pattern matching engine find what it is looking for faster.
  
anm
-- 
# Only works with '-Mstrict' 5.6.0
foreach (qw~Just another Perl Hacker~) {!$|=~m~\d+~&&
++$.&&eval&&(@$=split?\s{1}?,$@);$@=~s[.*?"(.*?)".*$]
{$.<=3?$1." ":$1."\n"}gmse;$\=$@;local$_="";print if+
!-!+!-!+!-!+!-!+!-!+!-!+!-!+!-!+!-!+!-!+!-!+!-!+!-!1}



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

Date: Tue, 19 Sep 2000 00:25:24 GMT
From: Alone@Work.com (Alone)
Subject: Re: Possible to generate html frames from perl ???
Message-Id: <39c6af68.79086216@news.reliable-net.net>


Okay...  what is a "here document" ???


On 18 Sep 2000 06:57:01 +0100, Jonathan Stowe
<gellyfish@gellyfish.com> wrote:

On Sun, 17 Sep 2000 19:47:59 GMT Sean Malloy wrote:
> Alone@Work.com (Alone) wrote:
>>Is it possible to generate an html frameset without writing to a file?
> 
> Certainly. On the website that I administer, I use a Perl script to
> generate framesets so that the search engine links to properly-framed
> pages (top banner, left menu, right content) based on the results of
> searches that locate information in the content pages. Here's the
> script (once the print statements start, any line _not_ starting with
> 'print' is wrapped from the previous line until you get to the
> document close tag):
> 
> ---------------------------------
> #!/usr/local/bin/perl
> $hostname = "www-nmcsd.med.navy.mil";
> $len = length($ARGV[0]);
> @path = split("/",$ARGV[0]);
> $basename = @path[$#path];
> $#path -= 1;
> $root = join("/",@path);
> print "Content-type: text/html\n\n";
> print "<HTML>\n";
> 
<snip squillions of print() statements>

Looks like a very clear case for a here docucument.

/J\
-- 
yapc::Europe in assocation with the Institute Of Contemporary Arts
   <http://www.yapc.org/Europe/>   <http://www.ica.org.uk>



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

Date: Tue, 19 Sep 2000 00:25:25 GMT
From: Alone@Work.com (Alone)
Subject: Re: Possible to generate html frames from perl ???
Message-Id: <39c6afc4.79178534@news.reliable-net.net>


Aha... very ingenious !!!

And do you know off-hand if a second call to myscript.cgi?frame=2 will
refresh the frame or will it load from the cache ???



On Mon, 18 Sep 2000 14:29:06 -0600, "Nathaniel Hekman"
<NHekman@geo-slope.com> wrote:

A frameset just points to other urls used to fill each frame.  Make
those
urls point to your cgi script, with some way for the script to know
which
frame it is now generating.  For example, the url to your main page
could be
http://www.whatever.com/myscript.cgi.  myscript.cgi generates a
frameset in
html, saying that frame 1 is to be filled with myscript.cgi?frame=1,
and
frame 2 with myscript.cgi?frame=2.  When myscript.cgi is called with
the
frame parameter set, it generates the appropriate html for that frame.


Nate






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

Date: Tue, 19 Sep 2000 09:20:08 +1000
From: Dave O'Brien <david.obrien@ssmb.com.au>
Subject: Re: print and CGI scripts
Message-Id: <39C6A328.926FC345@ssmb.com.au>



Jonathan Stowe wrote:
> 
> On Thu, 14 Sep 2000 15:31:09 +1000 Dave O'Brien wrote:
> >
> > I am writing a CGI script that takes some user settings, and then then
> > processes, and creates some new files.
> >
> 
> <snip>
> 
> >
> > As you can see, very simple.  All I want to do, is temporarily redirect
> > print statements back to the terminal, and not the browser.
> >
> 
> open(CONSOLE,'>/dev/console') || die "Whoah - can't open Console - $!\n";
> select CONSOLE;
> 
> # print now goes to /dev/console
> 
> select STDOUT;
> 
> # print now goes to wherever STDOUT was going before
> 
> Of course your 'terminal' might not be /dev/console but we can't help you
> determine that.
> 
> /J\
> --
> yapc::Europe in assocation with the Institute Of Contemporary Arts
>    <http://www.yapc.org/Europe/>   <http://www.ica.org.uk>

Thanks Johnathon,

I have solved my problem, and *you guessed it*, it wasn't the print
command at all!

I was running system(dos2unix $file $file)

which was outputting the converted files to STDOUT (which it doesn't do
by default).  Very annoying.  I was being too lazy to write the
conversion (which merely strips off the Windows ctrl characters).

Thanks to all the respondee's, and I'm sorry for wasting some of your
time.

A fairly interesting display from a cross section of the community :)

cheers

Dave


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

Date: Tue, 19 Sep 2000 10:51:22 +1100
From: jason <elephant@squirrelgroup.com>
Subject: Re: printer administration under NT
Message-Id: <MPG.143147731dc2437d9897b6@localhost>

uunet <clandos@bigfoot.com> wrote ..
>is there a library that supports printer administration, such as grant
>rights, under perl
>
>i use active perl 5.6 at the moment and there seems to be no solution to
>grant access permissions to nt- lpr-printers

you might need to do it directly with one of the registry modules

  Win32::TieRegistry

  Win32Api::Registry

-- 
  jason -- elephant@squirrelgroup.com --


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

Date: Tue, 19 Sep 2000 09:46:00 +1000
From: Dave O'Brien <david.obrien@ssmb.com.au>
Subject: Re: Problem running script from within a script
Message-Id: <39C6A938.503ED470@ssmb.com.au>



Jonathan Stowe wrote:
> 
> On Wed, 13 Sep 2000 16:42:44 +0100 John Plaxton wrote:
> > Hi there, this newby needs help!
> >
> > I'm trying to open a script i.e. 'test.cgi' from within another script. How
> > is it done.
> >
> >
> > I'm using cgi.pm
> >
> > I've tried :
> > $foo->redirect('http://www.thisdontwork.com/cgi-bin/test.cgi'); which gives
> > a blank screen
> >
> 
> You need to print that.
> 
> print $foo->redirect('http://www.thisdontwork.com/cgi-bin/test.cgi');
> 
> /J\
> --
> yapc::Europe in assocation with the Institute Of Contemporary Arts
>    <http://www.yapc.org/Europe/>   <http://www.ica.org.uk>

try using the do operator with

$file="script.pl";
do $file;

I'm pretty sure that works ok.

Dave


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

Date: Mon, 18 Sep 2000 22:59:41 GMT
From: Brendon Caligari <bcaligari@my-deja.com>
Subject: Re: Range operator with "... /^$/"
Message-Id: <8q66oh$lpo$1@nnrp1.deja.com>

In article <8q61q8$fsl$1@nnrp1.deja.com>,
  ollie_spencer@my-deja.com wrote:
> I agree. I'm covered by embarassment, since my code DOES have "if",
but
> in my hurry to post, I used the incorrect "while". And in my "REAL"
> code, I do chomp.
>
> If I believe the "Perl Cookbook" ( and I do), the construct
> (/LOG AN EVENT/ ... /^$/) is a boolean, value initially "0", that
> evaluates each line it encounters against the first expression ( i.e.,
> /LOG AN EVENT/) until it encounters a line that contains that pattern,
> whereupon it becomes "1". It then evaluates each subsequent line until
> it finds one that matches the second pattern (i.e., /^$/), then
becoming
> "0".
>
> There is even an example of using the /^$/ expression to find a blank
> line in the same section of Cookbook, although not used as the
argument
> of "while".
>
> The trouble I'm having is probably due to my WinNT platform and the
use
> of hex 0d0a as the line terminator. I printed $/ to a file and viewed
it
> using emacs HEXL-MODE; It's one character, "0a", not "0d0a". Maybe I
> need to use /^0x0d$/(where 0x0d may not be correct - I may have to be
> clever to put a "0d" between ^ and $). Or maybe I can change $/ to
> hex0d0a for evaluating this file. I had hoped (and still hope)for a
> magic bullet that would put this problem to bed. I wonder if chomp
> changes the EOL character to "0a"?
>
> ollie spencer
>

you're not calling binmode() by any chance?

i'm running w2k and it works fine

brendon

Brendon
++++


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Mon, 18 Sep 2000 23:12:50 GMT
From: Yanick Champoux <yanick@babyl.sympatico.ca>
Subject: Re: Range operator with "... /^$/"
Message-Id: <Sjxx5.1466$z9.130484@news20.bellglobal.com>

ollie_spencer@my-deja.com wrote:
: I agree. I'm covered by embarassment,

	Could be worse. Could be monkey livers. :)

: since my code DOES have "if", but
: in my hurry to post, I used the incorrect "while". And in my "REAL"
: code, I do chomp.

	So can we see a minimal subset of your real code that
	reproduce the problem you are encountering. Pretty please
	with sugar on top? :)

: If I believe the "Perl Cookbook" ( and I do), the construct
: (/LOG AN EVENT/ ... /^$/) is a boolean, value initially "0", that
: evaluates each line it encounters against the first expression ( i.e.,
: /LOG AN EVENT/) until it encounters a line that contains that pattern,
: whereupon it becomes "1". It then evaluates each subsequent line until
: it finds one that matches the second pattern (i.e., /^$/), then becoming
: "0".

	Same thing for .., the only difference beign that .. test the 
	second operand (/^$/) on the same iteration that the first
	operand becomes truei, wherea ... does not. 

: There is even an example of using the /^$/ expression to find a blank
: line in the same section of Cookbook, although not used as the argument
: of "while".

: The trouble I'm having is probably due to my WinNT platform and the use
: of hex 0d0a as the line terminator. I printed $/ to a file and viewed it
: using emacs HEXL-MODE; It's one character, "0a", not "0d0a". Maybe I
: need to use /^0x0d$/(where 0x0d may not be correct - I may have to be
: clever to put a "0d" between ^ and $). Or maybe I can change $/ to
: hex0d0a for evaluating this file. I had hoped (and still hope)for a
: magic bullet that would put this problem to bed. I wonder if chomp
: changes the EOL character to "0a"?

It shouldn't matter to /^$/. Did my piece of code worked on your file?

: ollie spencer

: No Joy, so far.

	There's always joy. Sometime it's covered with strange smelly
	stuff, but there always joy. :)

Joy,
Yanick

-- 
eval" use 'that poor Yanick' ";
print map{ (sort keys %{{ map({$_=>1}split'',$@) }})[hex] }
qw/8 b 15 1 9 10 11 15 c b 13 1 12 b 13 f 1 c 9 a e b 13 0/;


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

Date: Mon, 18 Sep 2000 23:19:32 GMT
From: ollie_spencer@my-deja.com
Subject: Re: Range operator with "... /^$/"
Message-Id: <8q67th$n6u$1@nnrp1.deja.com>

Yep, I run binmode() after opening and before using the file.
I'm thinking now that I may have to convert all the "0d0a" newlines to
just "0a" (with perl, of course) before I will be able to do what I
want. I thought that $/ became "0d0a" automatically when it encountered
a windows file, but right now that seems to not be true. I'm trying to
force it-

Thanks again. Any suggestions are welcome.

ollie spencer

In article <8q66oh$lpo$1@nnrp1.deja.com>,
  Brendon Caligari <bcaligari@my-deja.com> wrote:

===A whole lot snipped===
>
> you're not calling binmode() by any chance?
>
> i'm running w2k and it works fine
>
> brendon
>
> Brendon
> ++++
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Mon, 18 Sep 2000 16:19:03 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Range operator with "... /^$/"
Message-Id: <MPG.143042c68e7bba4b98ad86@nntp.hpl.hp.com>

In article <8q5s6n$8pr$1@nnrp1.deja.com> on Mon, 18 Sep 2000 19:59:34 
GMT, Brendon Caligari <bcaligari@my-deja.com> says...
> In article <8q5l8i$vn6$1@nnrp1.deja.com>,
>   ollie_spencer@my-deja.com wrote:
> [snip snip]
> 
> > and could use it for this situation. But my questions are: why isn't
> > /^$/ a valid  delimiter for the range operator? Has it something to do
> 
> m/^$/ matches an empty line
> 
> a 'just read' line will probably contain a newline

  m/^$/ also matches a string that contains only a newline.

See perlre for an explicit statement about what is matched by '$'.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 18 Sep 2000 18:01:04 -0500
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: Range operator with "... /^$/"
Message-Id: <m34s3dwbin.fsf@dhcp11-177.support.tivoli.com>

ollie_spencer@my-deja.com writes:

> The trouble I'm having is probably due to my WinNT platform and the use
> of hex 0d0a as the line terminator. I printed $/ to a file and viewed it
> using emacs HEXL-MODE; It's one character, "0a", not "0d0a". Maybe I
> need to use /^0x0d$/(where 0x0d may not be correct - I may have to be
> clever to put a "0d" between ^ and $). Or maybe I can change $/ to
> hex0d0a for evaluating this file. I had hoped (and still hope)for a
> magic bullet that would put this problem to bed. I wonder if chomp
> changes the EOL character to "0a"?

Any chance you've called binmode for this filehandle?  If not, then I
think it *should* work and you shouldn't be having this line ending
trouble.  Unless the file is from a different system (i.e. the file is
from an NT system, but you are running on a UNIX-type system).

-- 
Ren Maddox
ren@tivoli.com


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

Date: Mon, 18 Sep 2000 23:30:39 GMT
From: ollie_spencer@my-deja.com
Subject: Re: Range operator with "... /^$/"
Message-Id: <8q68iv$nu2$1@nnrp1.deja.com>

In article <8q66oh$lpo$1@nnrp1.deja.com>,
  Brendon Caligari <bcaligari@my-deja.com> wrote:
> In article <8q61q8$fsl$1@nnrp1.deja.com>,
>   ollie_spencer@my-deja.com wrote:
> > I agree. I'm covered by embarassment, since my code DOES have "if",
=== Much snipped======

By replacing /^$/ with /^\x0d$/ I have been able to do what I wanted.
On the other hand, I'd be happier with replacing $/ with something that
would be more elegant.
My code now goes something like

open INFILE;
binmode(INFILE);
while(<INFILE>){
   if(/LOG AN EVENT/ ... /^\x0d$/){
      do something;
      }
}

And it does snatch out every occurence of the LOG AN EVENT paragraph and
prints it, and just that-

Thanks for your input!

ollie spencer


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Mon, 18 Sep 2000 22:27:06 GMT
From: nodo70@my-deja.com
Subject: readir
Message-Id: <8q64r1$jmb$1@nnrp1.deja.com>

Can anyone tell me what's wrong with my code below when it doesn't work
with a directory named C++ (if $targetDir contain an another dir called
C++)?  It will complain /C++/: nested *?+ in regexp at ./readir.pl line
xxx

$targetDir = $ARGV[0];
&recursiveDir ($targetDir);
exit(0);

#-----------------------------------------------------------------------
--------
# recursiveDir subroutine: to recursive through directories
#-----------------------------------------------------------------------
--------
sub recursiveDir {
    my ($targetDir) = @_;
    my (@files);
    my ($nextDir);
    opendir(DIR, "$targetDir") || die("Can't find $targetDir directory
!!!");
    @files = readdir(DIR);
    closedir(DIR);
    foreach $subDir (sort @files) {
       $nextDir = $targetDir . "\/" . $subDir;
       if ( -d $nextDir ) {
          if (!(($subDir =~ /^\.$/i) or ($subDir =~ /^\.\.$/i) or (grep
(/$subDir/,@dirIgnore)))) {
             &recursiveDir($nextDir);
          }
       }
       else {
             &doSomething($targetDir . "\/" .$subDir);
       }
    }
}


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 18 Sep 2000 23:13:02 GMT
From: cjw44@flatline.org.uk (Colin Watson)
Subject: Re: readir
Message-Id: <8q67hu$gpe$1@riva.ucam.org>

nodo70@my-deja.com wrote:
>Can anyone tell me what's wrong with my code below when it doesn't work
>with a directory named C++ (if $targetDir contain an another dir called
>C++)?  It will complain /C++/: nested *?+ in regexp at ./readir.pl line
>xxx
[...]
>          if (!(($subDir =~ /^\.$/i) or ($subDir =~ /^\.\.$/i) or (grep
>(/$subDir/,@dirIgnore)))) {

You need /\Q$subdir\E/ (or just /\Q$subdir/) instead of /$subdir/, to
stop the value of $subdir being interpreted as containing regex
metacharacters. See the perlre(1p) man page.

-- 
Colin Watson                                     [cjw44@flatline.org.uk]
Jam wants colonies. I am a jest on clowns.


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

Date: 18 Sep 2000 18:27:27 -0400
From: Dan Schmidt <dfan@harmonixmusic.com>
Subject: Re: Regular Expressions: Counting matches?
Message-Id: <wk66nt9vzk.fsf@turangalila.harmonixmusic.com>

Chovy <johndoyle33@hotmail.com> writes:

| Hello,
| 
| I want to find out how many times a word is matched in a string a text.
| Basically, I want to count the number of links on a page...
| ie-
| 
| ---
| m/<a href=/ig
| ---
| 
| how do I find out how many times it's been matched?

$num_matches = () = m/<a href=/ig;

In list context, m//g returns all the matches.  The () forces m// into
list context, and then that list gets looked at in a scalar context
(generating the list's length) in order to set $num_matches.

-- 
                 Dan Schmidt | http://www.dfan.org
Honest Bob CD now available! | http://www.dfan.org/honestbob/cd.html


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

Date: Mon, 18 Sep 2000 16:49:52 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Regular Expressions: Counting matches?
Message-Id: <MPG.143049fea08feb8198ad8b@nntp.hpl.hp.com>

In article <wk66nt9vzk.fsf@turangalila.harmonixmusic.com> on 18 Sep 2000 
18:27:27 -0400, Dan Schmidt <dfan@harmonixmusic.com> says...
> Chovy <johndoyle33@hotmail.com> writes:

 ...

> | I want to find out how many times a word is matched in a string a text.
> | Basically, I want to count the number of links on a page...
> | ie-
> | 
> | ---
> | m/<a href=/ig
> | ---
> | 
> | how do I find out how many times it's been matched?
> 
> $num_matches = () = m/<a href=/ig;
> 
> In list context, m//g returns all the matches.  The () forces m// into
> list context, and then that list gets looked at in a scalar context
> (generating the list's length) in order to set $num_matches.

Yuk.  That is the second time that gross and inefficient solution has 
been posted in this thread.

perlfaq4: How can I count the number of occurrences of a substring 
within a string?"

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Mon, 18 Sep 2000 23:09:01 GMT
From: esper@news.visi.com (Dave Sherohman)
Subject: Re: Running a perl program as a daemon?
Message-Id: <slrn8sd84c.jci.esper@pchan.dojo>

On Tue, 19 Sep 2000 00:33:35 +1000, Damien Dove <Damien_Dove@bigpond.com> wrote:
> At the moment i have a program that runs selected commands to a schedule.
> I'd like to convert that program to a daemon. What things do i have to
> change etc..

Very little.  When a program is run from inetd, STDIN, STDOUT, and STDERR all
point to the network connection instead of the console, so you just use them
normally.

The two things I've run across doing this are:

1) If you expect a human to be on the other end of the connection, consider
ending your lines with \r\n instead of just \n.  Otherwise, people at Windows
clients may
            get their text
                           formatted like this.
Conversely, I had to use s/[\r\n]*$// instead of chomp to clean up line ends,
since (without doing some sort of client detection) you don't know whether to
expect lines to end with \n, \r, or \r\n.

If you're using a binary protocol, this isn't an issue, of course.

2) You'll probably have to set $| = 1 to disable output buffering so that the
client will see transmitted data immediately instead of the server holding it
until a \n is encountered or the backlog of data exceeds a certain size.

-- 
"Two words: Windows survives." - Craig Mundie, Microsoft senior strategist
"So does syphillis. Good thing we have penicillin." - Matthew Alton
Geek Code 3.1:  GCS d- s+: a- C++ UL++$ P+>+++ L+++>++++ E- W--(++) N+ o+
!K w---$ O M- V? PS+ PE Y+ PGP t 5++ X+ R++ tv b+ DI++++ D G e* h+ r++ y+


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

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


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