[10160] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3753 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Sep 18 17:07:23 1998

Date: Fri, 18 Sep 98 14:00:21 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 18 Sep 1998     Volume: 8 Number: 3753

Today's topics:
    Re: /etc/passwd file (Abigail)
    Re: /etc/passwd file <webmaster@fccjmail.fccj.cc.fl.us>
    Re: /etc/passwd file <strat@pacifier.com>
    Re: /etc/passwd file <eashton@bbnplanet.com>
    Re: any way to encrypt my script? <uri@camel.fastserv.com>
    Re: any way to encrypt my script? (Abigail)
    Re: COBOL and Perl <uri@camel.fastserv.com>
        Converting from Unix script to an NT script <sdelong@systec.com>
        Error 405: Method Not Allowed <sloanw@desupernet.net>
    Re: Error 405: Method Not Allowed (Steve Linberg)
        Getting a line from a text file into an array (Matt Goddard)
    Re: Getting a line from a text file into an array ()
    Re: Getting a line from a text file into an array (Craig Berry)
        how can I get perl to tell the difference between files <843943n34@knight_storm@usa.net.sprynet.com>
    Re: I need a script writen, can someone help me please (Gareth Hall)
    Re: milliseconds? (Andrew M. Langmead)
    Re: my CGI to edit htpasswd's <NOSPAMd.b@mindless.com>
    Re: passing argument !!!! (Dave Cross)
    Re: passing argument !!!! (Matt Knecht)
    Re: Perl & Java - differences and uses (Barry A. Warsaw)
    Re: Perl & Java - differences and uses (Larry Wall)
    Re: Perl & Java - differences and uses (Blake Winton)
    Re: Perl & Java - differences and uses <dalke@bioreason.com>
    Re: Perl & Java - differences and uses <zenin@bawdycaste.org>
    Re: Perl & Java - differences and uses <zenin@bawdycaste.org>
    Re: Perl & Java - differences and uses <akuchlin@cnri.reston.va.us>
        Perl 5 & Linux <lee@mula.demon.co.uk>
    Re: Perl 5 & Linux (Steve Linberg)
        Perl-HTML-Javascript <bcgrafx@sprynet.com>
        Question about regex across multiple lines (Michael D Lewis)
    Re: User inputted regexp. (Patrick Timmins)
        Why does sendmail lose recipients? <admin@asarian-host.org>
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: 18 Sep 1998 19:19:59 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: /etc/passwd file
Message-Id: <6tubov$ip5$2@client3.news.psi.net>

Martin (minich@globalnet.co.uk) wrote on MDCCCXLIV September MCMXCIII in
<URL: news:6tu57j$2ek$1@heliodor.xara.net>:
++ Hi, could anyone please help me! I'm writing a script to add a new user
++ to a Unix system and need to append the /etc/passwd file. I see that the
++ data in here are arranged as fields separated by :s. Could someone
++ who's feeling a bit generous and knows it please tell me what each of
++ the fields are or point me in the direction of where to find it out.

If you don't know what the format of /etc/passwd is, or how to find
out that information, and don't know alternative ways to add users,
you shouldn't be allowed to write scripts like that.

It's like going into an airport and saying "Could anyone help me?
I have to fly that 747 to Chicago, and now I need someone to tell
me what all those lights mean. And if someone is really generous,
could you point me in the direction of the cockpit?"

++ PS> Is there a way to remove users from Red Hat Linux?

fdisk /dev/hda



Abigail
-- 
perl  -e '$_ = q *4a75737420616e6f74686572205065726c204861636b65720a*;
          for ($*=******;$**=******;$**=******) {$**=*******s*..*qq}
          print chr 0x$& and q
          qq}*excess********}'


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

Date: Fri, 18 Sep 1998 15:58:02 -0400
From: "Bill Jones, FCCJ Webmaster" <webmaster@fccjmail.fccj.cc.fl.us>
Subject: Re: /etc/passwd file
Message-Id: <3602BB4A.88A93F8E@fccjmail.fccj.cc.fl.us>

Martin wrote:
> 
> Hi, could anyone please help me! I'm writing a script to add a new user
> to a Unix system and need to append the /etc/passwd file. I see that the
> data in here are arranged as fields separated by :s. Could someone
> who's feeling a bit generous and knows it please tell me what each of
> the fields are or point me in the direction of where to find it out.
> 
> Also, the password is encrypted. Does anyone know how I could encrypt
> a password in $foo to allow it to be outputted to the passwd file?
> 
> Martin
> 
> PS> Is there a way to remove users from Red Hat Linux?


Not disregarding the replies of others, you should research this
subject via www.dejanews.com and you will see places to begin.

PS - The above was all the generousity I could muster...


