[12627] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 36 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jul 7 02:17:35 1999

Date: Tue, 6 Jul 1999 23:07:03 -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           Tue, 6 Jul 1999     Volume: 9 Number: 36

Today's topics:
        mkdir() only sets owner permission? (Scott Cale)
    Re: mkdir() only sets owner permission? (elephant)
    Re: mkdir() only sets owner permission? (Abigail)
    Re: mkdir() only sets owner permission? (Jim Britain)
    Re: mkdir() only sets owner permission? (Abigail)
    Re: mkdir() only sets owner permission? (Scott Cale)
    Re: mkdir() only sets owner permission? <uri@sysarch.com>
    Re: MLDBM on WIN32 <not@gonna.tell>
    Re: MLDBM on WIN32 <not@gonna.tell>
    Re: mod_perl and resources <elaine@chaos.wustl.edu>
        More newbie questions <jamescwalker@csi.com>
    Re: More newbie questions (Abigail)
    Re: More newbie questions (Jon Bell)
    Re: mput command (Abigail)
    Re: mput command (Laar)
    Re: mput command <gellyfish@gellyfish.com>
        multiline matching fun <urban@spielwiese.de>
    Re: multiline matching fun (Abigail)
    Re: multiline matching fun (Mark-Jason Dominus)
    Re: multiline matching fun <urban@spielwiese.de>
    Re: multiline matching fun (John Borwick)
    Re: multiline matching fun <urban@spielwiese.de>
        Multiline tainting problem <therobin@nortelnetworks.com>
        My Apologies! <jamesthurley@hotmail.com>
    Re: My First Perl error...I'm just learning. <gellyfish@gellyfish.com>
        Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)

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

Date: 6 Jul 99 00:55:33 GMT
From: uo780@vtn1.victoria.tc.ca (Scott Cale)
Subject: mkdir() only sets owner permission?
Message-Id: <37815405.0@news.victoria.tc.ca>


I'm writing a fragment of code that should take a name and create a sub
directory with that name. Simple

I have the line
mkdir $name,0777 || die "can't create $name!\n";

in my code but something is wrong. The directory is created ok but only
the user bit gets set. No matter what I try, the group and world
permissions are always set to ------.

Why?

I'm running it on a solaris (Sun 5.6) machine using perl 5.004_04. Please
email replies.

Thank you

Scott


-----
Scott Cale
uo780@victoria.tc.ca               Canada Rocks!               ()_()
Walt Disney World International Program (Canada) 7/95 - 4/96    (_) 


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

Date: Tue, 6 Jul 1999 11:03:59 +1000
From: e-lephant@b-igpond.com (elephant)
Subject: Re: mkdir() only sets owner permission?
Message-Id: <MPG.11ec0102e7bcfce0989b01@news-server>

Scott Cale writes ..
>I have the line
>mkdir $name,0777 || die "can't create $name!\n";

from the perlfunc documentation

mkdir FILENAME,MODE 
	Creates the directory specified by FILENAME, with permissions
	specified by MODE (as modified by umask). If it succeeds it
	returns TRUE, otherwise it returns FALSE and sets $! (errno).

umask EXPR 
umask 
	Sets the umask for the process to EXPR and returns the previous
	value. If EXPR is omitted, merely returns the current umask. 

	If umask(2) is not implemented on your system and you are trying
	to restrict access for yourself (i.e., (EXPR & 0700) > 0),
	produces a fatal error at run time. If umask(2) is not implemented
	and you are not trying to restrict access for yourself, returns
	undef. 

	Remember that a umask is a number, usually given in octal; it is
	not a string of octal digits. See also oct, if all you have is a
	string.

-- 
 jason - remove all hyphens for email reply -


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

Date: 5 Jul 1999 20:54:38 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: mkdir() only sets owner permission?
Message-Id: <slrn7o2oea.h6v.abigail@alexandra.delanet.com>

Scott Cale (uo780@vtn1.victoria.tc.ca) wrote on MMCXXXV September
MCMXCIII in <URL:news:37815405.0@news.victoria.tc.ca>:
<> 
<> I'm writing a fragment of code that should take a name and create a sub
<> directory with that name. Simple
<> 
<> I have the line
<> mkdir $name,0777 || die "can't create $name!\n";
<> 
<> in my code but something is wrong. The directory is created ok but only
<> the user bit gets set. No matter what I try, the group and world
<> permissions are always set to ------.
<> 
<> Why?


