[13141] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 551 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Aug 16 05:07:24 1999

Date: Mon, 16 Aug 1999 02:05:11 -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           Mon, 16 Aug 1999     Volume: 9 Number: 551

Today's topics:
        (...) ? ... : ... for three/more choices ?? marcza@my-deja.com
    Re: (...) ? ... : ... for three/more choices ?? (elephant)
        A module to create bibliographic entries <jcarlson@stanford.edu>
        Accessing $#array if array not declared marcza@my-deja.com
    Re: Accessing $#array if array not declared (elephant)
    Re: closing browser window <phony@nospam.com>
    Re: Creating hotlinks out of plain URLs in Perl. (Abigail)
        DBI-Problem: SELECT Statement with bind_param() <goesmann@do.isst.fhg.de>
    Re: DBI-Problem: SELECT Statement with bind_param() (Graham Ashton)
    Re: Error message: comma not allowed in filehandle line (Martien Verbruggen)
    Re: HARASSMENT -- Monthly Autoemail (Michael Rubenstein)
    Re: HARASSMENT -- Monthly Autoemail <drclue@drclue.net>
    Re: Looking for a Regular Expression to do an exact mat (Andreas Fehr)
    Re: Perl data type size (max and min values) (Abigail)
        RegExp question marcza@my-deja.com
    Re: RegExp question (elephant)
    Re: Simple Perl Parsing? (Abigail)
    Re: Simple Q: open(FILE,"http://...? (Abigail)
        statistical sorts <marc@interak.com>
    Re: Wacky Programming Tales (Kaz Kylheku)
    Re: Why use comp.lang.python when you've got comp.lang. <I.Clarke@strs.co.uk>
    Re: Why use Perl when we've got Python?! (Sam Holden)
    Re: Why use Perl when we've got Python?! <meowing@banet.net>
    Re: Why use Perl when we've got Python?! <rra@stanford.edu>
    Re: Why use Python when we've got Perl? <skip@mojam.com>
        Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)

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

Date: Mon, 16 Aug 1999 07:28:56 GMT
From: marcza@my-deja.com
Subject: (...) ? ... : ... for three/more choices ??
Message-Id: <7p8ejh$knk$1@nnrp1.deja.com>

Assume there are 4 "pairs" of strings

"aadd" ~  "first"
"hhww" ~ "second"
"qqll" ~ "third"
"kk" ~ "forth"

Now I want to print out exactly this second half
which belongs to the first half. Read:
Something like

$first part = "aadd";
print "Now the output=".($first_part eq "aadd","hhww","qqll","kk") ?
                        "first" : "second" : "qqll" : "forth")."\n";

Well, I know. It could be done several ways with hashes, with arrays
 ...But the solution should be as simple as possible. Preferable as a