Been there, 
done that; 
get over it :]
-Sneex- 
__________________________________________________________________
Bill Jones FCCJ Webmaster | http://www.fccj.org/cgi/mail?webmaster
__________________________________________________________________
We are the CLPM... Lower your standards and surrender your code...
We will add your biological and technological distinctiveness to 
our own... Your thoughts will adapt to service us...
 ...Resistance is futile...


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

Date: Fri, 18 Sep 1998 13:25:45 -0700
From: "Christian Brink" <strat@pacifier.com>
Subject: Re: /etc/passwd file
Message-Id: <3602c1ee.0@news.pacifier.com>


>PS> Is there a way to remove users from Red Hat Linux?

Yes kind of... but DO NOT DO IT... IT IS VERY VERY BAD....

What you want to do is put a "*"  in front of the password field (the 2nd)
this
will disable the account.  - Technique from ORA's Essential System
Administration (GET IT!!)

Do not remove a users password line..... to many thing rely on the UID.
1. the UID might be reassigned and give permissions to the wrong people.
2. if a poorly written program for example relies heavily on the user name
    and calls for the user name (i.e. getpwnam(455)) off the UID you get a
    UID back (at least on most systems) not a name.
3. (just and annoyance but) it will display the UID instead of the name.


on your first question

login_name:ENCRYPTEDPW:UserID:GroupID:GCOS (usually their full
name):/home/dir:/bin/shell_they_use

get your hands on
O'Reilly's Essential System Administration ISBN 1-56592-127-5
and O'Reilly's Running Linux ISBN 1-56592-151-8
It will be money well spent


P.S. you would be better off posting to
comp.os.linux.setup
comp.os.linux.misc
comp.unix.admin


HTH

C. Christian Brink,CNE
IS-Manager
All-Sports Supply, LLC
Clackamas,OR

strat@pacifier.com
chrisb@assi.com




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

Date: Fri, 18 Sep 1998 20:56:55 GMT
From: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Re: /etc/passwd file
Message-Id: <3602C6B1.452A6AA0@bbnplanet.com>

Christian Brink wrote:

> >PS> Is there a way to remove users from Red Hat Linux?

> Yes kind of... but DO NOT DO IT... IT IS VERY VERY BAD....

Having been an admin on systems with 12k+ users that changed frequently,
I would wonder a bit at that since I cannot think of any user account
that would be so critical as to merely disable it. Poorly written
programs get rewritten properly really fast when they rely on a
non-permanent account. If you can't remove an account smoothly than I
would think that you are doing it wrong. Just my own humble experience.

e.

"All of us, all of us, all of us trying to save our immortal souls, some
ways seemingly more round-about and mysterious than others. We're having
a good time here. But hope all will be revealed soon."  R. Carver


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

Date: 18 Sep 1998 15:16:43 -0400
From: Uri Guttman <uri@camel.fastserv.com>
To: bitnut1@my-dejanews.com
Subject: Re: any way to encrypt my script?
Message-Id: <sarzpbxfcys.fsf@camel.fastserv.com>

>>>>> "b" == bitnut1  <bitnut1@my-dejanews.com> writes:

  >> ------------------------------------------
  >> Question:
  >> if I don't want to show my source code
  >> to the world, what should I do with my script?
  >> ------------------------------------------
  >> Replies:
  >> - format c:
this works for me!

  >> - Delete it.
not as good.

  >> - Do you really want to start a religious argument here?
die infidel!

  >> - Don't use it where it can be seen.
see monty python (not the language): how not to be seen!

  b> Amazing!
  b> A question like this would be answered in most places in a
  b> straightforward manner with helpful pointers and references.

the lord alps those who alps themselves.

  b> The need to compile a program is self-evident to anyone who has
  b> written a program longer than one page. Every serious language
  b> has that option and major efforts go into improving compilers.

now who says that. all perl programs ARE compiled. maybe you don't know
that already. it's all in one step. and perl is serious, perl hackers
may be not serious sometimes.

  b> Now, which is it:
  b> -- Perl is an immature language and unusable for serious work, or

perl is both a floor wax AND a dessert topping!
(stolen from a recent post who stole it from an old SNL commercial)

  b> -- Perl users are immature and unable to answer a simple question.

no, it is you who are immature and don't get it.

perl hackers don't like to hide code. in fact we like to show it off in
CPAN.

hth,

uri


-- 
Uri Guttman                             Speed up your web server with Fast CGI!
uri@fastengines.com                                  http://www.fastengines.com


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

Date: 18 Sep 1998 19:53:04 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: any way to encrypt my script?
Message-Id: <6tudn0$ip5$5@client3.news.psi.net>

bitnut1@my-dejanews.com (bitnut1@my-dejanews.com) wrote on MDCCCXLIV
September MCMXCIII in <URL: news:6tu94v$9sh$1@nnrp1.dejanews.com>:
++ 
++ 
++ The need to compile a program is self-evident to anyone who has
++ written a program longer than one page. Every serious language
++ has that option and major efforts go into improving compilers.

What makes you think that Perl code isn't compiled before executed?



