[22123] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4345 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jan 5 14:05:46 2003

Date: Sun, 5 Jan 2003 11:05:08 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sun, 5 Jan 2003     Volume: 10 Number: 4345

Today's topics:
        changing user password <tmartin15@jam.rr.com>
    Re: changing user password <tmartin15@jam.rr.com>
    Re: changing user password <s.patterson@freeuk.com>
        Please help - CYGWIN install of Apache+Perl (Boris Pelakh)
    Re: regexp question <jurgenex@hotmail.com>
    Re: regexp question (tî'pô)
    Re: regexp question (Tad McClellan)
    Re: regexp question (Tad McClellan)
    Re: regexp question <kasp@NO_SPAMepatra.com>
    Re: Should I worry about the optimizer. (Tad McClellan)
        top-posting (was Re: regexp question) (Tad McClellan)
    Re: top-posting (was Re: regexp question) <kasp@NO_SPAMepatra.com>
    Re: top-posting (was Re: regexp question) <joe+usenet@sunstarsys.com>
        What are the software editor/creative choices for Perl <jbarrington@comcast.non>
    Re: What are the software editor/creative choices for P <jurgenex@hotmail.com>
    Re: What are the software editor/creative choices for P <kasp@NO_SPAMepatra.com>
        While loop  <No_Mail_Address@cox.net>
    Re: While loop <bramoshe@runslinux.net>
    Re: While loop <jurgenex@hotmail.com>
    Re: While loop <No_Mail_Address@cox.net>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sun, 05 Jan 2003 17:06:32 GMT
From: "Tommy" <tmartin15@jam.rr.com>
Subject: changing user password
Message-Id: <sCZR9.111109$6H6.3691234@twister.austin.rr.com>

Is there a way to change the users password via perl? I need to create an
html page that will allow the user to modify this if possible.

Thanks in advance...
Tommy





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

Date: Sun, 05 Jan 2003 17:09:37 GMT
From: "Tommy" <tmartin15@jam.rr.com>
Subject: Re: changing user password
Message-Id: <lFZR9.111130$6H6.3691555@twister.austin.rr.com>

I should have included that this on on a redhat linux system.

Tommy

"Tommy" <tmartin15@jam.rr.com> wrote in message
news:sCZR9.111109$6H6.3691234@twister.austin.rr.com...
> Is there a way to change the users password via perl? I need to create an
> html page that will allow the user to modify this if possible.
>
> Thanks in advance...
> Tommy
>
>
>




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

Date: 5 Jan 2003 18:43:32 GMT
From: Stephen Patterson <s.patterson@freeuk.com>
Subject: Re: changing user password
Message-Id: <slrnb1guvf.de.s.patterson@eccles.localdomain>

On Sun, 05 Jan 2003 17:09:37 GMT, Tommy wrote:
>> Is there a way to change the users password via perl? I need to create an
>> html page that will allow the user to modify this if possible.

You may be able to execute passwd through system(), if that doesn't
work, the passwords in /etc/passwd are encrypted through the system's
crypt command.

-- 
Stephen Patterson http://www.lexx.uklinux.net http://patter.mine.nu
steve@SPAM.lexx.uklinux.net  remove SPAM to reply        
Linux Counter No: 142831 GPG Public key: 252B8B37        
Last one down the pub's an MCSE


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

Date: 5 Jan 2003 09:59:26 -0800
From: pelakh@yahoo.com (Boris Pelakh)
Subject: Please help - CYGWIN install of Apache+Perl
Message-Id: <44ec9ada.0301050959.aaa1537@posting.google.com>

I installed perl 5.6 and apache 1.3 from the cygwin setup program, but
it did not install mod_perl. I cannot find mod_perl.so anywhere. I also
cannot find there httpd.conf was put or even how to start apache. All the
other modules were installed in cygwin/lib/apache. I have previously done the 
IndigoPerl installation and it was very straight forward.

I appreciate any help I can get.

-- Boris


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

Date: Sun, 05 Jan 2003 16:12:05 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: regexp question
Message-Id: <pPYR9.1443$Db.974@nwrddc02.gnilink.net>

C3 wrote:
> I'm doing a bit of ad blocking and I'm having trouble coming up with a
> specific regex to suit my purpose. I'll give an example for amazon.com
>
> *
>
http://g-images.amazon.com/images/G/01/marketing/cross-shop/arnold/apparel/1
> 202/ap_sr_on_1226_2.gif is an image I don't want to load
> * http://g-images.amazon.com/images/G/01/icons/icon_listmania.gif is
> an image I *do* want to load
>
> simply looking at the length of the two strings leads me to one
> answer. match any string starting with g-images.amazon.com and having
> up to five slashes after that. I feel this will be safe enough, but
> how do I come up with the expression?

I never understood why people are trying to use complicated REs to solve
each and any problem they run into. Perl has many more functions then just
REs:
- use m in list context with the modifier g and it will return a list of all
matches. Just use a single slash as search expression and then take the
length of the returned list.
- s returns the number of substitutions made. So just substitute a single
slash globally and take the return value of s
- But you don't even need to make the single slash a RE. Probably the fastet
method is to use tr to replace the single slash with whatever and then to
take the return value.

    tr/SEARCHLIST/REPLACEMENTLIST/cds
    y/SEARCHLIST/REPLACEMENTLIST/cds
            Transliterates all occurrences of the characters found in the
            search list with the corresponding character in the replacement
            list. It returns the number of characters replaced or deleted.

jue




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

Date: Sun, 05 Jan 2003 18:22:27 +0200
From: "Teh (tî'pô)" <teh@mindless.com>
Subject: Re: regexp question
Message-Id: <qimg1vsal0lfneet1ld4u6nqdpk554d8jp@4ax.com>

Kasp bravely attempted to attach 55 electrodes of knowledge
to the nipples of comp.lang.perl.misc by saying:
>I am new to Perl. I find your regex is not correct. You should 'escape' the
>slashes (/).
Instead of escaping every slash you can use a different separator for
m// (the match operator).

<snip>
>if(/^http:\/\/g-images.amazon.com(\/.*){5,}/)
 if(m#^http://g-images.amazon.com(/.*){5,}#) # saved 2 chars!!! Yay.

To me this is clearer, the url still looks like a url.


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

Date: Sun, 5 Jan 2003 08:52:04 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: regexp question
Message-Id: <slrnb1ghkk.8se.tadmc@magna.augustmail.com>

C3 <someone@microsoft.com> wrote:

> http://g-images.amazon.com/images/G/01/marketing/cross-shop/arnold/apparel/1
> 202/ap_sr_on_1226_2.gif is an image I don't want to load
> * http://g-images.amazon.com/images/G/01/icons/icon_listmania.gif is an
> image I *do* want to load
> 
> simply looking at the length of the two strings leads me to one answer.
> match any string starting with g-images.amazon.com and having up to five
> slashes after that. I feel this will be safe enough, but how do I come up
> with the expression? Here's what I came up with
> 
> regex ^http://g-images.amazon.com(/.*){0,5}
> http://192.168.0.1:2001/blank.gif
> 
> Unfortunately, this blocks both of the above images. I am a bit puzzled
> about the period within the brackets. Is it being interpreted as a literal?


No. That is, in fact, part of your problem.

Since it is not literal, it can match slash characters.

You also need to anchor the end of your pattern.


> any ideas?

   m#^http://g-images.amazon.com(/[^/]*){0,5}$#

but this communicates your description more clearly:

   m#^http://g-images.amazon.com# and tr#/## <= 7


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


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

Date: Sun, 5 Jan 2003 10:21:08 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: regexp question
Message-Id: <slrnb1gmrk.8se.tadmc@magna.augustmail.com>


[ text rearranged to follow the accepted conventions ]


Kasp <kasp@NO_SPAMepatra.com> wrote:
> "C3" <someone@microsoft.com> wrote in message
> news:3e17f873$0$18872$afc38c87@news.optusnet.com.au...

> http://g-images.amazon.com/images/G/01/marketing/cross-shop/arnold/apparel/1
>> 202/ap_sr_on_1226_2.gif is an image I don't want to load
>> * http://g-images.amazon.com/images/G/01/icons/icon_listmania.gif is an
>> image I *do* want to load

>> regex ^http://g-images.amazon.com(/.*){0,5}

>> Unfortunately, this blocks both of the above images.

> I find your regex is not correct. 


That is true...


> You should 'escape' the
> slashes (/).


 ... but not for that reason.

We cannot tell if the slashes need to be escaped or not.

They only need to be escaped if they are used as the delimiters
for the match operator, which the OP did not show us.


> Here is small code that I made for you. It's tested too :-)


The OP's problem was that both strings were matched when he only
wanted one of them to match...


[snip code]

> #open to comments from critics.


 ... your code also matches both.

It does not fix the OP's problem.


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


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

Date: Sun, 5 Jan 2003 22:42:33 +0530
From: "Kasp" <kasp@NO_SPAMepatra.com>
Subject: Re: regexp question
Message-Id: <av9p5i$q4n$1@newsreader.mailgate.org>

There are 6 "/" after amazon..com. This change is reflected now in the
regex.
Try this code:-

use strict;
if(m#^http://g-images.amazon.com(/.*){6,}#)
{
    print "$_ matched\n";
}

--
Perl is designed to give you several ways to do anything, so
consider picking the most readable one.
             -- Larry Wall in the perl man page







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

Date: Sun, 5 Jan 2003 11:11:18 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Should I worry about the optimizer.
Message-Id: <slrnb1gppm.97p.tadmc@magna.augustmail.com>

Teh (tî'pô) <teh@mindless.com> wrote:

> I was hoping someone who knows perl internally could give me a factual
> answer.


There are precious few here with knowledge of the internals.

You'll have a better chance of reaching such folks on:

   comp.lang.perl.moderated


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


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

Date: Sun, 5 Jan 2003 10:15:32 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: top-posting (was Re: regexp question)
Message-Id: <slrnb1gmh4.8se.tadmc@magna.augustmail.com>

Kasp <kasp@NO_SPAMepatra.com> wrote:

> I am new to Perl. 


But you are no longer new to the Perl newsgroup.


> #open to comments from critics.


Please start to follow the quoting conventions preferred in
this newsgroup.

You were quoting correctly on January 3rd, but have once
again reverted to top-posting.

You will get killfiled if you persist in top-posting, please stop.



[ snip TOFU ]

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


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

Date: Sun, 5 Jan 2003 22:30:51 +0530
From: "Kasp" <kasp@NO_SPAMepatra.com>
Subject: Re: top-posting (was Re: regexp question)
Message-Id: <av9os3$pv6$1@newsreader.mailgate.org>

Tad and everyone at comp.lang.perl.misc.,

My news reading client (mailgate.org) often givesme trouble. Sometimes, it
will not allow me to reply to questions through bottom-posting and even top
posting at times. I often have to "reply" through a "new" post.

I don't know if you understand the problem which I am facing with then news
client, but by Top-posting and a fresh post like this one, I have no
intentions of dishonoring anyone. I know that top-posting is against the Net
Etiquette, but please pardon me.

I used to post through news.google.com earlier but there are two
disadvantages of this:
1. It takes 3-9 hours for my message to come up on the site.
2. It displays my email ID for spiders to pick up and send me daily spams.

Regards,
Kasp.
--
Perl is designed to give you several ways to do anything, so
consider picking the most readable one.
             -- Larry Wall in the perl man page




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

Date: 05 Jan 2003 12:41:16 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: top-posting (was Re: regexp question)
Message-Id: <m3hecncx4z.fsf@mumonkan.sunstarsys.com>

"Kasp" <kasp@NO_SPAMepatra.com> writes:
> Tad and everyone at comp.lang.perl.misc.,
> 
> My news reading client (mailgate.org) often givesme
> trouble. Sometimes, it will not allow me to reply to questions through
> bottom-posting and even top posting at times. I often have to "reply"
> through a "new" post. 
> 
> I don't know if you understand the problem which I am facing with then
> news client, but by Top-posting and a fresh post like this one, I have
> no intentions of dishonoring anyone. I know that top-posting is
> against the Net Etiquette, but please pardon me.

FYI: Here's what my newsreader complained about in your followup
to Tad's post:

  Gnus-Warning: Munged return address suspected, found `SPAM' in from
  Gnus-Warning: No DNS for @NO_SPAMepatra.com in return address
  Gnus-Warning: Missing attribution
  Gnus-Warning: Missing context
  Gnus-Warning: Double-dash in signature missing trailing space
  Gnus-Warning: Signature too long: 5 lines
  Gnus-Warning: Flavell Bogosity Index 180 exceeds 100

> I used to post through news.google.com earlier but there are two
> disadvantages of this:
> 1. It takes 3-9 hours for my message to come up on the site.
> 2. It displays my email ID for spiders to pick up and send me daily
> spams. 

Then please find some other alternative; many people that read this 
newsgroup also read other high-volume newsgroups as well.  Experience 
has taught me that I'm usually better-off killfiling new participants 
who want special treatment, than I am to give it.

I don't killfile people to "punish them"- it sounds silly to even 
say that.  I do it to avoid spending any future time on their
posts, because I doubt the experience will be rewarding for me.
If I didn't use an active killfile in groups like clp.misc, I 
simply wouldn't have enough time to read the good posts.  Killfiles
are for time-management, not for censorship.

-- 
Joe Schaefer      "It is amazing how complete is the delusion that beauty is
                                          goodness."
                                               -- Leo Tolstoy



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

Date: Sun, 5 Jan 2003 11:55:38 -0500
From: "John B." <jbarrington@comcast.non>
Subject: What are the software editor/creative choices for Perl
Message-Id: <4pycnYRbNogO_oWjXTWcrg@comcast.com>

I'm a new webmaster for a smaller site that wants to investigate possible
uses for Perl (or CGI ?). I have some background in most computer languages,
but no experience with Perl and it's code within an internet site.

I've ordered a couple of books to study, but I'd like to know about some of
the better software that's available. I'm sure that I'll want to try and
design and test code as I learn, so what are the better/best freeware,
shareware, or commercial software choices that are reasonable on costs, easy
to learn and understand, and to work with.

Thanks for any insight.

--
Change [comcast.non] to [comcast.net]




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

Date: Sun, 05 Jan 2003 17:12:40 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: What are the software editor/creative choices for Perl
Message-Id: <cIZR9.1645$Db.773@nwrddc02.gnilink.net>

John B. wrote:
> I'm a new webmaster for a smaller site that wants to investigate
> possible uses for Perl (or CGI ?). I have some background in most
> computer languages, but no experience with Perl and it's code within
> an internet site.

Please note that Perl != CGI. The two have nothing to do with each other
except that Perl scripts are often used to implement CGI programs. You
should not confuse them and keep the domains well separated. In particular
asking a CGI question in a Perl NG is heavily frowned upon und will get you
on the fast way into many kill files.

Beside that, please have a look at CPAN (www.cpan.org) and the Perl FAQ.
It contains even an entry for editors:
    E:\MSN9M1-main>perldoc -q editor
    Found in E:\msn9m1-main\public\ext\perl\x86\lib\pod\perlfaq3.pod
      Is there an IDE or Windows Perl Editor?
                [Extensive commented list of over 20 editors removed]

Although the FAQ is targeted towards Windows users, most of it applies to
Unix, too.

jue




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

Date: Sun, 5 Jan 2003 22:52:58 +0530
From: "Kasp" <kasp@NO_SPAMepatra.com>
Subject: Re: What are the software editor/creative choices for Perl
Message-Id: <av9pm4$qc5$1@newsreader.mailgate.org>

"John B." <jbarrington@comcast.non> wrote in message
news:4pycnYRbNogO_oWjXTWcrg@comcast.com...
> I'm a new webmaster for a smaller site that wants to investigate possible
> uses for Perl (or CGI ?). I have some background in most computer
languages,
> but no experience with Perl and it's code within an internet site.
>
> I've ordered a couple of books to study, but I'd like to know about some
of
> the better software that's available. I'm sure that I'll want to try and
> design and test code as I learn, so what are the better/best freeware,
> shareware, or commercial software choices that are reasonable on costs,
easy
> to learn and understand, and to work with.
>
> Thanks for any insight.
>
> --
> Change [comcast.non] to [comcast.net]
>

Please note this group is specific to Perl only and CGI questions are Off
Topic.

Perl is free. You can download it from http://cpan.org/ports/index.html

Books to read in increasing order of depth/difficulty:
1. Learning Perl 3rd Edition - O'Reilly
2. Programming Perl 3rd Edition - O'Reilly




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

Date: Sun, 05 Jan 2003 16:39:03 GMT
From: Fred <No_Mail_Address@cox.net>
Subject: While loop 
Message-Id: <3E186038.4313B1C1@cox.net>

Hi there,

In a html file, I want to replace all <br> tags in preformated text
with \n, like
<pre> aaa<br> bbb<br> ccc<br ddd<br> eee</pre>
to
<pre> aaa
 bbb
 ccc
 ddd
 eee</pre>

I use the following code, but the second while loops forever until I
stop with Ctrl+Brk:

local $/ ;
while (<IN>){
   while (m/<pre>.+<br>.+<\/pre>/is) {
      s/(<pre>.+?)<br>(.+?<\/pre>)/$1\n$2/sg;
   }
print $_ ;
}

---
Fred


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

Date: Sun, 5 Jan 2003 16:55:55 +0000 (UTC)
From: Moshe Jacobson <bramoshe@runslinux.net>
Subject: Re: While loop
Message-Id: <av9o2q$ao$1@news-int.gatech.edu>

Fred had nothing better to do than to say:
> I use the following code, but the second while loops forever until I
> stop with Ctrl+Brk:

> local $/ ;
> while (<IN>){
>    while (m/<pre>.+<br>.+<\/pre>/is) {
>       s/(<pre>.+?)<br>(.+?<\/pre>)/$1\n$2/sg;
>    }
> print $_ ;
> }

you should just have an if instead of a while in the inner loop and
it'll be fine. The while is a loop. Why are you looping over the same
line? You're already looping over each line with the outer loop.

Moshe

-- 
*** SPAM BLOCK: Remove bra before replying! ***
Moshe Jacobson :: http://runslinux.net :: moshe at runslinux dot net
!! FBI Arreseting Programmers?  http://www.freesklyarov.org
!! Trust Microsoft Anti-Trust:  http://www.anti-dmca.org


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

Date: Sun, 05 Jan 2003 17:20:14 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: While loop
Message-Id: <iPZR9.6961$LY3.5635@nwrddc04.gnilink.net>

Moshe Jacobson wrote:
> Fred had nothing better to do than to say:
>> I use the following code, but the second while loops forever until I
>> stop with Ctrl+Brk:
>
>> local $/ ;
>> while (<IN>){
>>    while (m/<pre>.+<br>.+<\/pre>/is) {
>>       s/(<pre>.+?)<br>(.+?<\/pre>)/$1\n$2/sg;
>>    }
>> print $_ ;
>> }
>
> you should just have an if instead of a while in the inner loop and
> it'll be fine. The while is a loop. Why are you looping over the same
> line? You're already looping over each line with the outer loop.

While this is true and your advice should solve the OP's problem, I still
wonder why the inner loop doesn't terminate.
After executing the substitute there should not be any and <br> left.......

 .... wait a second. While writing the above it became quite clear to me.
There won't be any "<br"> left but what about "<BR>"? The inner loop
condition will match a capital "<BR>" but the substitute command will not
replace it. Thereby the condition will never become false.

jue




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

Date: Sun, 05 Jan 2003 17:51:41 GMT
From: Fred <No_Mail_Address@cox.net>
Subject: Re: While loop
Message-Id: <3E18713E.EB7B59CA@cox.net>

"Jürgen Exner" wrote:
> 
> Moshe Jacobson wrote:
> > Fred had nothing better to do than to say:
> >> I use the following code, but the second while loops forever until I
> >> stop with Ctrl+Brk:
> >
> >> local $/ ;
> >> while (<IN>){
> >>    while (m/<pre>.+<br>.+<\/pre>/is) {
> >>       s/(<pre>.+?)<br>(.+?<\/pre>)/$1\n$2/sg;
> >>    }
> >> print $_ ;
> >> }
> >
> > you should just have an if instead of a while in the inner loop and
> > it'll be fine. The while is a loop. Why are you looping over the same
> > line? You're already looping over each line with the outer loop.
> 
> While this is true and your advice should solve the OP's problem, I still
> wonder why the inner loop doesn't terminate.
> After executing the substitute there should not be any and <br> left.......
> 
> .... wait a second. While writing the above it became quite clear to me.
> There won't be any "<br"> left but what about "<BR>"? The inner loop
> condition will match a capital "<BR>" but the substitute command will not
> replace it. Thereby the condition will never become false.
> 
> jue

1.) I checked the html file and there are only <br> and no <BR>.
2.) If I replace the inner while by if then there is only one single
replacement in every <pre> ...</pre> string. Not what I want.
--
Fred


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 4345
***************************************


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