That's clearly explained in the manual. Did you read it?



Abigail
-- 
sub f{sprintf'%c%s',$_[0],$_[1]}print f(74,f(117,f(115,f(116,f(32,f(97,
f(110,f(111,f(116,f(104,f(0x65,f(114,f(32,f(80,f(101,f(114,f(0x6c,f(32,
f(0x48,f(97,f(99,f(107,f(101,f(114,f(10,q ff)))))))))))))))))))))))))


  -----------== 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: Tue, 06 Jul 1999 02:03:23 GMT
From: jbritain@home.com (Jim Britain)
Subject: Re: mkdir() only sets owner permission?
Message-Id: <378160f6.15990811@news>

[mailed and posted]
On 6 Jul 99 00:55:33 GMT, uo780@vtn1.victoria.tc.ca (Scott Cale)
wrote:


>I have the line
>mkdir $name,0777 || die "can't create $name!\n";
>
>in my code but something is wrong. The directory is created ok but only
>the user bit gets set. No matter what I try, the group and world
>permissions are always set to ------.


Operator precedence see: Learning Perl pg 38-39

The || (logical or) operator is evaluated before the comma operator.

Switch to the lower precedence "or" (logical or).

or

place parenthesis around the parameters passed to the mkdir function.

i.e. mkdir($name,0777) || die....

Most people use the wrong representation for logical or ( || ) when
they really want the ( or ) precedence.  || looks pretty and is more
visible.

And very few people even know that the comma is an operator itself,
and is most times evaluated as such, when people drop parens in
function calls.

People who call it ambiguous do not know the operators, or their
precedence.




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

Date: 5 Jul 1999 22:21:14 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: mkdir() only sets owner permission?
Message-Id: <slrn7o2tgl.h6v.abigail@alexandra.delanet.com>

Jim Britain (jbritain@home.com) wrote on MMCXXXV September MCMXCIII in
<URL:news:378160f6.15990811@news>:
[] [mailed and posted]
[] On 6 Jul 99 00:55:33 GMT, uo780@vtn1.victoria.tc.ca (Scott Cale)
[] wrote:
[] 
[] 
[] >I have the line
[] >mkdir $name,0777 || die "can't create $name!\n";
[] >
[] >in my code but something is wrong. The directory is created ok but only
[] >the user bit gets set. No matter what I try, the group and world
[] >permissions are always set to ------.
[] 
[] 
[] Operator precedence see: Learning Perl pg 38-39
[] 
[] The || (logical or) operator is evaluated before the comma operator.


While that's true, 0777 || die "..." still equals 0777.



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/=/./;


  -----------== 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: 6 Jul 99 05:19:55 GMT
From: uo780@vtn1.victoria.tc.ca (Scott Cale)
Subject: Re: mkdir() only sets owner permission?
Message-Id: <378191fb.0@news.victoria.tc.ca>

Scott Cale (uo780@vtn1.victoria.tc.ca) wrote:

: I'm writing a fragment of code that should take a name and create a sub
: directory with that name. Simple

: I have the line
: mkdir $name,0777 || die "can't create $name!\n";

: in my code but something is wrong. The directory is created ok but only
: the user bit gets set. No matter what I try, the group and world
: permissions are always set to ------.

: Why?

: I'm running it on a solaris (Sun 5.6) machine using perl 5.004_04. Please
: email replies.

Ok, I'm told it might be an operator presidence (spelling?) problem so I
pared it doewn to the most basic script

#!/public/bin/perl -w
use diagnostics;
mkdir("testdir",0777);

Still doesn't work. It creates the directory with the user permission set
to rwx and group/world permissions set to ------ *sigh*

I guess I'll have to use shell commands instead :-(

Scott

-----
Scott Cale
uo780@victoria.tc.ca               Canada Rocks!               ()_()
Walt Disney World International Program (Canada) 7/95 - 4/96    (_) 


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

Date: 06 Jul 1999 01:53:43 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: mkdir() only sets owner permission?
Message-Id: <x7oghquxw8.fsf@home.sysarch.com>

>>>>> "SC" == Scott Cale <uo780@vtn1.victoria.tc.ca> writes:


  SC> #!/public/bin/perl -w
  SC> use diagnostics;
  SC> mkdir("testdir",0777);

  SC> Still doesn't work. It creates the directory with the user permission set
  SC> to rwx and group/world permissions set to ------ *sigh*

  SC> I guess I'll have to use shell commands instead :-(