Abigail
-- 
perl -e '$a = q 94a75737420616e6f74686572205065726c204861636b65720a9 and
         ${qq$\x5F$} = q 97265646f9 and s g..g;
         qq e\x63\x68\x72\x20\x30\x78$&eggee;
         {eval if $a =~ s e..eqq qprint chr 0x$& and \x71\x20\x71\x71qeexcess}'


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

Date: 18 Sep 1998 15:20:25 -0400
From: Uri Guttman <uri@camel.fastserv.com>
Subject: Re: COBOL and Perl
Message-Id: <sarww71fcsl.fsf@camel.fastserv.com>

>>>>> "WTU" == Walter Tice USG <tice@hunch.zk3.dec.com> writes:

  WTU> -- 
  WTU> "One World. One Web. One Program."
  WTU>       -Microsoft promotional advertisement
  WTU> "Ein Volk, ein Reich, ein Fuhrer!"
  WTU>       -Adolf Hitler

that .sig says a lot! send it to the fed lawsuit!

uri

-- 
Uri Guttman                             Speed up your web server with Fast CGI!
uri@fastengines.com                                  http://www.fastengines.com


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

Date: Fri, 18 Sep 1998 15:53:10 -0400
From: "S. DeLong" <sdelong@systec.com>
Subject: Converting from Unix script to an NT script
Message-Id: <3602BA25.BD5DFDE0@systec.com>

I have been given the task of converting a script that runs on a unix
box to run on a NT box.  This particular script is reading a data from a
delimited text file.  Unfortunately, I am not a PERL scripter.  One
statement in the setup.pl file is asking for the record delimiter of the
text file.  I know it is a <CR><LF> but I don't know how to show this
representation in the script -

Are there any other major considerations when converting from a script
intended for unix?

Any help would be appreciated.

Thanks - Sandy

Here is the statement:
$r_sep="\r\n";





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

Date: Fri, 18 Sep 1998 14:55:25 -0400
From: "sw" <sloanw@desupernet.net>
Subject: Error 405: Method Not Allowed
Message-Id: <3602ad80.0@news.redrose.net>

i am trying to put a form request on my company's website.
can anyone please help me with the error message below:

405 Method Not Allowed

The method specified in the Request Line is not allowed for the resource
identified by the request. Please ensure that you have the proper MIME type
set up for the resource you are requesting.

when method="post" i get the above error message.
when method="get" the browser actually tries to download the *.pl file
itself instead of running.

i purchased a cgi/perl cookbook and changed all the required feilds (i
think) for the script.
yet no matter what i try i keep getting the same error message.

is this an error in MY code, either *.htm or *.pl, or something that must be
fixed by the server administrator (winNT web server)?

thank you for your time.

-sloan







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

Date: Fri, 18 Sep 1998 15:46:59 -0500
From: linberg@literacy.upenn.edu (Steve Linberg)
Subject: Re: Error 405: Method Not Allowed
Message-Id: <linberg-1809981546590001@ltl1.literacy.upenn.edu>

In article <3602ad80.0@news.redrose.net>, "sw" <sloanw@desupernet.net> wrote:

> i am trying to put a form request on my company's website.
> can anyone please help me with the error message below:
> 
> 405 Method Not Allowed

> is this an error in MY code, either *.htm or *.pl, or something that must be
> fixed by the server administrator (winNT web server)?

It's a server error message, so it's a server problem, and you should
bring it to the attention of your server administrator.
_____________________________________________________________________
Steve Linberg                       National Center on Adult Literacy
Systems Programmer &c.                     University of Pennsylvania
linberg@literacy.upenn.edu              http://www.literacyonline.org


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

Date: Fri, 18 Sep 1998 19:52:00 GMT
From: mgoddard@REMOVETHISrosetta.org (Matt Goddard)
Subject: Getting a line from a text file into an array
Message-Id: <3602b753.341232346@thor>

Let's say I have a text file, each line containing information, and I
want to put each line of that file into an array(with each element of
the array being a line from the file, seperated by "\n"). I'm
searching through faqs, books, and so far haven't seen the way. I know
it's gotta be fairly easy; can anyone help?
Thanks
-Matt



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

Date: Fri, 18 Sep 1998 20:29:34 GMT
From: mike@www.bcinternet.com ()
Subject: Re: Getting a line from a text file into an array
Message-Id: <slrn705isj.oi3.mike@www.bcinternet.com>

In article <3602b753.341232346@thor>, Matt Goddard wrote:
>Let's say I have a text file, each line containing information, and I
>want to put each line of that file into an array(with each element of
>the array being a line from the file, seperated by "\n"). I'm
>searching through faqs, books, and so far haven't seen the way. I know
>it's gotta be fairly easy; can anyone help?
	Your right, a 30 search through my copy of 'Learning Perl' told me
:>  Anyways there's an example, hope it helps.

