[10186] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3779 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Sep 21 18:07:41 1998

Date: Mon, 21 Sep 98 15:00:23 -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           Mon, 21 Sep 1998     Volume: 8 Number: 3779

Today's topics:
        &ReadParse and multiple selection <mistone2@vt.edu>
    Re: &ReadParse and multiple selection <upsetter@ziplink.net>
    Re: &ReadParse and multiple selection (brian d foy)
    Re: <a href"http//www.x.com>y</a>----->perl script (Alastair)
    Re: Any hash function out there ? <jdporter@min.net>
    Re: any way to encrypt my script? bitnut1@my-dejanews.com
    Re: Cookie Help! (brian d foy)
        Error 405 Method Not Allowed <sloanw@desupernet.net>
    Re: Error 405 Method Not Allowed (brian d foy)
        Hashes springing into existence [Was: more regex/patter <mgregory@asc.sps.mot.com>
    Re: Hashes springing into existence [Was: more regex/pa <dgris@perrin.dimensional.com>
        HELP !!! <qli3@jetson.uh.edu>
    Re: HELP !!! (Garrett Casey)
    Re: HELP !!! (brian d foy)
    Re: How to check a file is already open (PERL 4) ? (Tye McQueen)
        input for another program <manam_suresh@bah.com>
    Re: input for another program (brian d foy)
    Re: JAPH: how does this .sig work? (Abigail)
    Re: JAPH: how does this .sig work? <eashton@bbnplanet.com>
    Re: My perl script does not open files.... <wolfie@wolfie.ml.org>
    Re: My perl script does not open files.... (Matt Knecht)
        net::ftp uploading mass files (Steve .)
    Re: Newbie sort questions (Andre L.)
    Re: Perl & Java - differences and uses <borg@imaginary.com>
    Re: Perl & Java - differences and uses <borg@imaginary.com>
    Re: Perl & Java - differences and uses <jdporter@min.net>
    Re: Perl & Java - differences and uses <borg@imaginary.com>
    Re: Perl & Java - differences and uses <borg@imaginary.com>
        Perl: Right Tool for the Job? (Rick Freeman)
    Re: PerlMagick & linux (Alastair)
    Re: Problem with Splits on blank lines <murrayb@vansel.alcatel.com>
    Re: Problem with Splits on blank lines (Alastair)
    Re: Problem with Splits on blank lines (brian d foy)
        problems using "use", HELP! <kchunt@mail.hac.com>
        until problem <rfs@castillian.com>
    Re: until problem <evonzee@tritechnet.com>
    Re: until problem <ludlow@us.ibm.com>
    Re: until problem <ajohnson@gpu.srv.ualberta.ca>
    Re: where is Date::Parse? (Honza Pazdziora)
    Re: where is Date::Parse? (Abigail)
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Mon, 21 Sep 1998 16:04:57 -0400
From: Michael Stone <mistone2@vt.edu>
Subject: &ReadParse and multiple selection
Message-Id: <3606B169.A1D7A2D@vt.edu>

How does &ReadParse handle the data returned by an HTML form selection
list that allows for multiple selections?  Is the respective element in
the %in array an array containing the multiple slections?


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

Date: Mon, 21 Sep 1998 20:39:55 GMT
From: Scratchie <upsetter@ziplink.net>
Subject: Re: &ReadParse and multiple selection
Message-Id: <vQyN1.393$_c5.3832133@news.shore.net>

Michael Stone <mistone2@vt.edu> wrote:
: How does &ReadParse handle the data returned by an HTML form selection
: list that allows for multiple selections?  Is the respective element in
: the %in array an array containing the multiple slections?

No. It separates the individual values with "\0".

--Art

-- 
--------------------------------------------------------------------------
                    National Ska & Reggae Calendar
                  http://www.agitators.com/calendar/
--------------------------------------------------------------------------


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

Date: Mon, 21 Sep 1998 18:00:44 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: &ReadParse and multiple selection
Message-Id: <comdog-ya02408000R2109981800440001@news.panix.com>
Keywords: from just another new york perl hacker

In article <3606B169.A1D7A2D@vt.edu>, Michael Stone <mistone2@vt.edu> posted:

>How does &ReadParse handle the data returned by an HTML form selection
>list that allows for multiple selections?  Is the respective element in
>the %in array an array containing the multiple slections?

what do the docs say?

perhaps you want CGI.pm though, which has a cgi-lib compatibility
mode.

good luck :)

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers needs volunteers! <URL:http://www.pm.org/to-do.html>


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

Date: Mon, 21 Sep 1998 21:07:33 GMT
From: alastair@calliope.demon.co.uk (Alastair)
Subject: Re: <a href"http//www.x.com>y</a>----->perl script
Message-Id: <slrn70djnu.4q.alastair@calliope.demon.co.uk>

webmaster <webmaster@keynet.be> wrote:
>Hello,
>
>I want to replace the html tag <a href:"http//www.something.com">name</a>
>by a perl script. This must give me the opportunity within the same script
>counting how many times a certain icon is clicked on within a html page.

What have you tried so far?

>Thanks in advance.

You're welcome.

-- 

Alastair
work  : alastair@psoft.co.uk
home  : alastair@calliope.demon.co.uk


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

Date: Mon, 21 Sep 1998 17:16:48 -0400
From: John Porter <jdporter@min.net>
Subject: Re: Any hash function out there ?
Message-Id: <3606C240.64BC567E@min.net>

boubaker@dgac.fr wrote:
> 
>  My problem is that I want to generate unique ids for a list of string (that
> are guaranteed to be always different) that my program receive `on the fly'
> (and even on multiples instances of my program), $id = $^T$$; is not good
> because strings could arrive very quickly ($^T not precise enough), and
> before reinventing the wheel I expected that there is a faster and cleaner
> and  safer way by using perl internal hash function.

MD5::hash() gives a very good distribution, but isn't particularly fast.
You might want to try it out and see if it's fast enough for your
purposes.

-- 
John "Many Jars" Porter


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

Date: Mon, 21 Sep 1998 20:16:20 GMT
From: bitnut1@my-dejanews.com
Subject: Re: any way to encrypt my script?
Message-Id: <6u6c6j$mkp$1@nnrp1.dejanews.com>


>-------------------------------------
> Russ Allbery <rra@stanford.edu>:
> I don't think that *most* people really care about the reversibility ..
>-------------------------------------

I do not consider the obfuscation part to be most important either,
but I can envision many situations where it well might be.

Say, someone is a fervent proponent of "free" software and chooses,
naturally, Perl. He (let's forget for a moment that real men
program in C) makes all the source code available for free.

However, he does not believe that information should also be free.
So, he charges oodles for the information on how to use the "free"
software and the "imprisoned" info can be released by paying online.

Now comes the ultimate revenge.
Some people believe that everything on the Net should be free and
are pleased when they find the keys to the cell-block in plain view
(source code). Having gotten the keys from the jailer, they will
merrily snatch the information and release it for everyone to share.

B.N.

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


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

Date: Mon, 21 Sep 1998 17:56:59 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: Cookie Help!
Message-Id: <comdog-ya02408000R2109981756590001@news.panix.com>
Keywords: from just another new york perl hacker

In article <3606AD7B.B5BCF615@horizonlive.com>, Rasan Rasch <rasan@horizonlive.com> posted:

>> Can anyone direct me to (hopefully) an on-line or downloadable file that
>> explains how to use cookies; ie. writing, reading, etc.
>
>You should use CGI.pm.
>http://stein.cshl.org/WWW/software/CGI/cgi_docs.html
>There should be a section on cookies with an example script.

one might also look at the CGI Meta FAQ which contains references
to many cookie resources, including the above module.

good luck :)

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers needs volunteers! <URL:http://www.pm.org/to-do.html>


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

Date: Mon, 21 Sep 1998 16:38:56 -0400
From: "sw" <sloanw@desupernet.net>
Subject: Error 405 Method Not Allowed
Message-Id: <36069033.0@news.redrose.net>

i am attempting to design a website for my company(winNT server) but always
receive a
'405: method not allowed' error when attempting to submit a form using perl.

i am also aware that this error message is a SERVER problem but both i and
the company's system administrator are unfamiliar with web servers.

can anyone please explain to me how i(we) can fix this problem?

the full error message reads as follows:
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.

Please contact the server's administrator if this problem persists.

thank you for your time.

-sloan







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

Date: Mon, 21 Sep 1998 17:54:53 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: Error 405 Method Not Allowed
Message-Id: <comdog-ya02408000R2109981754530001@news.panix.com>
Keywords: from just another new york perl hacker

In article <36069033.0@news.redrose.net>, "sw" <sloanw@desupernet.net> posted:

>i am attempting to design a website for my company(winNT server) but always
>receive a
>'405: method not allowed' error when attempting to submit a form using perl.

i beleive The Idiot's Guide to Solving Perl CGI Problems, referenced in
the CGI Meta FAQ, answers this question.

good luck.

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers needs volunteers! <URL:http://www.pm.org/to-do.html>


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

Date: 21 Sep 1998 16:02:08 +0930
From: Martin Gregory <mgregory@asc.sps.mot.com>
Subject: Hashes springing into existence [Was: more regex/pattern substitution]
Message-Id: <r8af3uc6xj.fsf_-_@asc.sps.mot.com>


cberry@cinenet.net (Craig Berry) writes:

> value created the element.  On reflection, I realized that I was
> remembering a slightly different case -- that doing
> 
>   exists $foo{bar}{quux}
> 
> creates $foo{bar} if it didn't exist already. 

I have been bitten by this too.  I wonder why it happens?   Is there
ever a case where this is a desirable effect?

Martin.


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

Date: Mon, 21 Sep 1998 21:58:33 GMT
From: Daniel Grisinger <dgris@perrin.dimensional.com>
Subject: Re: Hashes springing into existence [Was: more regex/pattern substitution]
Message-Id: <6u6h92$58n$1@rand.dimensional.com>

[posted to comp.lang.perl.misc and mailed to the cited author]

In article <r8af3uc6xj.fsf_-_@asc.sps.mot.com>
Martin Gregory <mgregory@asc.sps.mot.com> wrote:

>cberry@cinenet.net (Craig Berry) writes:

>>   exists $foo{bar}{quux}
>> 
>> creates $foo{bar} if it didn't exist already. 

>I have been bitten by this too.  I wonder why it happens?   Is there
>ever a case where this is a desirable effect?

It's an artifact of autovivification.

Perl sees C< exists $foo{bar}{baz}; > and creates $foo{bar},
hanging an empty hash reference off of it, on it's way to
check if {baz} exists.

This is moderately annoying, but I'd imagine that fixing it
would break a lot of things (not to mention that fixing it
would almost certainly slow C<exists> way down).

dgris
-- 
Daniel Grisinger          dgris@perrin.dimensional.com
`By about halfway through I was beginning to guess the 
ending, but it still kind of surprised me.'
      David Hatunen, talking about the movie Titanic


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

Date: Mon, 21 Sep 1998 15:18:42 -0500
From: "Charles Li" <qli3@jetson.uh.edu>
Subject: HELP !!!
Message-Id: <6u6ccm$vrd$1@news4.wt.net>

 I created a "www/cgi-bin/" subdirectory under my own directory in a UNIX
system and put a file called ".htaccess" in it with only two lines:
  AddType applications/x-httpd-cgi  .cgi
  AddType applications/x-httpd-cgi  .pl
I copied a CGI example from
http://rodin.cs.uh.edu/~acl/IC/Examples/cgi-bin/x1.pl  and put it also under
www/cgi-bin/ and rename it as "time.pl".
I created a webpage and put in a link to
http://rodin.cs.uh.edu/~acl/IC/Examples/cgi-bin/x1.pl  , it works. However,
when I change the link to my copy of the same file, it just give the
annoying error message as:
500 Server Error
The server encountered an internal error or misconfiguration and was unable
to complete your request.
Please contact the server administrator and inform them of the time the
error occurred , and anything you might have done that may have caused the
error.
Error: HTTPd: malformed header from script ....../www/cgi-bin/time.pl
"time.pl" runs fine under command line if I type in "perl.time.pl". But it
won't work if I just type in "time.pl". Is there any UNIX setup I should do
to run a PERL (or any other program file) by just typing in the file name?
Thank you so much.


Charles Li

--
Charles Li




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

Date: Mon, 21 Sep 1998 21:43:12 GMT
From: nospamno_adms1@cts.com (Garrett Casey)
Subject: Re: HELP !!!
Message-Id: <3606c778.24277238@nntp.cts.com>

On Mon, 21 Sep 1998 15:18:42 -0500, "Charles Li" <qli3@jetson.uh.edu>
wrote:

> I created a "www/cgi-bin/" subdirectory under my own directory in a UNIX
>system and put a file called ".htaccess" in it with only two lines:
>  AddType applications/x-httpd-cgi  .cgi
>  AddType applications/x-httpd-cgi  .pl
>I copied a CGI example from
>http://rodin.cs.uh.edu/~acl/IC/Examples/cgi-bin/x1.pl  and put it also under
>www/cgi-bin/ and rename it as "time.pl".
>I created a webpage and put in a link to
>http://rodin.cs.uh.edu/~acl/IC/Examples/cgi-bin/x1.pl  , it works. However,
>when I change the link to my copy of the same file, it just give the
>annoying error message as:
>500 Server Error
>The server encountered an internal error or misconfiguration and was unable
>to complete your request.
>Please contact the server administrator and inform them of the time the
>error occurred , and anything you might have done that may have caused the
>error.
>Error: HTTPd: malformed header from script ....../www/cgi-bin/time.pl
>"time.pl" runs fine under command line if I type in "perl.time.pl". But it
>won't work if I just type in "time.pl". Is there any UNIX setup I should do
>to run a PERL (or any other program file) by just typing in the file name?
>Thank you so much.
>
>
>Charles Li
>
>--
>Charles Li
>
>

I am pretty sure this happened to me a long time ago.  If I remember
correctly, there where some weired characters in the script (ones that
my editor didn't display).  The script looked perfect, and it executed
from the command line, but didn't resulted in error 500 over the net.
I don't know why it worked, but i copied the file to then copied it
back.  Example

cp x1.pl x2.pl
rm x1.pl
cp x2.pl x1.pl
rm x2.pl

 

Garrett Casey
nospamo_adms1@cts.com
Remove "nospamo_" To send me email.


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

Date: Mon, 21 Sep 1998 17:58:35 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: HELP !!!
Message-Id: <comdog-ya02408000R2109981758350001@news.panix.com>
Keywords: from just another new york perl hacker

In article <6u6ccm$vrd$1@news4.wt.net>, "Charles Li" <qli3@jetson.uh.edu> posted:

>Error: HTTPd: malformed header from script ....../www/cgi-bin/time.pl
>"time.pl" runs fine under command line if I type in "perl.time.pl". But it
>won't work if I just type in "time.pl". Is there any UNIX setup I should do
>to run a PERL (or any other program file) by just typing in the file name?

see the CGI Meta FAQ; or a newsgroup that discusses server configuration
or CGI programming.

good luck :0

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers needs volunteers! <URL:http://www.pm.org/to-do.html>


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

Date: 21 Sep 1998 15:23:30 -0500
From: tye@fumnix.metronet.com (Tye McQueen)
Subject: Re: How to check a file is already open (PERL 4) ?
Message-Id: <6u6ck2$etf@fumnix.metronet.com>

>>>>> "titi" == titi  <tibiweb@chez.com> writes:
titi> How can I test if the incomming file (it's FTP from a distant server)
titi> is already closed ?

I think the "standard" way to do this is to have the FTP client
rename the file once it is downloaded.
-- 
Tye McQueen    Nothing is obvious unless you are overlooking something
         http://www.metronet.com/~tye/ (scripts, links, nothing fancy)


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

Date: Mon, 21 Sep 1998 16:06:49 -0400
From: Suresh Kumar Manam <manam_suresh@bah.com>
Subject: input for another program
Message-Id: <3606B1D9.C451B329@bah.com>

I am calling an external program from my perl script and it requires an
input after some intial process. How can I wait and pass that input to
that external program and how can I hardcode that ipnput in my script so
that it automatically passes to that external program.

Thanks

Kumar


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

Date: Mon, 21 Sep 1998 17:59:40 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: input for another program
Message-Id: <comdog-ya02408000R2109981759400001@news.panix.com>
Keywords: from just another new york perl hacker

In article <3606B1D9.C451B329@bah.com>, Suresh Kumar Manam <manam_suresh@bah.com> posted:

>I am calling an external program from my perl script and it requires an
>input after some intial process. How can I wait and pass that input to
>that external program and how can I hardcode that ipnput in my script so
>that it automatically passes to that external program.

see the perlipc man page for a discussion of several techniques.

good luck :)

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers needs volunteers! <URL:http://www.pm.org/to-do.html>


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

Date: 21 Sep 1998 21:13:50 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: JAPH: how does this .sig work?
Message-Id: <6u6fie$4ca$1@client3.news.psi.net>

Matt Knecht (hex@voicenet.com) wrote on MDCCCXLVII September MCMXCIII in
<URL: news:MmxN1.498$XP2.3856774@news3.voicenet.com>:
++ Arvind K. Karandikar <akarandi@pcocd2.intel.com> wrote:
++ >perl  -e '$_ = q *4a75737420616e6f74686572205065726c204861636b65720a*;
++ >          for ($*=******;$**=******;$**=******) {$**=*******s*..*qq}
++ >          print chr 0x$& and q
++ >          qq}*excess********}'
++ 
++ It may help to realize how much quoting is going on here, and what the
++ quote delimiters are.  Here's what I got when I boiled it all down to
++ somthing much simpler, and formatted sanely:
++ 
++ $_ = '4a75737420616e6f74686572205065726c204861636b65720a';
++ 
++ for ($x = 1; $x *= 1; $x *= 1) {
++     $x *= s/../"print chr 0x$& and 'qq'"/ee;
++ }