i bet they fail too. did you lookup up umask in both perl and your unix
man pages? did you check what your umask value is? 

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: Mon, 5 Jul 1999 23:35:08 -0400
From: "Doug Crabtree" <not@gonna.tell>
Subject: Re: MLDBM on WIN32
Message-Id: <7lrtel$m7d$1@nntp8.atl.mindspring.net>

Faisal Nasim <swiftkid@bigfoot.com> wrote in message
news:7lj729$7ek2@news.cyber.net.pk...
> It works fine for me!
>
> Try installing DB_File through PPM and see if it solves the problem.

I found out it works fine for me too.  The problem was with flock().  Oh
well, going to try to figure out how to use flock here...

Thanks,
Doug




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

Date: Tue, 6 Jul 1999 01:16:26 -0400
From: "Doug Crabtree" <not@gonna.tell>
Subject: Re: MLDBM on WIN32
Message-Id: <7ls3ds$ppg$1@nntp6.atl.mindspring.net>

Ok, I got rid of the flock statements and at least the script ran.

Let me ask just one more question:  How different should a perl program
written on a Apache server be from one on a Win32 system?  I can't even get
my code to create a datafile using MLDBM.  Maybe my first code was sloppy
and Apache is just more forgiving, or maybe my brain got fried by firework
smoke.  Who knows.

Can you give me an example of a tie statement that works on a Win32 system?
Obviously I am missing something.

Also, is it possible to use the same MLDBM data file from the Apache server?
Or do you have to convert it somehow?  On a key count of the database, I get
3 on the apache and a 2 on the Win32 (same file)!?!?!?!?!?

Thanks,
Doug




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

Date: Mon, 5 Jul 1999 11:37:17 -0500
From: elaine ashton <elaine@chaos.wustl.edu>
Subject: Re: mod_perl and resources
Message-Id: <Pine.GSO.4.05.9907051134280.21584-100000@chaos.wustl.edu>

> Anyone using mod_perl with Apache?  To me it seems that every httpd process
> is running perl interpreter so that it eats a lot of resources.

Lots of people are using mod_perl with Apache. 

The docs should explain all you wish to know at http://perl.apache.org/

One nice section on perf tuning....


REDUCING MEMORY USE 

As a side effect of using mod_perl, your HTTPD processes will be larger
than without it. There is just no way around it, as you have this extra
code to support your added functionality.

On a very busy site, the number of HTTPD processes can grow to be quite
large. For example, on one large site, the typical HTTPD was about 5Mb
large. With 30 of these, all of RAM was exhausted, and we started to go to
swap. With 60 of these, swapping turned into thrashing, and the whole
machine slowed to a crawl.

To reduce thrashing, limiting the maximum number of HTTPD processes to a
number that is just larger than what will fit into RAM (in this case, 45)
is necessary. The drawback is that when the server is serving 45 requests,
new requests will queue up and wait; however, if you let the maximum
number of processes grow, the new requests will start to get served right
away, but they will take much longer to complete.

One way to reduce the amount of real memory taken up by each process is to
pre-load commonly used modules into the primary HTTPD process so that the
code is shared by all processes. This is accomplished by inserting the use
Foo (); lines into the startup.perl file for any use Foo; statement in any
commonly used Registry program. The idea is that the operating system's VM
subsystem will share the data across the processes.

enjoy.

e.
-- 

         -=]) elaine ashton // elaine@chaos.wustl.edu // HFB ([=-
   -=]) A dismal wasteland of banality, cliche' and casual obscenity ([=- 



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

Date: Sat, 03 Jul 1999 14:26:04 -0800
From: CapWalker <jamescwalker@csi.com>
Subject: More newbie questions
Message-Id: <931040765.11966@www.remarq.com>

My first question has to do with compiling Perl to a stand
alone module. I'm on Windows98 and would like to distribute
the apps with having the user downloading Perl. How can I do
this ?

My second question has to do with running under Windows98. I
can't seem to associate the Perl scripts with the compiler.
Does anyone know how this can be done ?

My third question follows another thread here, why Perl ?
Given a limited lifespan, and even more limited time to
learn new languages, what are the good ones to know ? It
seems that Visual Basic is a winner and maybe C (or C++),
but as an intermediate language there's Delphi, JBuilder
(Java) along with a few more.

My Last question (for now) is how to get back to the
newsgroup to find my original questions. I'm using ReMarq to
read the newsgroup (I can't get Netscape working right with
it) so I'm only getting those messages emailed to me. Any
help on this end would be appreciated too!