#!/usr/bin/perl
open(IN,'<path to file>');
@array = <IN>;
close(IN);
foreach $foo (@array)
{
  print $foo;
}


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

Date: 18 Sep 1998 20:29:53 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Getting a line from a text file into an array
Message-Id: <6tufs1$972$1@marina.cinenet.net>

Matt Goddard (mgoddard@REMOVETHISrosetta.org) wrote:
: Let's say I have a text file, each line containing information, and I
: want to put each line of that file into an array(with each element of
: the array being a line from the file, seperated by "\n"). I'm
: searching through faqs, books, and so far haven't seen the way. I know
: it's gotta be fairly easy; can anyone help?

I'm sorry, but you can't have looked very hard and missed this.  Get the
Llama and *read* it, cover to cover -- you won't be sorry you did.  In the
mean time:

  @lines = <FILE>;

That is, the <> operator in a list context does precisely what you want.

---------------------------------------------------------------------
   |   Craig Berry - cberry@cinenet.net
 --*--    Home Page: http://www.cinenet.net/users/cberry/home.html
   |      "Ripple in still water, when there is no pebble tossed,
       nor wind to blow..."


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

Date: Fri, 18 Sep 1998 12:38:26 -0700
From: "Knight" <843943n34@knight_storm@usa.net.sprynet.com>
Subject: how can I get perl to tell the difference between files and directories?
Message-Id: <6tucuj$7rn$1@juliana.sprynet.com>

How can I get perl to tell the difference between files and directories? I
have it on Windows 95. Any help here is greatly appreciated. Thank you.

-Knight




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

Date: Fri, 18 Sep 1998 20:57:07 GMT
From: guruchoc@bigpond.com (Gareth Hall)
Subject: Re: I need a script writen, can someone help me please
Message-Id: <3602c8f0.1617935@news.bigpond.com>


>I take it this is another joke, not as good as Patrick Timmins' earlier
>post, but funny.
>
>What? Its not a joke??
>
>Could the author read the "QUESTIONS (was: Perl Programmer Needed)"
>thread started by Patrick Timmins on 09/09/98 and see how this question
>_should_ be worded.
>
>Most programmers here will _help_ you write scripts, but don't expect
>them to do all the work for you.
>
>

Not a joke, just a simple question. Obviously this newsgroup takes
itself far to seriously.


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

Date: Fri, 18 Sep 1998 20:26:37 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: milliseconds?
Message-Id: <EzHy4D.Ku@world.std.com>

miho21@yahoo.com writes:


>there is no need to explain to me about
>programming, since i know some languages like c++ and java. what I do not
>know, is perl programming.

Sorry, my mistake. Since the inability to consult standard reference
documentation is frequently the sign of a programming novice, that is
who I thought I was speaking to. I forgot that it is also the sign of
the incompetent.

>there is no need to explain to me about research either, but you know what?
>usenet is a big part of my research turf. I find it very helpful to be able
>to toss questions and get answers when FAQs dont quite cut it, and they dont
>always... 

People are here because they they like thinking about interesting
questions dealing with Perl. And there are an infintate number of
interesting questions people could ask. On the other hand, the
standard perl quoting operators are in themselves not very
interesting.

I'm not even talking about the FAQ here. It has some interesting
explainations. And its not like the documentation "dont quite cut it"
because it didn't seem like you even checked it. (I just checked
perlop again, and I can see how it would throw a novice.) Trying to
figure out another way of explaining the reference documentation or
the FAQ can be quite interesting. Trying to explain a concept to
someone who can't think of any way of getting their answer _other_
than Usenet is not.

-- 
Andrew Langmead


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

Date: Fri, 18 Sep 1998 19:40:11 GMT
From: THX <NOSPAMd.b@mindless.com>
Subject: Re: my CGI to edit htpasswd's
Message-Id: <3602B716.4BFF586F@mindless.com>

don't know if this is what u were looking for, but check it out
http://solutionscripts.com
called access denied

db


 ... wrote:

>         Yesterday I spent about an hour looking for a CGI that would allow
> one of my customers to edit their htpasswd over the web.  Everytime I found a
> script it was commercial, so I figured it as about time I learned enough
> perl to make a CGI :>  Anyways if anybody needs a laugh, or this script it
> can be downloaded from http://www.bcinternet.com/~mike/htadmin.perl
>
>                         mike...



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

Date: Fri, 18 Sep 1998 19:10:49 GMT
From: dave@mag-sol.com (Dave Cross)
Subject: Re: passing argument !!!!
Message-Id: <3602af55.2244062@news.demon.co.uk>

[email copy of Usenet post sent to cited author]

On Fri, 18 Sep 1998 10:02:50 -0700, lr@hpl.hp.com (Larry Rosler)
wrote:

>[Posted to comp.lang.perl.misc and a copy mailed.]

>People really should test their assertions, instead of just posting: "I 
>think you'll need...".

Larry, why is it always you who catches my 'posting without thinking'
posts?