one "oneliner" (see above). I don't want to declare extra variables.
I just want to fill in the target patterns ("first....) into the
printing statement itself.

Any suggestions ?

Bye

Marcus








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


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

Date: Mon, 16 Aug 1999 17:53:32 +1000
From: elephant@squirrelgroup.com (elephant)
Subject: Re: (...) ? ... : ... for three/more choices ??
Message-Id: <MPG.12226e89b731315e989c2e@news-server>

marcza@my-deja.com writes ..
>"aadd" ~  "first"
>"hhww" ~ "second"
>"qqll" ~ "third"
>"kk" ~ "forth"
-
>Well, I know. It could be done several ways with hashes, with arrays
>...But the solution should be as simple as possible. Preferable as a
>one "oneliner" (see above). I don't want to declare extra variables.
>I just want to fill in the target patterns ("first....) into the
>printing statement itself.
>
>Any suggestions ?

honestly .. you should use a hash .. this is pretty much what they were 
born to do

#--begin
my %h = { aadd => "first"
        , hhww => "second"
        , qqll => "third"
        , kk => "forth"		# [sic]
        };

my $first_part = "aadd";
print "Now the output = $h{$first_part}\n";
#--end

there's no shame in declaring extra variables .. another option is with 
one of the many SWITCH constructs in perl .. something like

#--begin
my $first_part = "aadd";
print "Now the output = ";

for ($first_part)
{
  /aadd/ && do { print "first" ; last; };
  /hhww/ && do { print "second"; last; };
  /qqll/ && do { print "third" ; last; };
  /kk/   && do { print "forth" ; last; };
}
#--end

-- 
 jason - elephant@squirrelgroup.com -


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

Date: 16 Aug 1999 07:24:57 GMT
From: "Jim" <jcarlson@stanford.edu>
Subject: A module to create bibliographic entries
Message-Id: <01bee7b8$71f2f860$cc008924@ling-pc1.stanford.edu>

Hello,

Has anyone here seen a perl module (or anything else, for that matter)
which takes
a variety of information about a particular work (e.g., title, author,
editor) and, 
depending on the type of work (article,book,review) assembles it into a
valid 
bibliographical entry, following some major convention?

I know it's a long shot, but it would be really neat if such a module did
exist.

Thanks,

Jim


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

Date: Mon, 16 Aug 1999 07:37:41 GMT
From: marcza@my-deja.com
Subject: Accessing $#array if array not declared
Message-Id: <7p8f44$l30$1@nnrp1.deja.com>

Suppose:

# @lines = ("a", "b", "c");
print "ARR=$#lines\n";  # gives ARR=-1
$ind = 0;
while ($ind <= $#lines)
   {  ... }

The content of $#lines is just before the while loop
-1 because the array is undefined. Therefore the loop should not be
entered. Surprisingly it ENTERS the loop ! Why ?

Bye

Marcus


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


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

Date: Mon, 16 Aug 1999 18:07:29 +1000
From: elephant@squirrelgroup.com (elephant)
Subject: Re: Accessing $#array if array not declared
Message-Id: <MPG.122271d0eb78030a989c2f@news-server>

marcza@my-deja.com writes ..
>Suppose:
>
># @lines = ("a", "b", "c");
>print "ARR=$#lines\n";  # gives ARR=-1
>$ind = 0;
>while ($ind <= $#lines)
>   {  ... }
>
>The content of $#lines is just before the while loop
>-1 because the array is undefined. Therefore the loop should not be
>entered. Surprisingly it ENTERS the loop ! Why ?

just copied-pasted your code above .. and it doesn't enter the loop on 
either of my machines

5.004_04 i386-linux (a newly rebuilt Redhat 5.2 install)
5.005_02 MSWin32-x86-object (ActiveState's 508 build)

-- 
 jason - elephant@squirrelgroup.com -


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

Date: 16 Aug 1999 05:47:22 GMT
From: "Bart Simpson" <phony@nospam.com>
Subject: Re: closing browser window
Message-Id: <7p88la$qa3$0@216.39.133.71>


Eli Smets <Eli.Smets@advalvas.be> wrote in message
news:7p72uj$6c6$1@nickel.uunet.be...

> Is it possible to close the active browser window from within perl code?
>

Yes,

# assuming mime header already printed
print 'javascript:window.close();';

That will do the trick.  It will automatically close a window that was
opened by javascript, but if it is the main window, or a user opened window,
then a prompt will be displayed, allowing the user to cancel.




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

Date: 16 Aug 1999 02:45:16 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Creating hotlinks out of plain URLs in Perl.
Message-Id: <slrn7rfge9.8kg.abigail@alexandra.delanet.com>

Sunfox (sunfox@sunwerx.com) wrote on MMCLXXVI September MCMXCIII in
<URL:news:VTLt3.106061$U42.140154@news1.rdc1.bc.home.com>:
== Abigail wrote in message ...
== >
== >As for a formatted version, no, not really. But here's the code that
== >created the regex:
== 
== Thanks for that; allows me to edit it. Unfortunately, I just noticed it only
== HREFs the base domain - for instance, in the URL
== http://www.microsoft.com/windows/index.html only http://www.microsoft.com/
== would be a link, completely ignoring windows/index.html. Any ideas? Has no
== one ever really encountered this problem before? :-P


It works for me:

#!/opt/perl/bin/perl -w

use strict;

my $re = q {
(?:http://(?:(?:(?:(?:(?:[a-zA-Z\d](?:(?:[a-zA-Z\d]|-)*[a-zA-Z\d])?)\.
 ... [105 lines deleted] ...
\$\-_.!~*'(),])|(?:%[a-fA-F\d]{2})|[:@&=+])*))*)?)))
};

$re =~ s/\s+//g;

while (<DATA>) {
    chomp;
    if (/($re)/o && $_ eq $1) {
        print "$_: matched\n";
    }
    else {
        print "$_: failed\n";
    }
}


__DATA__
http://www.microsoft.com/windows/index.html



http://www.microsoft.com/windows/index.html: matched



Abigail
-- 
package Just_another_Perl_Hacker; sub print {($_=$_[0])=~ s/_/ /g;
                                      print } sub __PACKAGE__ { &
                                      print (     __PACKAGE__)} &
                                                  __PACKAGE__
                                            (                )


  -----------== 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: Mon, 16 Aug 1999 09:04:53 +0200
From: Thomas Goesmann <goesmann@do.isst.fhg.de>
To: Thomas Goesmann <goesmann@do.isst.fhg.de>, rhrh@hotmail.com
Subject: DBI-Problem: SELECT Statement with bind_param()
Message-Id: <37B7B815.AC9A8AC2@do.isst.fhg.de>

Hi,

sorry for posting the same question again but the first posting was
misleading.

So, the exact problem is the following: We use DBI with ODBC and we need
to execute a SQL statement like:

SELECT *
FROM Process
WHERE ProcessID = <Variable>

which I think is generally possible with the bind_param function. But
what is the exact syntax?

We tried 

$sth = $dbh->prepare(
>         q  {
>                 SELECT *
>                 FROM Process
>                 WHERE ProcessID = ?
>             });
> 
> $rc = $sth->bind_param( ??????????????????? );
> $rc = $sth->execute();
 
but we could not find the appropriate parameters for the bind_param
function. 

Could anybody help (Richard, do you know the solution to this problem)?

Thank you very much.

Regards,

Thomas Goesmann


-- 
________________________________________________________________
Dipl.-Inf.                          Fraunhofer-Institut fuer 
Thomas Goesmann                     Software- und Systemtechnik
Tel  : ++49 +231 9700 - 743         Joseph-v.-Fraunhofer-Str. 20
Fax  : ++49 +231 9700 - 798         Postfach 52 01 30
eMail: goesmann@do.isst.fhg.de      D-44227 Dortmund
WWW  : http://www.do.isst.fhg.de/mitarbeiter/Thomas.Goesmann/


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

Date: 16 Aug 1999 08:06:24 GMT
From: billynospam@mirror.bt.co.uk (Graham Ashton)
Subject: Re: DBI-Problem: SELECT Statement with bind_param()
Message-Id: <slrn7rfhk0.u4k.billynospam@wing.mirror.bt.co.uk>

In article <37B7B815.AC9A8AC2@do.isst.fhg.de>, Thomas Goesmann wrote:
>
>SELECT *
>FROM Process
>WHERE ProcessID = <Variable>

SELECT * is very bad. Applications break when your database changes.
List the things you want to select properly, even if you want them all!

>which I think is generally possible with the bind_param function. But
>what is the exact syntax?

my $sth = $dbh->prepare( q{
    SELECT foo
      FROM bar
     WHERE fruit = ?
}) or die $dbh->errstr;

$sth->execute($apple) or die $sth->errstr;

Any clearer?

-- 
Graham

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


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

Date: Mon, 16 Aug 1999 06:57:03 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Error message: comma not allowed in filehandle line 15
Message-Id: <3DOt3.226$Cb2.11849@nsw.nnrp.telstra.net>

In article <7p42li$qa4$1@nnrp1.deja.com>,
	neptune19@my-deja.com writes:
> I wrote a small Perl script and when run the following message appears:
> no comma allowed in filehandle in line 15
> The only line of code in my script that has a comma is this one:
> print header, start_html;
> which I believe is harmless

Yes, it is harmless. The world will _not_ stop rotating because of
that line. But.... Your program will not compile. You know why?
Because you have a comma after (what perl believes is) a filehandle in
the print statement.

Next time you have one of perl's totally obscure errors which are
absolutely not clear at all, you should look up the error in the
perldiag documentation, which I will quote for you here:

# perldoc perldiag
[snip]
     No comma allowed after %s
         (F) A list operator that has a filehandle or "indirect
         object" is not allowed to have a comma between that and
         the following arguments.  Otherwise it'd be just another
         one of the arguments.

		 One possible cause for this is that you expected to have
         imported a constant to your name space with use or
         import while no such importing took place, it may for
         example be that your operating system does not support
         that particular constant. Hopefully you did use an
         explicit import list for the constants you expect to
         see, please see the use entry in the perlfunc manpage
         and the import entry in the perlfunc manpage. While an
         explicit import list would probably have caught this
         error earlier it naturally does not remedy the fact that
         your operating system still does not support that
         constant. Maybe you have a typo in the constants of the
         symbol import list of use or import or in the constant
         name at the line where this error was triggered?
[snip more]

If that 'header' is supposed to be the CGI module's one, just use 

print header(), start_html();

or import the right names by giving the use CGI statement the right
options.

Martien
-- 
Martien Verbruggen                  | 
Interactive Media Division          | That's not a lie, it's a terminological
Commercial Dynamics Pty. Ltd.       | inexactitude.
NSW, Australia                      | 


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

Date: Mon, 16 Aug 1999 06:13:35 GMT
From: miker3@ix.netcom.com (Michael Rubenstein)
Subject: Re: HARASSMENT -- Monthly Autoemail
Message-Id: <37b7a952.701300396@nntp.ix.netcom.com>

On Sun, 15 Aug 1999 12:04:05 -0500, "Daniel R. Tobias"
<dan@softdisk.com> wrote:

>Just how are newbies *ever* supposed to learn the basics of netiquette
>in the future, if people like you are so intent on insisting that the
>"oldtimers" be "nicey-nicey" and never do anything so rude as to
>actually tell a newbie that something they did was wrong?

And this thread contains a wealth of information for newbies on
the basics of netiquette.

Tom Christiansen has shown them the proper way to deal with
disagreement -- harrass the other party with email.

I R A Darth Aggie has taught them that it is OK to send spam to
anyone who posts on usenet.  After all, posting on usenet is an
invitation for unsolicited email.

These are not the lessons I would choose to teach beginners.



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

Date: Sun, 15 Aug 1999 23:39:50 -0700
From: ".." <drclue@drclue.net>
Subject: Re: HARASSMENT -- Monthly Autoemail
Message-Id: <37B7B236.F8799E1A@drclue.net>

Michael Rubenstein wrote:

> On Sun, 15 Aug 1999 12:04:05 -0500, "Daniel R. Tobias"
> <dan@softdisk.com> wrote:
>
> >Just how are newbies *ever* supposed to learn the basics of netiquette
> >in the future, if people like you are so intent on insisting that the
> >"oldtimers" be "nicey-nicey" and never do anything so rude as to
> >actually tell a newbie that something they did was wrong?
>
> And this thread contains a wealth of information for newbies on
> the basics of netiquette.
>
> Tom Christiansen has shown them the proper way to deal with
> disagreement -- harrass the other party with email.
>
> I R A Darth Aggie has taught them that it is OK to send spam to
> anyone who posts on usenet.  After all, posting on usenet is an
> invitation for unsolicited email.
>
> These are not the lessons I would choose to teach beginners.

Thankyou kind sir for fighting the good fight.
There seems to be a confusion in priorities amoungst some in which answers
lag far behind protocol of transactions in their priorities.

This a disgusting turn of events for the internet that answers are lower
than political form


--
--=<> Dr. Clue (A.K.A. Ian A. Storms) <>=--
--=<[]>=- http://www.drclue.net
--=<[]>=-
--=<[]>=- C++ HTML JavaScript JAVA VRML DHTML
--=<[]>=- CGI NSAPI TCP/IP SQL Sybase Informix (Interest In Oracle)
--=<[]>=- Dr. Clue's famous HTML/CGI guide.
--=<[]>=- http://www.drclue.net/F1.cgi/HTML/HTML.html




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

Date: Mon, 16 Aug 1999 05:43:06 GMT
From: backwards.saerdna@srm.hc (Andreas Fehr)
Subject: Re: Looking for a Regular Expression to do an exact match case   indepenent
Message-Id: <37b7a48f.1319407@news.uniplus.ch>

On Sun, 15 Aug 1999 21:38:41 GMT, bart.lateur@skynet.be (Bart Lateur)
wrote:

>>>> Does anyone know how "regular expression" that matches either upper or
>>>>  lower case letter strings and does not use the "/i" option ???
>>>
>>>/[a-zA-Z]/
>>>
>>
>>And how should that match 'computer administration' ?
>
>	/[cC][oO][mM][pP][uU][tT][eE][rR]/ # etc.
>
>When I tested it, it turned out to be quite a bit faster than the //i
>option.
>

Thanks, I guess. But that was some rhetorical question.
I wanted to make him think about the answer he gave.

Andreas


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

Date: 16 Aug 1999 03:07:11 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Perl data type size (max and min values)
Message-Id: <slrn7rfhne.8kg.abigail@alexandra.delanet.com>

Steve (steve@nomail.com) wrote on MMCLXXVI September MCMXCIII in
<URL:news:37B77CA1.115C205A@nomail.com>:
** Hi all, got a pretty simple Perl question here.
** 
** How can I determine the maximum and minimum value of a scalar value?
** Or, what is the size of a scalar.  I can\x92t seem to find this information
** in Larry Wall\x92s Programming Perl or the online perl.com documentation.
** 
** Please respond via newsgroup only (email is not valid to avoid junk
** mail).

If you put down a silly email address, I might give you a silly answer.
BTW, you have illegal characters in your post.


Here's one way to find out:

     my  $j = my $i = 0;
     do {$j =    $i ++} until $i =~ /Inf/;
     print "The maximum value of a scalar is: $j\n";


Abigail
-- 
perl -e 'for (s??4a75737420616e6f74686572205065726c204861636b65720as?;??;??) 
             {s?(..)s\??qq \?print chr 0x$1 and q ss\??excess}'


  -----------== 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: Mon, 16 Aug 1999 07:45:58 GMT
From: marcza@my-deja.com
Subject: RegExp question
Message-Id: <7p8fjk$lem$1@nnrp1.deja.com>

I want to find out a regexp which inserts a "0" if the day or the month
of a date is only a single digit:

$mydate1 = "2.12.1999"; # should give "02.12.1999"
$mydate2 = "7.2.1999";  # should give "07.02.1999"
$mydate3 = "03.4.1999";  # should give "03.04.1999"

I could do that with two replacement statement. But this must go within
one line.

With two:
$mydate1 =~ s/^([1-9])\./0$1\./eg;
$mydate1 =~ s/\.(1-9])\./\.0$1\./eg;

Bye

Marcus


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


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

Date: Mon, 16 Aug 1999 18:15:48 +1000
From: elephant@squirrelgroup.com (elephant)
Subject: Re: RegExp question
Message-Id: <MPG.122273be86cfceb5989c30@news-server>

marcza@my-deja.com writes ..
>I want to find out a regexp which inserts a "0" if the day or the month
>of a date is only a single digit:
>
>$mydate1 = "2.12.1999"; # should give "02.12.1999"
>$mydate2 = "7.2.1999";  # should give "07.02.1999"
>$mydate3 = "03.4.1999";  # should give "03.04.1999"

a combination of sprintf and the return list from the m// operator would 
be the way I'd do it .. btw - if you're just going to print this then 
use printf instead of sprintf and lose the assignment

  $mydate1
    = sprintf( "%02d.%02d.%4d", $mydate1 =~ m/(\d+)\.(\d+)\.(\d+)/);


see

  perldoc -f sprintf

and the m// documentation in

  perldoc perlop

for more information

-- 
 jason - elephant@squirrelgroup.com -


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

Date: 16 Aug 1999 03:15:06 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Simple Perl Parsing?
Message-Id: <slrn7rfi69.8kg.abigail@alexandra.delanet.com>

Linux GNUBEE (dchurch@kabana.net) wrote on MMCLXX September MCMXCIII in
<URL:news:7optnf$2ov$1@macaw.cyberport.com>:
__ Could someone please show me how to grab ONLY certain text from a string,
__ such as the following:
__ 
__ my $line = "fasdjfhkdfhaksdfhSTARThello worldENDaskjkdfljkdfjls";
__ 
__ How can I parse out only the text between the two tags, including the tags
__ in their respective positions within the string.  In other words, I want
__ toend up with
__ 
__ STARThello worldEND


substr $line, index ($line, "START"), 3 + rindex ($line, "END") - length $line;



Abigail
-- 
perl -we 'print split /(?=(.*))/s => "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: 16 Aug 1999 03:16:45 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Simple Q: open(FILE,"http://...?
Message-Id: <slrn7rfi9c.8kg.abigail@alexandra.delanet.com>

mms67 (mms67@usa.net) wrote on MMCLXXV September MCMXCIII in
<URL:news:7p59s9$4uh@enews1.newsguy.com>:
// Can I open a remote file in Perl like this:
// 
// open(FILE,"http://host/file");  ?

No.

// If not, how can the above be achieved?


use LWP;



Abigail
-- 
%0=map{reverse+chop,$_}ABC,ACB,BAC,BCA,CAB,CBA;$_=shift().AC;1while+s/(\d+)((.)
(.))/($0=$1-1)?"$0$3$0{$2}1$2$0$0{$2}$4":"$3 => $4\n"/xeg;print#Towers of Hanoi


  -----------== 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, 15 Aug 1999 21:48:32 -0800
From: Marc Grober <marc@interak.com>
Subject: statistical sorts
Message-Id: <37B7A62F.2DA92CCF@interak.com>

I am looking for a way to sort a population into arbitrarily sized
groups so that the distribuition of a characteristic in the full
population is the same as in the sample groups.  I have looked at CPAN's
stat modules and was really looking for somethingat a higher level in
that I am sure there must be code like this already in use.

Marc Grober
marc@interak.com



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

Date: Mon, 16 Aug 1999 05:27:51 GMT
From: kaz@ashi.FootPrints.net (Kaz Kylheku)
Subject: Re: Wacky Programming Tales
Message-Id: <slrn7rf8bf.hp6.kaz@ashi.FootPrints.net>

On 15 Aug 1999 22:18:59 GMT, Ben Caradoc-Davies <bmcd@es.co.nz> wrote:
>There is nothing wrong with i = i + 1 (especially for us Pythonistas :-), but
>taken together with the loop it suggests an unfamiliarity with the accepted
>idioms of the language.

It does suggest that. But it could also be some religous thing. As in ``I won't
use this evil ++ thing because KRUDBAL didn't have it, and KRUDBAL is the
finest programming language there ever was. So if it's not in KRUDBAL, you
don't need it.''

:)


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

Date: Mon, 16 Aug 1999 09:54:36 +0100
From: Ian Clarke <I.Clarke@strs.co.uk>
Subject: Re: Why use comp.lang.python when you've got comp.lang.perl.misc?
Message-Id: <37B7D1CC.66ADE8F5@strs.co.uk>


> I believe that if someone wanted to hear about why Perl was a nasty
> language and Python was the cat's meow, that they wouldn't be reading
> comp.lang.perl.misc to do so.  Wouldn't you agree?  Nonetheless, certain
> members of the Python Mafia seem to have taken it upon themselves to
> come over here and do precisely that.

Firstly, if you are counting me among those members of the "Python
Mafia" then you have not paid close attention to my postings.  I have
never claimed to know enough about Perl to say that it is better or
worse than Python - I have only commented on my initial impressions of
the language, and on comments made by others in this thread.

Secondly, are you suggesting that any comments critical of Perl should
be censored from comp.lang.perl.misc?  Some people actually enjoy a bit
of healthy debate.

Ian.


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

Date: 16 Aug 1999 05:49:45 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Why use Perl when we've got Python?!
Message-Id: <slrn7rf9km.9r6.sholden@pgrad.cs.usyd.edu.au>

On Sun, 15 Aug 1999 21:09:36 -0700,
   TRG Software: Tim Greer <webmaster@chatbase.com> wrote:

My kill file works so I'll have to reply to a reply oh well...

>John Stevens wrote:
>> 
>> On 13 Aug 1999 14:26:17 -0700, Tom Christiansen <tchrist@mox.perl.com> wrote:
>> >     [courtesy cc of this posting mailed to cited author]
>> >
>> 
>> >I say this for certain because I *do* read their code, and it's completely
>> >easy to do so.
>> 
>> Yes?  There is a sig:
>> 
>> #!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
>> $^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
>>  00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
>> rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print
>> 
>> So, tell me, in thirty seconds or less, and without refering to a
>> reference manual, what this does?  If you
>> wrote this, or have ever seen it before, this test is invalid.

The really sad thing is that it isn't that hard. Though I'm probably wrong...

$^=q; - we are assigning to $^ whatever we find until the next ;. Simple
enough I know how to quote strings in perl.

;, - end the string string started above and the , seperates the next
statement.

$0=q, - as above but this time assigning to $0 and ending on the next ,.

,, - end the string above and seperate the next statement.

($_=$^) - assign $^ to $_  ...

=~y, do a transliteration with , as the seperator.

, - end the characters to translate from, start those to go to...

,d - end the transliteration with a d option.

s, - do a substitution with , as the seperator again.

, - end the pattern, start the substitution.

,gee - end the substitution with the gee options.

,print - finally print $_...

Of course lots of stuff happens in the /ee part of the substitute I assume.

It took me more than 30 seconds to type, but basically in less than thirty 
seconds I can work out what is happening. I can't tell what the output will
be, because I can't be bothered doing tr// and s//gee in my head.

I could write a garbage string in python, pass it though a regular expression
or two, and then eval - I mean exec - it too. It would be equally difficult
to decipher.

>> 
>> You, of course, may well complain that this test is invalid or
>> unfair because *YOU* would never write code like this.  But if
>> you have problems with this, then why allow it?  If you have
>> problems with this, everybody else will, too.

Intentionally obfuscated code is irrelevant... You can do that in any language,
it does not make the language any less maintanable for real world use. Grow
up.

"x='x=%s;x%%`x`';x%`x`"



l='l=%s;print l%%`l`';print l%`l`


from sys import*;from string import*;a=argv;[s,p,q]=filter(lambda x:x[:1]!=
'-',a);d='-d'in a;e,n=atol(p,16),atol(q,16);l=(len(q)+1)/2;o,inb=l-d,l-1+d
while s:s=stdin.read(inb);s and map(stdout.write,map(lambda i,b=pow(reduce(
lambda x,y:(x<<8L)+y,map(ord,s)),e,n):chr(b>>8*i&255),range(o-1,-1,-1)))


q='"'
q1="'"
n='\n'
s='\\'
r1="def f(a,s1,s2,s3,s4):"
r2=" print a+'1='+q+s1+q+n+a+'2='+q+s2+q"
r3=" print a+'3='+q+s3+q+n+a+'4='+q+s4+q"
r4=" print s1+n+s2+n+s3+n+s4"
def f(a,s1,s2,s3,s4):
 print a+'1='+q+s1+q+n+a+'2='+q+s2+q
 print a+'3='+q+s3+q+n+a+'4='+q+s4+q
 print s1+n+s2+n+s3+n+s4
p1="print 'q='+q1+q+q1+n+'q1='+q+q1+q"
p2="print 'n='+q1+s+'n'+q1+n+'s='+q1+s+s+q1"
p3="f('r',r1,r2,r3,r4)"
p4="f('p',p1,p2,p3,p4)"
print 'q='+q1+q+q1+n+'q1='+q+q1+q
print 'n='+q1+s+'n'+q1+n+'s='+q1+s+s+q1
f('r',r1,r2,r3,r4)
f('p',p1,p2,p3,p4)


There's four python programs that most people won't be able to decipher in
30 seconds or less without referring to the docs. BFD. It doesn't mean
anything.

-- 
Sam

I explicitly give people the freedom not to use Perl, just as God gives
people the freedom to go to the devil if they so choose.
	--Larry Wall


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

Date: 16 Aug 1999 02:07:11 -0400
From: meow <meowing@banet.net>
Subject: Re: Why use Perl when we've got Python?!
Message-Id: <87vhagjm28.fsf@slip166-72-251-196.ma.us.ibm.net>

Abigail <abigail@delanet.com> wrote:

> If you have a large program, with a couple of hundreds of lines,
> a few import statements at the beginning don't matter that much.
> For onelines, it does though. ;-)

I read this before grabbing some sleep, and then qhad a dream where I
got a memo saying that all interactive computer usage would henceforth
be required to adhere to coding standards.  It *really* pissed me off.
THE END.

> You have a point that modularity makes it easier to change a languages
> behaviour. But do you really want that? Do you want to change, or remove
> existing behaviour, causing old scripts to no longer work, or to work
> differently if you upgrade your language? If you just add functionality,
> it hardly matters (except perhaps for the poor sobs implementing it).

Overloading/overriding can be a really nifty toy, used sanely.  The
obvious example in Perl would be the ability to pretend that dbm is
just an ordinary hash table.  I like that it's easy to take something
that does a bunch of vanilla writes for interactive use, and change
write's behavior so that it does efficient network buffering (or
perhaps line length encoding that only a VAX could love) without
having to put special cases out in the "real" code.

I know Perl lets you get to pretty much the same place with stuff like
modules, `use subs' and the not-quite-finished TIEHANDLE interface,
but the package/ISA/EXPORT red tape makes me feel like I'm trying to
get away with something naughty.  It just feels more "right" to play
with things like that when hey, it's just a method and overrides
happen.

In either language, however, it's thoroughly annoying when something
gets tweaked and the changes are just buried in there without so much
as a quick note that "OBTW, this function/method is an override."

> Of course, both you and Russ are absolutely right that one shouldn't
> judge the difficulty of a language on how large the core is, but what
> you need to learn to actually get your work done.

I'm sure quite a bit of the "perl is harder to learn" meme is just the
sheer heft of the documentation.  perlfunc.pod sees to be of infinite
length, for example.  Python *looks* easier because most of that stuff
is buried in the module references; but sheesh, there sure are a lot
of 'em and their names aren't exactly obvious. (I can't believe that
anyone really thinks it's intuitive to look in the os module if you
want to learn how to dup an fd.)


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

Date: 15 Aug 1999 23:26:00 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: Why use Perl when we've got Python?!
Message-Id: <yl907c44xz.fsf@windlord.stanford.edu>

John Stevens <jstevens@bamboo.verinet.com> writes:

> Yes?  There is a sig:

> #!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
> $^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
>  00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
> rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print

Yes, it's obfuscated code.  What's your point?  Do you seriously think
that writing obfuscated code is impossible in Python?  Believe me, any
language that supports overloading will let you write things far more
obfuscated than the above, which really isn't that hard to figure out.
The only tricks it really uses are odd quoting and delimiting characters.

Frankly, I didn't even go out of my way to obfuscate that block; it
started as an exercise in writing a self-printing Perl program within the
McQ limit, which requires writing very compactly, and then just 'cause I
felt like it I encrypted half the code with a simple transposition cypher
to make it look stranger.  Most of Abigail's sigs are way more obfuscated
than that; most moderately experienced Perl programmers who have spent a
few minutes picking apart my sig have figured it out without much trouble.

> You, of course, may well complain that this test is invalid or unfair
> because *YOU* would never write code like this.  But if you have
> problems with this, then why allow it?

You must be loads of fun at parties.  :)

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: Mon, 16 Aug 1999 01:12:03 -0500 (CDT)
From: Skip Montanaro <skip@mojam.com>
To: tchrist@mox.perl.com (Tom Christiansen)
Subject: Re: Why use Python when we've got Perl?
Message-Id: <14263.42199.122753.147323@dolphin.mojam.com>

    Tom> There's just no way to deal with the never-ending onslaught of
    Tom> non-programmer CGI script kiddies, who seem to outnumber the rest
    Tom> of us zillions to one.

You could tell them that CGI programming is easier in Python.  In fact, the
bot that responds to first posts to c.l.p.m could do this... ;-)

Skip Montanaro	| http://www.mojam.com/
skip@mojam.com  | http://www.musi-cal.com/~skip/
847-971-7098





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

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" from
almanac@ruby.oce.orst.edu. The real FAQ, as it appeared last in the
newsgroup, can be retrieved with the request "send perl-users FAQ" from
almanac@ruby.oce.orst.edu. 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" from
almanac@ruby.oce.orst.edu. 

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


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