**** Posted from RemarQ - http://www.remarq.com - Discussions Start Here (tm) ****


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

Date: 3 Jul 1999 18:57:00 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: More newbie questions
Message-Id: <slrn7nt8pp.31h.abigail@alexandra.delanet.com>

CapWalker (jamescwalker@csi.com) wrote on MMCXXXII September MCMXCIII in
<URL:news:931040765.11966@www.remarq.com>:
// My first question has to do with compiling Perl to a stand
// alone module. I'm on Windows98 and would like to distribute
// the apps with having the user downloading Perl. How can I do
// this ?

FAQ. But what if they already have Perl? Do you want to force them
to download your program that's basically Perl with a wrapper around it?

// My second question has to do with running under Windows98. I
// can't seem to associate the Perl scripts with the compiler.
// Does anyone know how this can be done ?

Associate Perl scripts with the compiler? Do you understand yourself
what you are saying? I surely don't.

// My third question follows another thread here, why Perl ?

Why not?

// Given a limited lifespan, and even more limited time to
// learn new languages, what are the good ones to know ? It
// seems that Visual Basic is a winner and maybe C (or C++),
// but as an intermediate language there's Delphi, JBuilder
// (Java) along with a few more.

Well, if you think Visual Basic is a winner, go for it! And who
knows, perhaps C as well. It's a good outsider, but a bit young.
Perhaps it need to mature a bit. And Java is fine too. It's soo
backwards compatible and crossplatform!

// My Last question (for now) is how to get back to the
// newsgroup to find my original questions. I'm using ReMarq to
// read the newsgroup (I can't get Netscape working right with
// it) so I'm only getting those messages emailed to me. Any
// help on this end would be appreciated too!

Uhm, get a real newsreader? I've never had any problems with nn, rn,
tin, trn, slrn and a handful of other newsreaders I can't remember
the names of.