I must stop posting just as I'm leaving the office on a Friday
evening!

Thanks for pointing it out.

Dave...

dave@mag-sol.com
Sybase Contractors Resource Page: www.mag-sol.com/Sybase/
Agency Rating System: www.mag-sol.com/ARS/
London Perl M[ou]ngers: www.mag-sol.com/London.pm


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

Date: Fri, 18 Sep 1998 19:39:42 GMT
From: hex@voicenet.com (Matt Knecht)
Subject: Re: passing argument !!!!
Message-Id: <2GyM1.304$XP2.2286784@news3.voicenet.com>

Dave Cross <dave@mag-sol.com> wrote:
>[email copy of Usenet post sent to cited author]
>
>On Fri, 18 Sep 1998 10:02:50 -0700, lr@hpl.hp.com (Larry Rosler)
>wrote:
>
>>[Posted to comp.lang.perl.misc and a copy mailed.]
>
>>People really should test their assertions, instead of just posting: "I 
>>think you'll need...".
>
>Larry, why is it always you who catches my 'posting without thinking'
>posts?

You're not the only one he catches.

-- 
Matt Knecht - <hex@voicenet.com>


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

Date: 18 Sep 1998 15:33:49 -0400
From: bwarsaw@cnri.reston.va.us (Barry A. Warsaw)
Subject: Re: Perl & Java - differences and uses
Message-Id: <61lnnhrzaa.fsf@anthem.cnri.reston.va.us>


>>>>> "Z" == Zenin  <zenin@bawdycaste.org> writes:

    Z> 	A language can be hard to work with for many reasons.  Lack of
    Z> support from the common editors can most defiantly be one of
    Z> them.

    Z> 	Imagine coding <insert nearly any language> without
    Z> auto-indent for instance.

Very interesting point, which brings me to one of the two reasons why
I stopped using Perl (and Tcl) on a regular basis.  First, when the
early Lucid Emacs editor came out that supported font-locking, I found
that Perl4's package operator ' royally screwed the syntax coloring.
(interesting sidenote: I violently scoffed at the whole notion of
syntax color when I first saw it, but quickly couldn't live without it
:-) And forget HERE docs!  Such a minor point perhaps, but it bugged
me silly.

My second reason for the switch was that I needed a language that was
both easy to embed and useful as a general standalone scripting
language.  Tcl served the former purpose nicely; Perl was better at
the latter but too painful at the former.

Python solved all these problems for me at a time when nothing else
did in quite so elegant a way.  You can argue that all the tools
mentioned have improved in the last 5 - 7 years, but I've had no
reason to go back.

Which basically means, use the tools that help you do what you want,
in the most straightforward way.

-Barry


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

Date: 18 Sep 1998 12:39:38 -0700
From: larry@kiev.wall.org (Larry Wall)
Subject: Re: Perl & Java - differences and uses
Message-Id: <6tuctq$d8l@kiev.wall.org>

In article <360026F0.136F6AD@min.net>, John Porter  <jdporter@min.net> wrote:
>George Reese wrote:
>> Perl is quite simply no where as OO as python.
>
>True; but you think that means Perl is no where near as *good* as a
>consequence.  But that does not follow, because OO is not the be-all,
>end-all you seem to think it is.

Indeed.  This has been a rather entertaining discussion--it keeps
reminding me of a saying I particularly like:

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

Larry


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

Date: Fri, 18 Sep 1998 18:54:22 GMT
From: bwinton@calum.csclub.uwaterloo.ca (Blake Winton)
Subject: Re: Perl & Java - differences and uses
Message-Id: <EzHtuM.484@undergrad.math.uwaterloo.ca>

In article <360266C3.4657B9F6@sage.att.com>,
Garrett G. Hodgson <garry@sage.att.com> wrote:
>Zenin wrote:
>> Terry Reedy <tjreedy@udel.edu> wrote:
>> : Actually, Python allows optional use of '#{' and '#}' as block delimiters
>>         Does this actually have any effect on Python's blocking, or is it
>>         just the editor kluge it looks like?
>kluge.

But not an editor kludge, as much as a broken-user kludge.  ;)

>>         Funny, #{ and #} look a lot like line noise to me. ;-P

That must be why they're optional...

Later,
Blake.


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

Date: Fri, 18 Sep 1998 14:35:03 -0700
From: Andrew Dalke <dalke@bioreason.com>
Subject: Re: Perl & Java - differences and uses
Message-Id: <3602D207.F4946CB6@bioreason.com>

Zenin <zenin@bawdycaste.org> said:
>       ?P<> is a slick feature, I'll admit, but I do wonder when it would
>       be of use?  I do some pretty funky re myself, and have only found
>       and extremely limited number of cases that I had to drop down to
>       index() and pos().
>
>       Could someone please show a real world example of this feature
>       in use?