While this produced the same output, it's not the same.

I don't have a string "qq" in my sig. Try replacing 'qq' in your version
with '1'.


++ Using $* is very tricky, especially when combined with the *= operator
++ and the noise of ****** which could be any string.

No, it cannot.

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

won't compile and 

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

won't produce output.


++ You can see the final bit of magic if you slip in another print
++ statement:
++ 
++     $x = $x * s/../print "print chr 0x$& and 'qq'"/ee;
++ 
++ Even in this simplified form, theres a good deal going on.  Any use of
++ s///ee makes me cross-eyed when I first try to figure out what it's
++ doing.

There is more going on that you seem to be aware of.



Abigail
-- 
perl -MNet::Dict -we '(Net::Dict -> new (server => "dict.org")\n-> define ("foldoc", "perl")) [0] -> print'


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

Date: Mon, 21 Sep 1998 21:54:44 GMT
From: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Re: JAPH: how does this .sig work?
Message-Id: <3606C8BB.CA194536@bbnplanet.com>

Abigail wrote:

> There is more going on that you seem to be aware of.

So like a woman to love mystery. 

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: Mon, 21 Sep 1998 16:52:12 -0300
From: "Wolfie" <wolfie@wolfie.ml.org>
Subject: Re: My perl script does not open files....
Message-Id: <6u6ajr$soc$1@news.iis.com.br>