Abigail
-- 
perl -e '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
         / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / 
         % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %;
         BEGIN {% % = ($ _ = " " => print "Just Another Perl Hacker\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: Sun, 4 Jul 1999 15:31:46 GMT
From: jtbell@presby.edu (Jon Bell)
Subject: Re: More newbie questions
Message-Id: <FECr4y.AHL@presby.edu>

 CapWalker  <jamescwalker@csi.com> wrote:
>Given a limited lifespan, and even more limited time to
>learn new languages, what are the good ones to know ? It
>seems that Visual Basic is a winner and maybe C (or C++),
>but as an intermediate language there's Delphi, JBuilder
>(Java) along with a few more.

Don't forget to reserve some time to learn the new hot "must-learn"
languages that will surely be developed during the rest of your working
lifetime.

-- 
Jon Bell <jtbell@presby.edu>                        Presbyterian College
Dept. of Physics and Computer Science        Clinton, South Carolina USA
        [     Information about newsgroups for beginners:     ]            
        [ http://www.geocities.com/ResearchTriangle/Lab/6882/ ]


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

Date: 2 Jul 1999 20:05:32 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: mput command
Message-Id: <slrn7nqoeb.31h.abigail@alexandra.delanet.com>

David Thornton (/dev/null@davidthornton.com) wrote on MMCXXXI September
MCMXCIII in <URL:news:XDMAYHAz6Ff3EwOz@davidthornton.com>:
|| This is very basic FTP but I am having trouble.


Then you shouldn't be asking in a Perl group. Perl and FTP have no
letters in common.



Abigail
-- 
perl -wlne '}for($.){print' file  # Count the number of lines.


  -----------== 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: Sun, 04 Jul 1999 06:20:27 GMT
From: laar@ix.netcom.com (Laar)
Subject: Re: mput command
Message-Id: <377efd19.29693967@nntp.ix.netcom.com>

On 2 Jul 1999 20:05:32 -0500, abigail@delanet.com (Abigail) wrote:

>Then you shouldn't be asking in a Perl group. Perl and FTP have no
>letters in common.

Wonderful, just wonderful. The bitch is not only arrogant and
condescending, but *blind* too.

--
Laar
www.netcom.com/~laar/index.html


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

Date: 4 Jul 1999 14:45:39 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: mput command
Message-Id: <7lns2j$3vs$1@gellyfish.btinternet.com>

On Sun, 04 Jul 1999 06:20:27 GMT Laar wrote:
> On 2 Jul 1999 20:05:32 -0500, abigail@delanet.com (Abigail) wrote:
> 
>>Then you shouldn't be asking in a Perl group. Perl and FTP have no
>>letters in common.
> 
> Wonderful, just wonderful. The bitch is not only arrogant and
> condescending, but *blind* too.
> 

How charming

*plonk*

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>


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

Date: Tue, 06 Jul 1999 04:30:38 +0200
From: Rob Urban <urban@spielwiese.de>
Subject: multiline matching fun
Message-Id: <37816A4E.A31EE09A@spielwiese.de>

I've got the string (lines with "snip snip" not part of string):

-------------------- snip snip ---------------------
Congratulations !!
The domain
        booger.de
has been successfully updated.
The changes were:
        nserver: ns.booger.de 123.123.123.123
        nserver: foobar.de
        remarks: NS und admin-c UPDATE
        tech-c: AAA666-RIPE
        zone-c: AAA666-RIPE
        admin-c: AAA666-RIPE
The changes for The domain
        booger.de
 will take effect after the next restart of the nameserver.
This happens normally between 8:00 am and 10:00 am on every working day.
-------------------- snip snip ---------------------

When I try to use the following regexp:

$re = '^Congratulations\s*!!\n'.
    'The domain\n'.
    '\t(\S+)\n'.
    'has.*updated\.\n'.
    'The changes were:\n'.
    '(\t.*\n)+'.
    'The changes.*domain\n'.
    '\t\S+\n'.
    '\s*will take effect.*nameserver\.\n'.
    'This happens.*day\.$';

all I get in $2 is "admin-c: AAA666-RIPE".

However, if I use:

$re = '^Congratulations\s*!!\n'.
    'The domain\n'.
    '\t(\S+)\n'.
    'has.*updated\.\n'.
    'The changes were:\n'.
    '((\t.*\n)*\t.*\n)+'.
    'The changes.*domain\n'.
    '\t\S+\n'.
    '\s*will take effect.*nameserver\.\n'.
    'This happens.*day\.$';

then $2 is equal to

        nserver: ns.booger.de 123.123.123.123
        nserver: foobar.de
        remarks: NS und admin-c UPDATE
        tech-c: AAA666-RIPE
        zone-c: AAA666-RIPE
        admin-c: AAA666-RIPE

why is that? I expected "(\t.*\n)+" to match one or more occurrences of
a tab followed by anything, followed by a newline.

Rob Urban


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

Date: 5 Jul 1999 22:55:31 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: multiline matching fun
Message-Id: <slrn7o2vgv.h6v.abigail@alexandra.delanet.com>

Rob Urban (urban@spielwiese.de) wrote on MMCXXXV September MCMXCIII in
<URL:news:37816A4E.A31EE09A@spielwiese.de>:
,, 
,, why is that? I expected "(\t.*\n)+" to match one or more occurrences of
,, a tab followed by anything, followed by a newline.


No, as explained in the manual. It also explains how you can make it
what you expected it to match.



Abigail
-- 
perl -e '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
         / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / 
         % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %;
         BEGIN {% % = ($ _ = " " => print "Just Another Perl Hacker\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: Tue, 06 Jul 1999 09:31:56 GMT
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: multiline matching fun
Message-Id: <7lsidf$7op$1@monet.op.net>

In article <37816A4E.A31EE09A@spielwiese.de>,
Rob Urban  <urban@spielwiese.de> wrote:
>I expected "(\t.*\n)+" to match one or more occurrences of
>a tab followed by anything, followed by a newline.

`.' normally matches any character except a newline.
Use the  /s option on the regex match to make `.' match newlines.


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

Date: Tue, 06 Jul 1999 16:40:57 +0200
From: Rob Urban <urban@spielwiese.de>
Subject: Re: multiline matching fun
Message-Id: <37821579.724381AC@spielwiese.de>

Abigail wrote:
> 
> Rob Urban (urban@spielwiese.de) wrote on MMCXXXV September MCMXCIII in
> <URL:news:37816A4E.A31EE09A@spielwiese.de>:
> ,,
> ,, why is that? I expected "(\t.*\n)+" to match one or more occurrences of
> ,, a tab followed by anything, followed by a newline.
> 
> No, as explained in the manual. It also explains how you can make it
> what you expected it to match.
> 
> Abigail

yes.  I've been through perlre(1), the FAQ, FMTEYEWTK but maybe I'm just
stoopid.

would a more kind and helpful person care to answer this question?

summary: why doesn't the re "(\t.*\n)+" match a series of lines beginning with
a tab char? Or rather the re matches, but the corresponding substring variable
contains only the last line, rather than all the lines.

Rob Urban


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

Date: Tue, 6 Jul 1999 16:37:50 GMT
From: John.Borwick@sas.com (John Borwick)
Subject: Re: multiline matching fun
Message-Id: <37852f9f.16061815@newshost.unx.sas.com>

On Tue, 06 Jul 1999 16:40:57 +0200, Rob Urban <urban@spielwiese.de>
wrote:

>summary: why doesn't the re "(\t.*\n)+" match a series of lines beginning with
>a tab char? Or rather the re matches, but the corresponding substring variable
>contains only the last line, rather than all the lines.

the (\t.*\n)+ that you're using now matches a series of lines, each
ending in a newline.  however since each line is different, every time
a new line is matched $2 is updated because a different string of the
same form is found.


if you would like to match all the lines, i suspect you should use


( (?:\t.*\n)+ )

which is almost exactly what you'd said before.  here's what you
wrote:

>    '((\t.*\n)*\t.*\n)+'.

this can be compressed to ( (\t.*\n)+ )+
so right now if you looked at $3 in this code you'd probably get the
next to last line.

$2 will only be equal to several lines if the + is inside the
parentheses.

hope this helps,

-- 
john borwick


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

Date: Tue, 06 Jul 1999 19:19:27 +0200
From: Rob Urban <urban@spielwiese.de>
Subject: Re: multiline matching fun
Message-Id: <37823A9F.3610CF97@spielwiese.de>

John Borwick wrote:
> 
> [useful bits deleted]
> 
> hope this helps,

thanks!

Rob Urban


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

Date: Tue, 06 Jul 1999 14:43:13 -0400
From: Robin Senior <therobin@nortelnetworks.com>
Subject: Multiline tainting problem
Message-Id: <37824E41.E0324D67@nortelnetworks.com>

Hi,
I have a cgi script that accepts input from html "textareas".
These textareas are usually populated by cutting and pasting text from
other websites, which means they occasionally contain
characters/formatting that the user doesn't intend on including, and end
up accidentally tainting the variables.

The submitted info is stored in a flat-text database, with records
delimited by newlines. Sometimes people enter stuff like:


This is line1.

This is line3.


I've done the obvious, which is:

$fields{'input'} =~s/[\n\f]//sg;

to get rid of newlines. It gets rid of newlines, yet allows the input to
remain its multiline formatting. (I guess seperate lines in textareas
are passed as \r's)
This worked for about a month, then for some reason, some submissions
would act as though they contained \n's, even though they were filtered
out. I think this may be a problem with ^M (multiline) characters, but
I'm not sure.

Would something like:

$fields{'input'} =~ s/\cM/\r/sg;

solve it, or are there other potential pseudo-newline characters?
I know \r doesn't count as a newline... I hadn't heard of ^M until a
couple of days ago. What other characters could cause it to think there
is a newline?

I can't use something like s/\s//g because I need to retain the
formatting... I don't even know if that would catch it.

I think the multiline character varies from system to system and editor
to editor, so what should I filter for? I think it actually showed up as
M-^V in vi and e...

Thanks in advance,
-robin


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

Date: Tue, 6 Jul 1999 22:32:40 +0100
From: "James Thurley" <jamesthurley@hotmail.com>
Subject: My Apologies!
Message-Id: <7ltsi2$qe5$1@gxsn.com>

I have just been given a warning that I have been asking non-Perl questions,
and I may get flamed.  I thought that my questions where perl related, as
they where about CGI, but it would seem not.
I apologise and will not bother you all again.

James.




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

Date: 2 Jul 1999 22:12:11 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: My First Perl error...I'm just learning.
Message-Id: <7ljdfr$223$1@gellyfish.btinternet.com>

On Tue, 29 Jun 1999 19:26:47 GMT av8tor@flash.net wrote:
> I'm just starting to learn perl and CGI.
> I'm getting the following error when trying to call my program from
> Netscape:
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> Script execution error
> 
> Unable to execute script due to a configuration problem.
> Please notify the webmaster of this error.
> 
> exec() returned: 2: No such file or directory
> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> 
> this is my cgi code I uploaded
> 
> #!/bin/perl

I would check with your ISP whether that is the actual path to your
perl as the error would seem to indicate otherwise.

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>


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

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


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