Technically, that wasn't the point.  You said:
Zenin <zenin@bawdycaste.org> asked:
>  Please show *any* Python or Java code that when translated to Perl
>  would be done uncleanly by default.  *Any* code.

So I gave you one, and I'm assuming your added requirement for
a "real world" example implicitly says that this is indeed a
case where Python code is "cleaner" than Perl.

Not that that says *anything* about the language.  After all,
the trivial one that's hard in Perl is "write a function that
evaluates Python code".

But if you want real world examples where you need the position
of the matches -- anything that needs to highlight the matching
groups.  First thing I can think of is a tutorial on regular
expressions where you want to show which parts of the string were
matched and the number of the group associated with it (assuming
there are at most 9 groups):

Enter the string: This is a test
Enter the pattern: (is).*(s)
Here's what matched:
  This is a test
    11        2

import re
print "Enter the string:",
instr = raw_input()
print "Enter the pattern:",
matches = re.search(raw_input(), instr)
print "Here's what matched:"
print "  " + instr
last = 0
s = "  "
for i in range(1,len(matches.groups())+1):  # Hmm, cumbersome....
    s = s + " " * (matches.start(i) - last)
    last = matches.end(i)
    s = s + str(i) * (last - matches.start(i))
print s

But still, I think I've made my point clear -- there are things
that are better expressed in Python.  And even with that, it doesn't
prove anything about the language.

Given the (IMHO useless) whitespace flame thread, I think I'm finished
with this discussion.

						Andrew


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

Date: 18 Sep 1998 20:15:15 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: Perl & Java - differences and uses
Message-Id: <906149664.984804@thrush.omix.com>

Larry Wall <larry@kiev.wall.org> wrote:
:     "It is amazing how complete is the delusion that beauty is goodness."
:                                                         -- Leo Tolstoy
: Larry

	Larry, I'd *kill* for a copy of your quotes file. :-)

-- 
-Zenin (zenin@archive.rhps.org)           From The Blue Camel we learn:
BSD:  A psychoactive drug, popular in the 80s, probably developed at UC
Berkeley or thereabouts.  Similar in many ways to the prescription-only
medication called "System V", but infinitely more useful. (Or, at least,
more fun.)  The full chemical name is "Berkeley Standard Distribution".


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

Date: 18 Sep 98 20:35:20 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: Perl & Java - differences and uses
Message-Id: <906151160.601494@thrush.omix.com>

Andrew Dalke <dalke@bioreason.com> wrote:
: Technically, that wasn't the point.  You said:
: Zenin <zenin@bawdycaste.org> asked:
: >  Please show *any* Python or Java code that when translated to Perl
: >  would be done uncleanly by default.  *Any* code.
:
: So I gave you one, and I'm assuming your added requirement for
: a "real world" example implicitly says that this is indeed a
: case where Python code is "cleaner" than Perl.

	Clean has nothing to do with it.  I never said a Perl version
	of your code would be unclean, only that the algorithm would
	be a little larger.  Changing the algorithm alone would do
	nothing to the readability or "cleanliness" of the code.

: Not that that says *anything* about the language.

	Or it's "cleanliness".

: After all, the trivial one that's hard in Perl is "write a function
: that evaluates Python code".

	sub eval_python {
	    my $python_code = shift;
	    return `echo "$python_code" | python`;
	}

	:-)

	Of course, this can be turned around to, "write a function
	in Python that evaluates any Perl code", with a similar
	solution.

: But if you want real world examples where you need the position
: of the matches -- anything that needs to highlight the matching
: groups.

	Good point.

	>snip<
: But still, I think I've made my point clear -- there are things
: that are better expressed in Python.  And even with that, it doesn't
: prove anything about the language.

	Agreed, so long as s/Python/<insert preferred language>/

	Every language has its pros and cons, or else we'd have nothing
	to debate about.
-- 
-Zenin (zenin@archive.rhps.org)           From The Blue Camel we learn:
BSD:  A psychoactive drug, popular in the 80s, probably developed at UC
Berkeley or thereabouts.  Similar in many ways to the prescription-only
medication called "System V", but infinitely more useful. (Or, at least,
more fun.)  The full chemical name is "Berkeley Standard Distribution".


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

Date: Fri, 18 Sep 1998 20:44:41 GMT
From: "Andrew M. Kuchling" <akuchlin@cnri.reston.va.us>
Subject: Re: Perl & Java - differences and uses
Message-Id: <13826.50312.368649.883713@amarok.cnri.reston.va.us>

Andrew Dalke writes:
>But if you want real world examples where you need the position
>of the matches -- anything that needs to highlight the matching
>groups.  First thing I can think of is a tutorial on regular
>expressions where you want to show which parts of the string were
>matched and the number of the group associated with it (assuming
>there are at most 9 groups):

	In fact, there's just such a demo program included in the