>You can just write:
>
>        $arq = 'c:/perl/temp';

        Thanks... very easier :)

>The rest of the operating system isn't quite as braindead as the command
>line parser.
>
>>     open (ARQ, $arq) || die "can't open $arq";
>>     print ARQ "test of script\n";
>
>I'm betting that the problem is that you're trying to write to a file that
>you opened for reading.

    Yeah, saw that after... But i tried with ">c:/perl/temp" and it does not
work too. it says that the file does not exist, but i created a empty file
and still not working... now it justs exit, without any warning... neither
the die error message... :(

    []'s
    Wolfie




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

Date: Mon, 21 Sep 1998 20:10:09 GMT
From: hex@voicenet.com (Matt Knecht)
Subject: Re: My perl script does not open files....
Message-Id: <BoyN1.500$XP2.3887965@news3.voicenet.com>

Wolfie <wolfie@wolfie.ml.org> wrote:
>>>     open (ARQ, $arq) || die "can't open $arq";
>>>     print ARQ "test of script\n";
>
>    Yeah, saw that after... But i tried with ">c:/perl/temp" and it does not
>work too. it says that the file does not exist, but i created a empty file
>and still not working... now it justs exit, without any warning... neither
>the die error message... :(

Then, ammend your program to complain when it has trouble printing:

open (ARQ, $arq) || die "can't open $arq";
print(ARQ "test of script\n") || warn "print: $!";

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


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

Date: Mon, 21 Sep 1998 21:55:21 GMT
From: syarbrou@ais.net (Steve .)
Subject: net::ftp uploading mass files
Message-Id: <3606cb07.6345870@news.ais.net>

I use net::ftp to download a couple files.  From that it creates a few
hundred tiny files with a perl script.  I need to upload these to a
server automatically after the perl script makes them.  What is the
best way to up them?  Should I read in the directory and then do a
foreach putting the files onto the server?  or is there a way with
net::ftp or something else to just upload everything in the directory
to a specific directory on the server?  Thanks.

Steve


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

Date: Mon, 21 Sep 1998 16:02:53 -0500
From: alecler@cam.org (Andre L.)
Subject: Re: Newbie sort questions
Message-Id: <alecler-2109981602530001@dialup-600.hip.cam.org>

In article <3606914A.49ED@csi.com>, Eric-Goforth@csi.com wrote:

> I was hoping that someone can explain some demo programs in Naba
> Barkakati's Discover Perl.  As given in the book, here are two examples
> of using the sort funtion:
> 
> C:\Perl\myapps>cat sortcost.pl
> #!/usr/bin/perl
> @cost = (24.99, 19.95, 49.95, 44.99);
> @sorted_cost = sort @cost;
> #print "@sorted_cost\n";
> print "@sorted_cost";
> 
> C:\Perl\myapps>cat sortname.pl
> #!/usr/bin/perl
> @names = ("Joe", "Tom", "John", "Bill", "Mary", "Susan");
> @sorted_names = sort(@names);   #save the array
> print "@sorted_names\n";
> 
> My question is, what's the rule as far as using parentheses when using
> the sort function?  Is it used for strings arrays only?  

Same rule as for any function or sub that requires a list of parameters.
You can use parens or not, and if you don't, you can screw up your code
(see archives in DejaNews for discussions on the subject). 

The author not only appears to be inconsistent in his use of parentheses
in his book, but, more importantly, the first example is downright wrong
-- unless it is an example of what not to do. (Just replace any number
with 9.99 and you'll see.) 

> Also, I don't see any difference between print "@sorted_cost\n"; and
> print "@sorted_cost";.  Both of these cause all the output to be printed
> on a single line, I thought that \n was supposed to be a line feed.

The \n _does_ output a newline. But if you only print one line, you may
not see the difference. :-)

Andre


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

Date: Mon, 21 Sep 1998 20:11:00 GMT
From: George Reese <borg@imaginary.com>
Subject: Re: Perl & Java - differences and uses
Message-Id: <opyN1.1207$Ge.3737871@ptah.visi.com>

In comp.lang.java.programmer John Porter <jdporter@min.net> wrote:
: Jonathan Abbey wrote:
:> 
:> In article <360026F0.136F6AD@min.net>, John Porter  <jdporter@min.net> wrote:
:> | > Java is pure OO.
:> |
:> | No, not really.  One glaring example is that intrinsic data types
:> | are not classes like user-defined classes.  Arrays, for example,
:> | can only hold intrinsic data types.  That's one of the reasons
:> | they had to invent the Vector class.
:> 
:> That turns out (*cough*) not to be the case.  In Java, arrays can
:> indeed be defined to hold intrinsics, but they can also be defined to
:> hold instances of any defined type of object.
:> 
:> Vectors are there to provide dynamically sizable arrays, to allow
:> deletions in the middle, to provide a bunch of methods for finding
:> elements, performing enumerations, etc.
:> 
:> One thing Vectors can't do is hold unwrapped intrinsics.  Vectors can
:> only deal with objects.

: So I got it a little backwards. :-)

: My point is essentially the same; intrinsic data types are not
: full-fledged classes.  Working with them is not done in an OO style,
: unlike in Smalltalk.

Primitives are not in any way contrary to the OO paradigm.  That there
be no primitives in an OO environment is a silly construct of
misguided Smalltalk developers, not of anyone who is familiar with
what OO is at heart--something that has little to do with programming
languages.  OO is partially about the encapsulation of data, not the
elimination of it.

-- 
George Reese (borg@imaginary.com)       http://www.imaginary.com/~borg
PGP Key: http://www.imaginary.com/servlet/Finger?user=borg&verbose=yes
   "Keep Ted Turner and his goddamned Crayolas away from my movie."
			    -Orson Welles


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

Date: Mon, 21 Sep 1998 20:12:10 GMT
From: George Reese <borg@imaginary.com>
Subject: Re: Perl & Java - differences and uses
Message-Id: <uqyN1.1208$Ge.3737871@ptah.visi.com>

In comp.lang.java.programmer John Porter <jdporter@min.net> wrote:
: George Reese wrote:
:> 
:> In comp.lang.java.programmer Patricia Shanahan <pats@acm.org> wrote:
:> : When it comes to programming language selection I believe in keeping a
:> : good stable and picking the horse for the course.
:> 
:> Where have I argued contrary to this?  The point goes back to perl v
:> python.  When you have that in your bag of tricks in a structured
:> language, why bother with a second that does just the same thing?

: Interesting to note how your arguments have evolved from
: "Perl is so far beneath Python" to "One is as good as the other,
: so why bother with two".

I advise you to go back and take a remedial reading comprehension
class.  I have never argued anything of the sort of "Perl is so far
beneath Python".  You just made that up.

-- 
George Reese (borg@imaginary.com)       http://www.imaginary.com/~borg
PGP Key: http://www.imaginary.com/servlet/Finger?user=borg&verbose=yes
   "Keep Ted Turner and his goddamned Crayolas away from my movie."
			    -Orson Welles


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

Date: Mon, 21 Sep 1998 16:26:43 -0400
From: John Porter <jdporter@min.net>
Subject: Re: Perl & Java - differences and uses
Message-Id: <3606B683.2640764@min.net>

George Reese wrote:
> 
> Is a barrage of insults commonly accepted in comp.lang.perl.misc as a proper
> form of argumentation?

No one has done as much harm to your reputation as you have done
yourself.


> Trust me, perl programmers are not my potential
> employers or coworkers.

Oh, you're leaving the industry?  I wish you had said so sooner,
I would have cut you a lot more slack.


> If the OO-ness of perl is any measure of your OO expertise, I do fear
> greatly.

Fortunately it's not.  Many people have found Perl a comfortable and
productive language to work in, despite having used other, more
restrictive languages in the past.


> You and Uri just keep repeating the mantra that I think OO is for everything
> in spite of the fact that I have repeatedly stated that is not the case.

No, you have consistently stated that it *IS* the case, as support
for the notion that Python is "therefore" superior to Perl.

If OO is not for everything (as you now appear to be admitting),
then languages which support both OO and non-OO programming are more
broadly useful than languages which support only OO programming.


> You mean once I do what I have been doing for years, something I am a
> recognized expert in?  Damn!

"AcmeSoft, a recognized leader in real-time client-server solutions,
is proud to announce the availability of their new product..."


> And this would be why I would not hire you.

Guess you thought that makes a nice argument after all, eh?

-- 
John "Many Jars" Porter


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

Date: Mon, 21 Sep 1998 16:21:27 -0500
From: "George Reese" <borg@imaginary.com>
Subject: Re: Perl & Java - differences and uses
Message-Id: <srzN1.1226$Ge.3790805@ptah.visi.com>


Abigail wrote in message <6u5sve$otj$4@client3.news.psi.net>...
>George Reese (borg@imaginary.com) wrote on MDCCCXLVII September MCMXCIII
>in <URL: news:kQjN1.1068$Ge.3259462@ptah.visi.com>:
>++
>++ Jesus Christ, I posted a hastily drawn together set of steps which
>++ clearly were not an algorithm (not even by the definition I posted)
>++ and you take it as an opportunity to make a personal attack on me.
>
>
>Maybe you shouldn't answer a question that asks for an example of
>an algorithm with something that isn't an algorithm.


Let me get this straight.  It is MY fault that he is making personal insults
against me because I made an honest mistake?

--
George Reese (borg@imaginary.com)       http://www.imaginary.com/~borg
PGP Key: http://www.imaginary.com/servlet/Finger?user=borg&verbose=yes
   "Keep Ted Turner and his goddamned Crayolas away from my movie"
       -Orson Welles





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

Date: Mon, 21 Sep 1998 16:23:23 -0500
From: "George Reese" <borg@imaginary.com>
Subject: Re: Perl & Java - differences and uses
Message-Id: <gtzN1.1227$Ge.3792430@ptah.visi.com>

I agree 100% with this summary.  I appreciate your 'good sportsmanship' with
respect to being right on the issue, contrasted with the several people who
have felt that my mistake is cause for endless personal attacks.

Patricia Shanahan wrote in message <36066375.4426A4EC@acm.org>...
>*Whenever there is a practical algorithm, or a practical and effective
>heuristic, for performing a programming task it stops being something
>programmers should be doing normally, and moves into the domain of
>things software tools can and should do.*
>
>By a "practical algorithm" I mean a procedure that is mindless,
>platform neutral, reproducible, certain to be effective and that can
>be carried out in reasonable space and time - excluding e.g.
>algorithms with O(n!) execution time where real world problems have
>large values of n. Such algorithms cannot be realistically applied by
>humans or computers - though computers can typically use them for much
>larger problems than humans can.
>
>By a "heuristic" I mean a procedure that is like an algorithm in being
>mindless and platform neutral, but that may not be reproducible and is
>not certain to be effective. By a "practical heuristic" I mean one
>that can be executed in reasonable space and time. By "effective" for
>a heuristic I mean one that does the job mindlessly about as well as a
>competent person applying normal skill and judgement can be expected
>to do routinely - similar probability of producing a solution of at
>least similar quality.
>
>An "effective heuristic" may not do as well as an unusually skilled
>expert giving particular attention to a critical instance. An example
>of this is modern compiler code optimization techniques, which do at
>least as well as a typical programmer churning out large quantities of
>assembly language code, but are not certain to do as well as an expert
>with detailed understanding of the target processor hand tuning a
>really critical piece of code.

--
George Reese (borg@imaginary.com)       http://www.imaginary.com/~borg
PGP Key: http://www.imaginary.com/servlet/Finger?user=borg&verbose=yes
   "Keep Ted Turner and his goddamned Crayolas away from my movie"
       -Orson Welles





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

Date: Mon, 21 Sep 1998 21:25:24 GMT
From: rick@marinweb.com (Rick Freeman)
Subject: Perl: Right Tool for the Job?
Message-Id: <3607c164.24684806@nntp2.ba.best.com>

Hi all,

I need to write indexing and search scripts for a set of xml
documents.  It needs to handle at least 20k documents, about 8k in
size, on average.  I'm wondering if I should use Perl and the
following general approach:

The index would be a DB style hash.  Each pair would have the word as
the key, and the identifiers of the documents containing the word in
it's value.  Searching would, obviously, check the hash for a list of
all the documents with that word.

Pretty straight forward.  But I'm wondering if it will scale up to the
quantity of documents I need to handle.  It's accessed via cgi, so it
can't take 45 seconds to run.  (Indexing can be done on a regular
basis in the background, so speed isn't as important there.)

So, am I crazy thinking of trying to do this with a Perl script?

Rick

M a r i n W e b

Marin's Home on the World Wide Web
http://www.marinweb.com/

98 Main Street #453
Tiburon CA 94920
415-458-3201


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

Date: Mon, 21 Sep 1998 20:58:36 GMT
From: alastair@calliope.demon.co.uk (Alastair)
Subject: Re: PerlMagick & linux
Message-Id: <slrn70dj75.4q.alastair@calliope.demon.co.uk>

Enrique Terrazas <terrazas@labmed.ucsf.edu> wrote:
>
>cc -c -I../magick -I/usr/local/include/magick -I/usr/X11R6/include
>-Dbool=char -DHAS_BOOL -I/usr/loc
>al/include -O2    -DVERSION=\"1.45\" -DXS_VERSION=\"1.45\" -fpic
>-I/usr/lib/perl5/i386-linux/5.00404
>/CORE  Magick.c
>Magick.xs:15: magick.h: No such file or directory
>make: *** [Magick.o] Error 1
>
>Is magick.h supposed to be installed with ImageMagick?  If so, it doesn't
>seem to be installed on my machine. 

It's probably around somewhere - if not, you're stuck. Try and find it and copy
it to /usr/local/include (or wherever). Then try compiling again.

-- 

Alastair
work  : alastair@psoft.co.uk
home  : alastair@calliope.demon.co.uk


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

Date: 21 Sep 1998 12:18:21 -0700
From: Brad Murray <murrayb@vansel.alcatel.com>
Subject: Re: Problem with Splits on blank lines
Message-Id: <uyard2s1u.fsf@vansel.alcatel.com>

Carlos Corzo <r26878@email.sps.mot.com> writes:

> I have a string which contains blank spaces between the information
> in the line.
> 
> I would like to split the line to create a list containing all of the
> strings which were separated by blanks, then I will reverse the list
> and pop the first element off the list to get rid of the first string
> and then reverse the list again.  After this I will join the remaining
> list back to create a new string.

How about this instead, if you just want a list without the first
element:

$line = <DATA>;
($crap,@stringlist) = split ' ', $line;
print "@stringlist";

__DATA__
TheDogRan       Over the mountain


-- 
Brad Murray        "The secret of joy in work is contained in one
Software Analyst    word: excellence. To know how to do something well
Alcatel Canada      is to enjoy it."           Pearl S. Buck


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

Date: Mon, 21 Sep 1998 21:02:37 GMT
From: alastair@calliope.demon.co.uk (Alastair)
Subject: Re: Problem with Splits on blank lines
Message-Id: <slrn70djel.4q.alastair@calliope.demon.co.uk>

Carlos Corzo <r26878@email.sps.mot.com> wrote:
>Hello,
>
>I have a string which contains blank spaces between the information in the line.
>

[SNIP]

>Example:
>
>TheDogRan       Over the mountain
>
>I want to create a list of
>
>("TheDogRan", "Over", "the", "mountain")

What about ;

#!/usr/bin/perl -w

my $string = "TheDogRan       Over the mountain";

my @words = split / +/,$string;

foreach (@words) {
  print "word : ",$_,"\n";
}


-- 

Alastair
work  : alastair@psoft.co.uk
home  : alastair@calliope.demon.co.uk


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

Date: Mon, 21 Sep 1998 18:03:47 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: Problem with Splits on blank lines
Message-Id: <comdog-ya02408000R2109981803470001@news.panix.com>
Keywords: from just another new york perl hacker

In article <uyard2s1u.fsf@vansel.alcatel.com>, Brad Murray <murrayb@vansel.alcatel.com> posted:

>Carlos Corzo <r26878@email.sps.mot.com> writes:

>> I would like to split the line to create a list containing all of the
>> strings which were separated by blanks, then I will reverse the list
>> and pop the first element off the list to get rid of the first string
>> and then reverse the list again.  

see the shift() function so you can avoid the reverse()s!

but this seems preferable:

>$line = <DATA>;
>($crap,@stringlist) = split ' ', $line;

or similarly:

   (undef, @list) = ...

-- 
brian d foy                                  <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers needs volunteers! <URL:http://www.pm.org/to-do.html>


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

Date: Mon, 21 Sep 1998 14:17:33 -0700
From: Kenneth Hunt <kchunt@mail.hac.com>
Subject: problems using "use", HELP!
Message-Id: <3606C26D.7E228F3D@mail.hac.com>

I'm new so be kind. I'm trying to us a module and I declare it like
this:

	#!/usr/local/bin/perl
	#
	#	test.cgi: template for automatic HTML generation
	#

	use CGI qw(:standard);

and I get this error when I run "perl -w test.cgi":

	"use" may clash with future reserved word at test.cgi line 6.
	syntax error in file test.cgi at line 6, next 2 tokens "use CGI"
	Execution of test.cgi aborted due to compilation errors.

What am I doing wrong?
-- 


------------------------------------------------------
Kenneth Hunt
SC S12 V321 Rm. C233
office:	364-7755	pager:	715-0600
------------------------------------------------------


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

Date: Mon, 21 Sep 1998 16:13:21 -0400
From: "Robert F. Soto" <rfs@castillian.com>
Subject: until problem
Message-Id: <3606B361.CD1BE6E5@castillian.com>

Can anyone tell me why this does not work:

until (chomp($s = <STDIN>) eq 'q') {print("$s\n");}

When $s eq 'q' it still prints.


Tnks in advance,

Robert





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

Date: Mon, 21 Sep 1998 15:56:35 -0500
From: Eric Von Zee <evonzee@tritechnet.com>
Subject: Re: until problem
Message-Id: <3606BD83.17552A81@tritechnet.com>

I may be wrong (I am yet a newbie), but...

Doesn't $s = <stdin> return a 1?

So, it would seem that you are comparing 1 and 'q'....

What if you made it a few lines....

until ($s eq 'q') {
$s = chomp (<STDIN>);
print("$s\n") unless ($s eq 'q');
}

Robert F. Soto wrote:

> Can anyone tell me why this does not work:
>
> until (chomp($s = <STDIN>) eq 'q') {print("$s\n");}
>
> When $s eq 'q' it still prints.
>
> Tnks in advance,
>
> Robert

--
Best Regards,
Tritech Marketing Inc.

Eric Von Zee
Webmaster




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

Date: Mon, 21 Sep 1998 16:06:32 -0500
From: James Ludlow <ludlow@us.ibm.com>
Subject: Re: until problem
Message-Id: <3606BFD8.4E53E45@us.ibm.com>

Robert F. Soto wrote:
> 
> Can anyone tell me why this does not work:
> 
> until (chomp($s = <STDIN>) eq 'q') {print("$s\n");}
> 
> When $s eq 'q' it still prints.

It doesn't work like you think it does because chomp doesn't return the
string that it works on.  So even if $s eq 'q', chomp($s) will never eq
'q'.

Check the return value of chomp; you'll see that you've basically been
using:  until (0 eq 'q') { ... }

-- 
James Ludlow (ludlow@us.ibm.com)
Disclaimer: This isn't technical support, and all opinions are my own.


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

Date: Mon, 21 Sep 1998 16:07:50 -0500
From: Andrew Johnson <ajohnson@gpu.srv.ualberta.ca>
Subject: Re: until problem
Message-Id: <3606C026.618AB03B@gpu.srv.ualberta.ca>

Robert F. Soto wrote:
> 
> Can anyone tell me why this does not work:
> 
> until (chomp($s = <STDIN>) eq 'q') {print("$s\n");}
> 
> When $s eq 'q' it still prints.

because it is not testing whether $s eq 'q', it
is testing whether the result of the chomp operation
is equal to 'q' ... see 'perldoc -f chomp' for what
chomp() returns, try:

until(chomp($s=<STDIN>) && $s eq 'q'){print "$s\n"}

hope it helps
regards
andrew


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

Date: Mon, 21 Sep 1998 20:37:25 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: where is Date::Parse?
Message-Id: <slrn70de85.o6k.adelton@aisa.fi.muni.cz>

On 21 Sep 1998 16:39:47 GMT, Abigail <abigail@fnx.com> wrote:
> 
> It's just a plain stupid and dumb piece of code. To frustrating
> to work with. 

Why don't you just offer patches? Or have you got a complete new
piece of code that allows at least the same functions as CPAN.pm
does?

-- 
------------------------------------------------------------------------
 Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
                   I can take or leave it if I please
------------------------------------------------------------------------


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

Date: 21 Sep 1998 20:49:17 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: where is Date::Parse?
Message-Id: <6u6e4d$3jt$1@client3.news.psi.net>

Greg Bacon (gbacon@itsc.uah.edu) wrote on MDCCCXLVII September MCMXCIII
in <URL: news:6u6a60$ptk$2@info.uah.edu>:
++ In article <6u5vgj$q3h$2@client3.news.psi.net>,
++ 	abigail@fnx.com (Abigail) writes:
++ : It's just a plain stupid and dumb piece of code. To frustrating
++ : to work with. 
++ 
++ This is not my experience.  Could you elaborate?


When Net::FTP isn't available, it will whine and complain, try ftp
(fail - without indicating why), try lynx (fail - without indicating
why) then try ftp again, lynx again, etc. 

Of course, outside of CPAN, both ftp and lynx work like a charm.

Is it a good idea to have CPAN in the default installation, but
not having Net::FTP in there? 


I'v had installations where Net::FTP was the first method of choice,
but it CPAN would always start of with lynx. Fail, due to not handling
a firewall properly. It couldn't be told not to use lynx, untill
the configuration file was edited.


Often, if a module needs compiling, compiling and/or linking will
fail. CPAN doesn't detect that; untill it runs test. (If there are no
tests, it will happily install broken modules). Only then it fails. If
you fix whatever needs to be fixed, and try to install it again, it'll
skip the "make" part, as it thinks it already did that. You have to use
"force".


It won't discover dependancies untill "make test".
"Checking to see if your kit is complete" (well, that's from perl Makefile.PL)
always thinks your kit is complete. But it won't discover dependencies.


perl -MCPAN -eshell uses bold and underline by default.


It's a piece of crapware.



Abigail
-- 
sub _'_{$_'_=~s/$a/$_/}map{$$_=$Z++}Y,a..z,A..X;*{($_::_=sprintf+q=%X==>"$A$Y".
"$b$r$T$u")=~s~0~O~g;map+_::_,U=>T=>L=>$Z;$_::_}=*_;sub _{print+/.*::(.*)/s}
*_'_=*{chr($b*$e)};*__=*{chr(1<<$e)};
_::_(r(e(k(c(a(H(__(l(r(e(P(__(r(e(h(t(o(n(a(__(t(us(J())))))))))))))))))))))))


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

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

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