[10107] in Perl-Users-Digest
Perl-Users Digest, Issue: 3700 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Sep 12 12:07:22 1998
Date: Sat, 12 Sep 98 09:00:24 -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 Sat, 12 Sep 1998 Volume: 8 Number: 3700
Today's topics:
"my" vs "local"? hup@my-dejanews.com
Re: "my" vs "local"? (Michael Rubenstein)
Re: CGI.pm's HTML shortcuts (Jonathan Stowe)
Re: Change NT IP Address Using Perl (Jonathan Stowe)
Re: Comments on my Code? (Jonathan Stowe)
Re: csv (Jonathan Stowe)
Re: Embedded Perl? (Jonathan Stowe)
Re: fast/minimal server load CGI script (Jonathan Stowe)
Re: Financial Art, FAQ and un-cut money (Jonathan Stowe)
Re: forking in Win32 (Jonathan Stowe)
Re: Getting diagnostic messages with Solaris and perl5. (Jonathan Stowe)
Re: how to ask .cgi ? (Jonathan Stowe)
Re: How to do the background work in NT system !? (Jonathan Stowe)
Re: Incrementing a Multi-dimensional Hash Array (Jonathan Stowe)
Re: Learning perl (Jonathan Stowe)
Re: Mem info (Jonathan Stowe)
Re: newsgroups (Jonathan Stowe)
Re: NT Error levels (Jonathan Stowe)
Re: PDF ?? INTERPRETER ?? (Jonathan Stowe)
Re: Perl & Java - differences and uses <borg@imaginary.com>
Re: Perl & Java - differences and uses (David Formosa)
Re: Perl gurus opinion needed. <buchwald@dircon.co.uk>
Re: processing the Drop Down Menu (form part) using Per (Jonathan Stowe)
Re: read() but how? (Jonathan Stowe)
Re: Regular Expression - substitution from lower to upp (Gregory Spath)
Re: Retrieve file from PC using LWP::UserAgent? (Jonathan Stowe)
Re: script to compose html pages based on ip/user (Jonathan Stowe)
Re: socket accept() vs. CGI.pm accept() (Jonathan Stowe)
Re: This Website (slocomputers) was HACKED by United Ha (Jonathan Stowe)
Re: Using perl to write a passwd program... (Jonathan Stowe)
Re: warning: accept failed (Protocol error) (Jonathan Stowe)
Re: What is Robot in Perl? (Jonathan Stowe)
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 12 Sep 1998 14:01:36 GMT
From: hup@my-dejanews.com
Subject: "my" vs "local"?
Message-Id: <6tdus0$gmc$1@nnrp1.dejanews.com>
Hi,
I am not very clear about the main difference between "my" and "local".
Could somebody please explain to me why it give me difference output in code
below?
# perl -v
This is perl, version 5.004_04 built for i586-linux
---Begin----
#!/usr/bin/perl
my %test1 =(
"a" => "A",
"b" => "B",
);
local %test2 =(
"aa" => "AA",
);
$mytest1 = "test1";
$mytest2 = "test2";
print ${$mytest1}{'a'} ,"\n";
print ${$mytest2}{'aa'} ,"\n";
print $test1{'b'},"\n";
---End----
The output result I get is:
AA
B
I just don't understand why "${$mytest1}{'a'}" don't print out any result?
----------------------------------------------------------------------
AddALL is a book searching and price comparison meta search engine.
The free service find books and compare prices among 18 bookstores.
Please visit http://www.addall.com to save your Time and Money.
-- Chai-Hup Chen hup@addall.com --------------------------------------
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Sat, 12 Sep 1998 15:36:26 GMT
From: miker3@ix.netcom.com (Michael Rubenstein)
Subject: Re: "my" vs "local"?
Message-Id: <35fb9389.254899646@nntp.ix.netcom.com>
On Sat, 12 Sep 1998 14:01:36 GMT, hup@my-dejanews.com wrote:
>Hi,
> I am not very clear about the main difference between "my" and "local".
> Could somebody please explain to me why it give me difference output in code
>below?
>
># perl -v
>This is perl, version 5.004_04 built for i586-linux
>
>---Begin----
>#!/usr/bin/perl
>my %test1 =(
> "a" => "A",
> "b" => "B",
>);
>
>local %test2 =(
> "aa" => "AA",
>);
>
>$mytest1 = "test1";
>$mytest2 = "test2";
>
>print ${$mytest1}{'a'} ,"\n";
>print ${$mytest2}{'aa'} ,"\n";
>print $test1{'b'},"\n";
>---End----
>The output result I get is:
>
>AA
>B
>
>I just don't understand why "${$mytest1}{'a'}" don't print out any result?
You're using symbolic references. These are very powerful, but can
lead to unexpected results if you're not careful; you've run into one
of them. The documentation (perlref) explains and gives an
appropriate example:
Only package variables are visible to symbolic references.
Lexical variables (declared with my()) aren't in a symbol
table, and thus are invisible to this mechanism [symbolic
references]. For example:
local($value) = 10;
$ref = \$value;
{
my $value = 20;
print $$ref;
}
This will still print 10, not 20. Remember that local()
affects package variables, which are all ``global'' to the
package.
--
Michael M Rubenstein
------------------------------
Date: Sat, 12 Sep 1998 14:29:23 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: CGI.pm's HTML shortcuts
Message-Id: <35fa6538.60054171@news.btinternet.com>
On Fri, 11 Sep 1998 19:47:28 GMT, Jay Bartelt wrote :
>I almost hate to ask this question, but...
>
>Somebody in my group asked me for a list of HTML shortcuts created by
>Lincoln in his CGI.pm module. I assumed a list would be in the CGI
>doc but I don't see it. Is there a list somewhere? Searching CPAN
>for a piece of documentation is sometimes like separating a specific
>grain of sand from the beach
>
Just for fun of course you could try this little bit of code:
#!perl
#
use CGI;
foreach $hash (sort keys %CGI::EXPORT_TAGS)
{
print $hash,"\n";
for ( @{$CGI::EXPORT_TAGS{$hash}})
{
print "\t",$_,"\n";
}
}
that will give a comprehensive list of all tokens exported for each
name - and of course it gives what is in the version you are running.
of course you could just have looked at CGI.pm but thats not so much
fun is it.
/J\
--
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: Sat, 12 Sep 1998 14:29:20 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Change NT IP Address Using Perl
Message-Id: <35fa4586.52996198@news.btinternet.com>
On 10 Sep 1998 23:33:38 GMT, Gregory Spath wrote :
>
>Cool.
>
>Can you do this in windows95 too? I have a laptop that has different
>network setting depending on whether I'm on my home lan or at work.
>What keys should I look for? I'll be doing it with object rexx, not
>perl, so I don't need the perl functions.
Rexx, Rexx ? I would recommend comp.lang.rexx then buddy. ;-}
/J\
--
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: Sat, 12 Sep 1998 15:43:08 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Comments on my Code?
Message-Id: <35fa93c6.70036899@news.btinternet.com>
On Sat, 12 Sep 1998 02:05:36 -0400, Ronald J Kimball wrote :
>Scratchie <upsetter@ziplink.net> wrote:
>
>> I recently wrote a command-line mass-mailing utility. I would like to post
>> the code here and invite (contructive) comments and criticism. Anyone who
>> assumes that this is going to be used for spam will be roundly ignored.
>
>Pray tell, what is it going to be used for?
>
I must admit that I once wrote a Bulk mail script at work for the
purposes of sending the instructions on how to use the e-mail software
to all our users after rolling mail out. Of course that was pretty
logic impaired really wasnt it.
I also would like to know what this is going to be used for if not
spam.
/J\
--
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: Sat, 12 Sep 1998 15:43:03 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: csv
Message-Id: <35fa8fd5.69102955@news.btinternet.com>
On Fri, 11 Sep 1998 10:22:30 -0400, Gopal wrote :
>I want to write a cgi program that will put the .csv extension on the
>downloaded file
>for example when you write a cgi program as:-
>###########
>print "Contenet-type:text/ascii\n\n";
>it will allow you to save the file but if the
>cgi program is called say tmp.cgi then the file extension will be
>tmp.cgi but
>here i want to save it as .csv how do I do it.
>###########
>q.)What should be the content-type for
>a .csv file?
>
This is not really a Perl question at all - the question and the
answer would be the same whatever language you have used for your
program.
There are some links in the URL in my .sig that you might find useful
in finding answers to CGI problems.
/J\
--
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: Sat, 12 Sep 1998 15:42:52 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Embedded Perl?
Message-Id: <35fa8a98.67761741@news.btinternet.com>
On Fri, 11 Sep 1998 21:38:30 +0200, David Suarez de Lis wrote :
>Hi all,
>
>I was wondering if it's possible to embedd Perl into other languages and
>how (specially for Win32 platform). I have finally managed to convince my
>maganer that it can be The Right Thing To Do instead of relaying
>completely on other tools (guess, VB, VC++...)
>
>Any hints, help, info, docs, whatever really appreciated,
>
Check out the perlembed documentation.
/J\
--
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: Sat, 12 Sep 1998 14:29:36 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: fast/minimal server load CGI script
Message-Id: <35fa7aa3.64324260@news.btinternet.com>
On Sat, 12 Sep 1998 07:21:31 GMT, Jerrad Pierce wrote :
>firstly, I know speed and load are relatively inversely proportional...
>
>which would be better?
>
>a) trying the perl "compiler"
>
>b) "precompiling" the script? (dumping the kernel or something?)
>
You most probably wont find that either of these solutions will render
any great improvement in performance. Depending which platform/HTTP
server you are running on you might find that an embeded Perl type
thing such as mod_perl for Apache will enhance performace to a greater
extent and with other benefits acruing from the fact that for instance
mod_perl allows you to do far more than simple CGI does. I have some
experience of ISAPI Perl also but have never felt that lives up to the
expectations - but of course that is on the accursed IIS.
/J\
--
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: Sat, 12 Sep 1998 15:42:50 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Financial Art, FAQ and un-cut money
Message-Id: <35fa896f.67479372@news.btinternet.com>
On 11 Sep 1998 18:57:39 GMT, rgmmuwxt@usacurrency.com wrote :
><HTML>
><HEAD>
><TITLE></TITLE>
></HEAD>
><BODY>
><SCRIPT LANGUAGE="LiveScript">
>window.location.href="http://www.usacurrency.com";
></SCRIPT>
></BODY>
></HTML>
There's no use hiding behind uuencode, its still HTML in a plain text
forum, its still spam and whats the point anyhow it would only work
for those useless imitations of newsreaders that come with certain
popular web browsers anyway.
/J\
--
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: Sat, 12 Sep 1998 14:29:15 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: forking in Win32
Message-Id: <35fa40b5.51763407@news.btinternet.com>
On Thu, 10 Sep 1998 16:32:51 -0500, David Rosholt wrote :
>What is the equivalent of the Unix fork command for Win32, and how do I use
>it?
>
There is no real equivalent at all (unless you are using a cygwin32
Perl that emulates fork). The nearest equivalent is
<mumble>Win32::CreateProcess</mumble> which behaves in an entirely
different way - I would consult the Win32:: modules documentation for
more.
/J\
--
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: Sat, 12 Sep 1998 15:42:59 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Getting diagnostic messages with Solaris and perl5.004_04
Message-Id: <35fa8efe.68888143@news.btinternet.com>
On Fri, 11 Sep 1998 06:34:10 GMT, Tim Potter wrote :
>Hi everyone. I've been working on a perl script and all of a sudden I
>am now getting diagnostic messages (Chapter 9 in the camel book).
>
>The first one was "Bizarre copy of ARRAY in leave at /dev/fd/4 line
>1146." after writing a bit of Perl to replace a list of group id
>numbers with their names using getgrgid() and just recently "Bad
>free() ignored at /dev/fd/4 line 229." The diag messages occur at
>perfectly valid code (unfortunately I trashed the group id code
>fragment and the bad free occurs at an assignment statement )-:).
>
>The only weird thing I have done recently is install a whole lot of
>recommended and security patches on the Solaris 2.5.1 machine that the
>script is running on.
>
I would suggest re-compiling Perl. It might be that the patches have
affected libraries that Perl uses.
/J\
--
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: Sat, 12 Sep 1998 14:29:22 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: how to ask .cgi ?
Message-Id: <35fa5c46.58810998@news.btinternet.com>
On Fri, 11 Sep 1998 16:23:45 GMT, fmalo@my-dejanews.com wrote :
>hi!
>
>My question is very simple :
>
>how to program a script that send a request to a CGI-form ?
>
Most folk around here would advocate the use of the libwww-perl (LWP)
suite of modules available from CPAN. They are well documented with
plenty of example code in lwp-cook.pod.
/J\
--
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: Sat, 12 Sep 1998 14:29:27 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: How to do the background work in NT system !?
Message-Id: <35fa67c7.60656039@news.btinternet.com>
On Fri, 11 Sep 1998 20:58:42 GMT, James Bond 098 wrote :
>hmm......
>In Unix we can do some background work?
>but on NT system can we do it ?------------------------1
>
>which command in Perl can do that ?<---------------2
>
>I'd written some commnad like
>
>while(true){print "a"}
>
>
there is no "true" in Perl. This was beaten to do death in a thread a
short while ago.
you can write the while with no expression or with an expression that
will always be evaluated as "true" i.e:
while()
{
...
}
or
while(1)
{
...
}
alternatively you can use the degenerate form of for
for(;;)
{
...
}
On certain platforms if you are print out in the loop the output may
not show immediately unless you set the special variable $| (aka
$OUTPUT_AUTOFLUSH) .
/J\
--
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: Sat, 12 Sep 1998 14:29:25 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Incrementing a Multi-dimensional Hash Array
Message-Id: <35fa6652.60336265@news.btinternet.com>
On Fri, 11 Sep 1998 14:57:26 -0700, Larry Rosler wrote :
>[Posted to comp.lang.perl.misc and a copy mailed.]
>
>In article <35F983AE.657E@mgic.com> on Fri, 11 Sep 1998 15:10:22 -0500,
>Kevin Skelton <kevin_skelton@mgic.com> says...
>> Hi, I have a file of user-id's and reports they have accessed.
>>
>> user1,report1
>> user1,report1
>> user1,report8
>> user2,report3
>> user2,report8
>> etc....
>>
>> I would like to create a report in Perl that would show me the users and
>> the number of times they have accessed any given report.
>>
>> I know that I can increment a single hash array like this:
>>
>> While (<FILE>) {
>> ($userid,$reportid) = split(/,/);
>> $total{$userid}++;
>> }
>>
>> This would give me the total number of times a given user accessed ANY
>> report. But how do I create a multi-dimensional array and print off the
>> totals for a given user for each report?
>>
>> $total{$userid}{$report}++;
>> does not work.
>
>Why not? Maybe you forgot to chomp the $reportid.
>
>#!/usr/local/bin/perl -w
>use strict;
>
>my %total;
>
>while (<DATA>) {
> chomp;
> my ($userid, $reportid) = split /,/;
> $total{$userid}{$reportid}++;
>}
>
>my $userid;
>foreach $userid (sort keys %total) {
> foreach (sort keys %{$total{$userid}}) {
> print "$userid,$_: $total{$userid}{$_}\n";
> }
>}
>__END__
>user1,report1
>user1,report1
>user1,report8
>user2,report3
>user2,report8
>
>Output:
>
>user1,report1: 2
>user1,report8: 1
>user2,report3: 1
>user2,report8: 1
>
Its funny when you think of it - evryone goes around incanting
TIMTOWTDI yet three people post virtually identical pieces of code ;-}
Even funnier that I cant think of more than way to do it.
/J\
--
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: Sat, 12 Sep 1998 14:29:31 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Learning perl
Message-Id: <35fa6d5a.61896465@news.btinternet.com>
On Fri, 11 Sep 1998 23:50:30 GMT, nguyen.van@imvi.bls.com wrote :
>Hi guys,
>
>I just started perl and seen a lot of perl modules out there, but I'm
>confused which ones to use, and there are no samples for these modules. Can
>you guys help me out?
>
I dont know what do you want to do ?
This is a bit like walking into B&Q and seeing all of these tools and
bits of pipe and electrical stuff and wood and garden furniture and
asking the assistant what he thinks you should get.
The modules list on CPAN is categorized by function so given some idea
of what you hope to achieve this would be a good starting point. Most
modules do have good documentation and many of them have example code
with them too.
There is a document perlmodlib that comes with Perl that has
information on the Standard modules an d the categories of other
modules available.
/J\
--
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: Sat, 12 Sep 1998 15:42:56 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Mem info
Message-Id: <35fa8db4.68558208@news.btinternet.com>
On Thu, 10 Sep 1998 13:21:18 -0700, rajan wrote :
>Hi ,
>
> Is there a perl function which can tell u about
> the physical memory on the system on which it is
> executing ..
>
There is no Perl function to do this - that's not to say it can't be
done, it just depends on what system you are running and then some.
/J\
--
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: Sat, 12 Sep 1998 14:29:34 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: newsgroups
Message-Id: <35fa7922.63938741@news.btinternet.com>
On Fri, 11 Sep 1998 23:49:58 -0400, Daniel Caraway wrote :
>How many newsgroups deal with cgi or perl and where can I find them?
Well you found one ;-}
there is a comp.lang.perl.* hierarchy which comprise several groups of
which this is one.
There is a a single comp.infosystems.www.authoring.cgi group -
although there may be others lurking in some other hierarchy
unbeknownst to me.
You should probably check out news.answers and news.announce.newusers
whilst you are at it in order to minimize any faux pas as regards
etiquette around these places.
And before you post anything read the docs, read the faq, search
dejanews and then ask yourself again if you really need to post that
question.
/J\
--
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: Sat, 12 Sep 1998 14:29:32 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: NT Error levels
Message-Id: <35fa731f.63220487@news.btinternet.com>
On 12 Sep 1998 03:19:45 GMT, Danilo Reyes wrote :
>Can you please let me know how can i implement the following error checking
>using perl:
> if %errorlevel% == 0
>Thanks
>
If as I assume you intend to be running external programs from with a
Perl script and then check the success or failure of these then what
you should be using is the special variable $? - which gives the
return code of the last exec'd program.
e.g.
system('dir thing');
print $?; # 256 assuming no 'thing'
# 0 if thing exists
The actual return value from a program is ($? >> 8) of course.
On the other hand if you really want to get at the value of ERRORLEVEL
I havent got a clue because it doesnt seem to be available to the
environment in any generally accepted fashion - but there again I only
a few cursory tests on this.
/J\
--
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: Sat, 12 Sep 1998 15:43:06 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: PDF ?? INTERPRETER ??
Message-Id: <35fa9355.69924578@news.btinternet.com>
On 11 Sep 1998 15:59:19 GMT, RCIGROUP wrote :
>does anybody know if there is some way to have a perl script read a pdf file?
>I have a script that protects html files, but i also want to protect pdfs. When
>the script tries to open the file all i get is some garbled text. Any idea's!
>Andy rcigroup@aol.com
Check out <URL:http://www.geocities.com/CapeCanaveral/Hangar/4794/>
These guys were proposing something of the sort - I havent got time to
check it out myself so sorry if its a wild goose chase.
/J\
--
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: Sat, 12 Sep 1998 15:09:32 GMT
From: George Reese <borg@imaginary.com>
Subject: Re: Perl & Java - differences and uses
Message-Id: <M8wK1.1090$E9.3845649@ptah.visi.com>
In comp.lang.java.programmer David Adler <dha@panix.com> wrote:
: On Fri, 11 Sep 1998 17:12:10 GMT, George Reese <borg@imaginary.com> wrote:
:>Perl IS NOT OO. It just added some OO constructs as an
:>afterthought.
: Hmm... Since, if I recall correctly, Perl 5 was rewritten from the
: ground up and included references/objects, this seems a bit off.
: Just thought you'd all want to know. :-)
The binary to support the language may have been written from the
ground up, but the semantics were tacked on to the existing language.
The inclusion of things called references/objects does not make a
language OO.
--
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: 13 Sep 1998 01:17:33 +1000
From: dformosa@zeta.org.au (David Formosa)
Subject: Re: Perl & Java - differences and uses
Message-Id: <6te3ad$2iq$1@godzilla.zeta.org.au>
In <LNeK1.958$E9.3226998@ptah.visi.com> George Reese <borg@imaginary.com> writes:
>In comp.lang.java.programmer Matt Knecht <hex@voicenet.com> wrote:
[...]
>: To maintain it, though, you did need a good understanding of the
>: language. Without that, forget it.
>C is hard to maintain beyond memory issues (and perl still has memory
>issues, as does python or Java--just with perl it takes more talent to
>construct your apps so that the memory issues are not so important).
How do you get a segfualt or a memory leek from within Perl? In C
you just have to sneeze and you end up pointing to invalid memory.
But in perl there is no way due to the nature of the language to cause this
to occour.
[...]
>To your objection that computers are complex I have to laugh.
>Computer languages are infinitely simpler than human languages. They
>are designed to enable a human to express their desires in a format
>understandable by simple minded computers--yes, computers are very
>simple minded, they are not at all complex.
But I don't wish to express simple idears, I wish to express quite
complex idears. So it seems natural that I should use a languge that
mirrors that complextity.
[...]
>It applies bizarre meanings to things that have very different
>meanings in other contexts.
So do natural languges. But while thay are infinitely inconsitent that
are what you would expect.
> Furthermore, perl enables about a million different ways of doing the
>very same thing.
Since peaple can never aggry on which is the best way to do something,
why should we forcably limmit them to one model or anthour?
------------------------------
Date: Sat, 12 Sep 1998 12:51:29 +0100
From: "Peter Buchwald" <buchwald@dircon.co.uk>
Subject: Re: Perl gurus opinion needed.
Message-Id: <35fa6420.0@newsread1.dircon.co.uk>
>`Computer hacker' may be a matter for speculation, but `hack writer'
>is not. `Hack writer' is derived from `hackney' (== cab) and not from
>`hack' (== hoe, cut up) regarless of whether you would categorize it
>that way or not.
The OED has one sense of the word hackney as being "one who does mean work
for hire"(1784). The word "hackneyed"(1749) also comes from this.
--
PAB
http://www.buchwald.dircon.co.uk/
------------------------------
Date: Sat, 12 Sep 1998 15:43:09 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: processing the Drop Down Menu (form part) using Perl script
Message-Id: <35fa94eb.70329924@news.btinternet.com>
On Sat, 12 Sep 1998 04:12:49 +0100, Michael Yevdokimov wrote :
>Hello!
>
>Can anybody tell me how to process the currect item of drop-down menu box
>from <form>...</form> properly and write it to file? May be you send me any
>example?
>
Read the documentation for CGI.pm and the sundry resources listed in
my signature - also I posted an example piece of code last week which
can be found at:
http://x5.dejanews.com/getdoc.xp?AN=388140908&CONTEXT=905614423.1459355729&hitnum=1
(Just to follow LR's example of course)
/J\
--
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: Sat, 12 Sep 1998 14:29:37 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: read() but how?
Message-Id: <35fa7cd8.64888779@news.btinternet.com>
On 12 Sep 1998 07:21:41 GMT, Park wrote :
>I trying much time for using read(). But. I can't.
>
>I want get data from next.....
>
>0123456789 <== ABC.TXT
> |___|
> |
> $abc
>
>I tried..
>open(ABC, "ABC.TXT");
>read(ABC, bc, 5, 2);
>print $abc;
>
>
>c:\>perl test.cgi
> 01234
>c:\>
>
>How can I get '12345' from data file?
>
Assuming that you simply want to extract five characters from a line
starting with the second character then you probably want to do
something like:
open(ABC,"ABC.TXT") || die "Cant open - $!\n";
while(<ABC>)
{
print substr($_,1,5),"\n";
}
In your example I think you are confused about the purpose of the
OFFSET argument:
An OFFSET may be specified to place the read data
at some other place than the beginning of the string.
So in other words your read(ABC, $abc, 5, 2) will place the five
characters read from the file into the scalar starting at the third
position in the string. i.e. you will get two spaces at the beginning
of the string (OFFSET is zero based).
I think what you are trying to achieve could be expressed something
like this:
#!perl
seek DATA,1,1;
read(DATA,$test,5);
print $test;
__END__
01234567
Although of course this has very little utility in multiline data -
read the perlfunc entry for seek().
/J\
--
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: 12 Sep 1998 13:55:25 GMT
From: gspath@NOSPAM.epix.net (Gregory Spath)
Subject: Re: Regular Expression - substitution from lower to upper case...how?
Message-Id: <z2H2FGLjexoj-pn2-qx1mxHOY0b7S@hobbes.epix.net>
On Thu, 10 Sep 1998 23:06:19, gabor@vmunix.com (Gabor) wrote:
> In comp.lang.perl.misc, Jules <julius@clara.net> wrote :
> # Dear all, please tell me how I could use the substitution expression to
> # convert all lowercase characters to uppercase? I tried \U\E pair but won't
> # work. My program is as follows:
>
> You've several options.
>
> tr/a-z/A-Z/;
>
> $_ = uc $_;
>
> s/(.+)/\U$1/;
You missed one:
$_ = "\U$_"; (basically your third option, makes more sense to me
this way)
------------------------------
Date: Sat, 12 Sep 1998 15:42:48 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Retrieve file from PC using LWP::UserAgent?
Message-Id: <35fa8689.66762106@news.btinternet.com>
On Fri, 11 Sep 1998 14:11:17 -0400, Vince Hendricks wrote :
>Hi,
>
> I have a web based form that allows a user to save a file onto the
>web server's local disk as part of a large database application. The
>web server (Apache 1.3.1) is running on a Sun Ultra 10 with Solaris 2.6.
>
> I am currently stumped on how exactly to retrieve files off of PCs
>and/or Macs and other un*x file systems. I have been going through all
>the FAQs and documentation and just can't seem to find this particular
>scenario. My latest stab at the problem was to use LWP::UserAgent with
>the following code, but it was unsuccessful for retrieving a file off of
>a PC running Win95. Any ideas on where I can find a reference or a
>module to do this?
>
> Note: The following works fine when getting a file off of the same
>unix file system.
>
<snip code>
ER, yes it would work fine to obatin a file from the local filesytems
- think what happens when you type file:C:\windows\win.ini into the
Location box (or whatever) of a browser on a PC - it is obtaining the
file from the local filesystem.
To achieve what you are trying to do you would need to have an HTTP
server of some sort running on each of the client PCs and the file
required be in the servers directory somewhere then you would have:
my $req = HTTP::Request->new(GET => "http://$filelocation");
where $filelocation is relative to the HTTP servers root.
There are free HTTP servers available for the PC and I presusme for
the Mac also.
This is already getting out of Perl country though.
/J\
--
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: Sat, 12 Sep 1998 15:43:05 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: script to compose html pages based on ip/user
Message-Id: <35fa90f7.69392080@news.btinternet.com>
On Fri, 11 Sep 1998 09:38:57 -0500, John Guillory wrote :
<snip>
>
>I also need to check more closely the CGI.pm module--I just learned about
>this yesterday. That's how new I am to this.
>
I tell you what - after you have read the documentation for CGI.pm and
have garnered a few ideas about the implementation of your design -
and tried some out, then come back to us with any problems you might
be having with the code. As it stands I for one am at a loss as to
what more to say. I dont mean to be unhelpful but what you are trying
to do is pretty specific and I dont think that anyone is going to post
any code without seeing your attempt first (although I will probably
be proved wrong).
/J\
--
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: Sat, 12 Sep 1998 14:29:13 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: socket accept() vs. CGI.pm accept()
Message-Id: <35fa3f4a.51400297@news.btinternet.com>
On Thu, 10 Sep 1998 14:25:17 -0700, Scott Harper wrote :
>I am having a problem with a CGI program that also has to interface with
>sockets. The problem is that CGI.pm has a routine called accept that seems
>to be conflicting with the sockets routine by the same name. Has anybody
>seen this? Am I doing something wrong? I know that I can just not import the
>:cgi function set into my main namespace and avoid the problem, but that
>means that I have to explicitly call out the package name for all the
>functions in the :cgi function set, which is less than ideal. I was hoping
>that someone had a more elegant solution.
>
For myself I actually prefer to use the full OO apparoach with CGI as
I find it clearer to see what is going on - I find nothing inelegeant
in:
use CGI;
my $query = new CGI;
print $query->header;
...
etc
Although admittedly there is a disincentive to use the HTML producing
methods a great deal then as you wind up with more typing (possibly)
thena actually typing the HTML tags - but swings and roundabouts.
/J\
--
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: Sat, 12 Sep 1998 15:42:57 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: This Website (slocomputers) was HACKED by United Hackers HQ
Message-Id: <35fa8e36.68688436@news.btinternet.com>
On Fri, 11 Sep 1998 03:39:22 GMT, sa@dcsammae.fun wrote :
>
>This Website was HACKED by United Hackers HQ
>
>http://www.slocomputers.com/sandra/
>
>kabooom!!!!!!! dont joke with us anymore
>
>
How very clever of you - I hope you cleaned the mess off your mummy's
furniture afterwards.
Or am I missing something here and this was really a sophisticated
piece of spam - after all we all had a look didn't we?
/J\
--
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: Sat, 12 Sep 1998 14:29:16 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Using perl to write a passwd program...
Message-Id: <35fa42b6.52276241@news.btinternet.com>
On Fri, 11 Sep 1998 12:07:19 -0500, Stefan Adams wrote :
>About writing a perl passwd script. I have already written all the
>functions to crypt the password and to throw out bad passwords and do random
>passwords. However, my problem is updating the /etc/passwd file. One way
>that I have been doing it is opening /etc/passwd and making the change with
>in a foreach $line (@line) {} of the OPEN(/etc/passwd) This works fine for
>root. But note how the distributed passwd written in C program can be run
>by any user to update the password for that user only. The way that I have
>done it will only let root make changes because no other users have access
>to /etc/passwd. How can I possibly get around this while leaving the
>permissions of /etc/passwd set to -rwxr--r-- since the C passwd can make
>changes with these permissions?
>
You will need to make your script setuid - with the usual caveats
check the perlsec manpage for more on them. In order to prevent users
from changing other peoples passwords you will have to check the real
user id of the user running the program (that is available from the $<
special variable) indeed if the user is not root then you probably
want to ignore any username argument and just proceed to change the
password for the user. The first edition of "Programming Perl" had an
example passwd program which went much further to prevent abuse than I
have outlined - I dont know if the source is available anywhere
though.
/J\
--
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: Sat, 12 Sep 1998 15:43:00 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: warning: accept failed (Protocol error)
Message-Id: <35fa8f5c.68982284@news.btinternet.com>
On Fri, 11 Sep 1998 13:11:16 +0200, Maen Suleiman wrote :
>Hi guys ..
>i am running a Netscape Fasttrack 2.01 server .. recently i am getting
>this error :
>
>[11/Sep/1998:12:56:09] warning: accept failed (Protocol error)
>
>when calling a cgi script written in perl by more than a one client ! ..
>the script is about 770 lines ! and it seems working without any
>problems before .. and when one client call it !! .. but when two
>clients call it in the same time ( automaticlly loads ) it gives the
>above error .. any onw have an idea of thre problem ..
>i will be gratefull for any help
>thanx in advance
>
Without an example piece of code I would have to put this down to a
server configuration problem. Does your script use sockets ? Other
than that I cannot see any problem that would belong to Perl (and even
then perhaps not).
/J\
--
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: Sat, 12 Sep 1998 14:29:28 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: What is Robot in Perl?
Message-Id: <35fa6a15.61183209@news.btinternet.com>
On Fri, 11 Sep 1998 20:58:46 GMT, James Bond 098 wrote :
>"Robot", i've encountered this word many time in Perl, what does it's
>means. etc. Robot Rules .... something like that!
Robot has no special significance in Perl. The Robots to which I
assume you are referring are programs of the webcrawler variety which
search and index the Web of course these can be written in any
language - but are indeed commonly written in Perl as Perl offers many
facilities to do this sort of thing easily. The robot rules that you
will most probably seen in the context of Perl is the WWW:RobotRules
module that is part of the LWP package - this is part of an
implementation of the "Robot Exclusion Standard" which is designed to
give Webmasters control over what parts of a website a robot can visit
- this is documented in
<URL:http://info.webcrawler.com/mak/projects/robots/norobots.html>
. You should check out the docunmentation for WWW:RobotRules and
LWP::RobotUA - if you dont have the LWP package available it can be
had from CPAN.
/J\
--
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
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 3700
**************************************