distribution: Demo/tkinter/guido/redemo.py.  (regexdemo.py uses the
old regex module.)  redemo.py is pretty useful for experimenting with
a regular expression that isn't working.  The only flaw is that the
text input box for the regular expression is only a single line, which
makes it impossible to enter a large regex that uses re.VERBOSE; it
should really be expandable to a multiline field.  (Hey, there's a
weekend project.)

-- 
A.M. Kuchling			http://starship.skyport.net/crew/amk/
We pass through this world but once. Few tragedies can be more extensive than
the stunting of life, few injustices deeper than the denial of an opportunity
to strive or even to hope, by a limit imposed from without, but falsely
identified as lying within.
    -- Stephen Jay Gould, _The Mismeasure of Man_



	


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

Date: Fri, 18 Sep 1998 20:21:43 +0100
From: "Lee" <lee@mula.demon.co.uk>
Subject: Perl 5 & Linux
Message-Id: <906146586.22869.0.nnrp-02.d4e4b2e6@news.demon.co.uk>

I'm not sure if I should be asking this question in a linux newhgroup but
here goes :

I'm running Linux redhat 5.1 and I've started to dabble in perl 5.0

I've done a small prog as follows :

#!/usr/bin/perl
$inputline = <STDIN>;
print( $inputline );

saved as file : prog

I set it to be executable using : chmon +x  prog

But when I type prog to run it I get a linux error saying file not found

Any ideas ?




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

Date: Fri, 18 Sep 1998 15:46:12 -0500
From: linberg@literacy.upenn.edu (Steve Linberg)
Subject: Re: Perl 5 & Linux
Message-Id: <linberg-1809981546120001@ltl1.literacy.upenn.edu>

In article <906146586.22869.0.nnrp-02.d4e4b2e6@news.demon.co.uk>, "Lee"
<lee@mula.demon.co.uk> wrote:

> I'm not sure if I should be asking this question in a linux newhgroup but
> here goes :
> 
> I'm running Linux redhat 5.1 and I've started to dabble in perl 5.0
> 
> I've done a small prog as follows :
> 
> #!/usr/bin/perl
> $inputline = <STDIN>;
> print( $inputline );
> 
> saved as file : prog
> 
> I set it to be executable using : chmon +x  prog
> 
> But when I type prog to run it I get a linux error saying file not found
> 
> Any ideas ?

This is a linux question.  It *does* belong in a linux newsgroup.  Please
post linux questions where they belong from now on. :)

However, in the spirit of improving the net karma of the universe, the
answer to your question is that your path is not set to include the
directory your script resides in.  Force it by referring to it as ./prog
(when you are in that directory).  Make sure your execute permissions are
set correctly.

Cheers!
_____________________________________________________________________
Steve Linberg                       National Center on Adult Literacy
Systems Programmer &c.                     University of Pennsylvania
linberg@literacy.upenn.edu              http://www.literacyonline.org


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

Date: Fri, 18 Sep 1998 15:12:13 -0400
From: bc <bcgrafx@sprynet.com>
Subject: Perl-HTML-Javascript
Message-Id: <3602B08D.47DDA1F4@sprynet.com>

I have created a form that writes info to a database with Perl CGI. The
perl displays to the user an HTML form that consists mostly of
pushbuttons that fill in the blanks. The buttons all respond to
Javascript code that retrieves this information. Majority of the
information is static. My problem lies in the dynamic data. In just
straight html I can make the javascript external and have one button
that goes and gets data and rewrites my javascript file. Then I would
push a second button that would act upon the new Javascript external to
fill in the dyanmic data.
This doesn't work from within my CGI Perl though. The call to the
external .JS file breaks me out of the CGI.
Anybody have any ideas.




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

Date: 18 Sep 1998 20:11:39 GMT
From: mlewis@nmia.com (Michael D Lewis)
Subject: Question about regex across multiple lines
Message-Id: <6tuepr$nvn@hume.nmia.com>

   I'm trying to change an ASCII file using a RE in a perl script.  Since 
it has not been successful, I've tried to reduce the file format down to
the parts that are giving me a problem.  If I can find a solution for this
test format, I should be able to convert it back up into the real format.  

   Here's an example of the input file:
   
<3> 1 fred
barney
<5> 2 wilma
betty

   And here's what it should look like on the output:
   
<3> 4 fred
barney
<5> 10 wilma
betty


Notes:
        1) The number following the bracketed number should become the
           value of the bracketed number plus 1 added to a running total
           ( which starts at 0 ).  So 0+3+1=4 and 4+5+1=10

        2) Many lines of text can exist between "barney" and "<5>". 
        
So my program would do a "m/<(\d)>/" . If it was successful, it would do
the math on the number it would find, and do a 
"s/<(\d)>/\s+\d+\s+/<$1> $newvalue /".
This worked until I found out that the input file could also look like:

<3>
 1 fred
barney
<5> 2 wilma
betty

   To span multiple lines I added the line $/ = ".\n"; to the program.
Now I can't seem to connect the values I find with the values I need to replace.
It seems like the /g option on the m/ operator will walk through the
string one find at a time, where the /g option on the s/ operator will
not.

  Can this conversion be done using REs?  Or do I have to brute force my
way thru the file?

Thanks,
Michael Lewis
mlewis@nmia.com



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

Date: Fri, 18 Sep 1998 19:16:29 GMT
From: ptimmins@netserv.unmc.edu (Patrick Timmins)
Subject: Re: User inputted regexp.
Message-Id: <6tubid$d5i$1@nnrp1.dejanews.com>

In article <36026D73.4F19B19E@nortel.com>,
  Michael Bowler <mkbowler@nortel.com> wrote:
> How can I verify a regular expression given by the user for validity?
>
> Code snippet.
> $exp = <STDIN>;
> chop $exp;
> if ($data =~ /$exp/) {
>    #Do something.
> }
>
> This works great until the user types something beginning with
> a single asterisk or something else invalid.  Is there a way for
> me to validate $exp ... [snip] ...

You could make sure the characters you wish to dis-allow are not,
if fact, there, eg:

$exp = <STDIN>;
chop $exp;
if ($exp =~ /^[^.*]+$/ && $data =~ /$exp/) {
   #Do something.
}

Hope that helps.

Patrick Timmins
U. Nebraska Medical Center

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: Fri, 18 Sep 1998 21:23:01 +0200
From: "Mark" <admin@asarian-host.org>
Subject: Why does sendmail lose recipients?
Message-Id: <199809181924.NAA01364@asarian-host.org>

Dear reader,

When sendmail transfers mail to a delivery agent set in sendmail.cf, is has
compiled an internal list of recipients that it feeds the delivery agent. A
regular sendmail.cf section would look like this:

Mlocal,  P=/bin/vmail, F=lsDFMAw5:/|@qrmn9, S=10/30, R=20/40,
            T=DNS/RFC822/X-Unix,
            A=mail -d $u

Mprog,  P=/bin/sh, F=lsDFMoqeu9, S=10/30, R=20/40, D=$z:/,
            T=X-Unix,
            A=sh -c $u

For a long time now, there is a problem that I have not been able to
successfully solve. Reading the above, imagine one of the recipients being a
user with a .forward file with the following content:

mailfilter@my.domain

Where "mailfilter" would be an aliases in the form of:

mailfilter: "| /usr/bin/perl /usr/local/etc/httpd/cgi-bin/mailfilter.pl"

(In case you wonder why the .forward file does not immediately hold a line
like:

"| /usr/local/etc/httpd/cgi-bin/mailfilter.pl"

That is so as to still allow piping mail to a program for users that have no
shell-access themselves). Okay, so far so good: the designated perl-script
"mailfilter.pl" will receive the content of the entire email ready for
reading from STDIN. Perfect, except that when the perl-script is done, and
exited with error-code 0, sendmail has "forgotten" all its other recipients.
It somehow stops delivering mail to the remainder of the recipients.
Although with a bit of work recipients could be extracted from the
mail-header (ugly) inside the perl-script, that will fail for those
recipients sendmail collected from bcc-lines.

The question is of course: why does sendmail forget the rest of its
recipients? The answer to that question may not be so trivial as it would
seem. An easy, but at least incomplete, answer would be saying that having
run the perl-script has caused sendmail to lose, or change, its original
environment. But that is not entirely true. Look what I did for the SMTP
section:

Msmtp,  P=/usr/bin/perl, F=mDFMuX, S=11/31, R=21, E=\r\n, L=990,
             T=DNS/RFC822/SMTP,
             A=perl /usr/local/etc/httpd/cgi-bin/smtp_control.pl $u $f $r $s

Although the flags on these line are here merely for cosmetic reasons, and
so as not to confuse sendmail unnecessarily, sendmail relinquishes
SMTP-control to the perl-script (the perl-script itself, having done its
checks, then resends the mail running another sendmail with a more
traditional sendmail.cf having a delivery agent that speaks SMTP). That
works smoothly; no matter how many recipients there are, sendmail will keep
calling the perl-script until its entire internal list of recipients has
exhausted. Works like a charm. Question is therefore, why does the
environment stay perfectly stable for this SMTP-trick, and keeps delivering
mail to all its recipients, while sendmail loses the remainder of its
recipients for .forward files that have mail piped to a perl-script too?

Should you perchance reply, please be so good as to cc a copy to me.

Much obliged,

- Mark

        System Administrator Asarian-host.org







--
For more information about this posting service, contact:

help@asarian-host.org    -- for instant general information about our services
admin@asarian-host.org   -- for the server's administrator
nclark@asarian-host.org  -- for our PR manager
abuse@asarian-host.org   -- for abuse of this posting service

If you wish to get an anonymous email/posting account, visit our sign-up page:

http://asarian-host.org/emailform.html


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

Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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 V8 Issue 3753
**************************************

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