[9164] in Perl-Users-Digest
Perl-Users Digest, Issue: 2782 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jun 1 20:07:24 1998
Date: Mon, 1 Jun 98 17:00:30 -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, 1 Jun 1998 Volume: 8 Number: 2782
Today's topics:
Re: A Email to WWW GaTeWaY, is there such a Thing? (Earl Hood)
Re: Any kind of help is hard to find. (Michael Dori)
Re: Any kind of help is hard to find. (Michael Dori)
Bug in NET::FTP or am I just stupid? <broom@voicenet.com>
Re: Counter or Pause function in Perl? (Martien Verbruggen)
Re: file output and modules (Jonathan Stowe)
Re: HELP ME PLEASE! (Martien Verbruggen)
Re: Help with Error message (Jonathan Stowe)
Re: Help with Error message (Charles DeRykus)
Re: Help with Error message <rootbeer@teleport.com>
Re: Help with pipes, bidirectional communication (Martien Verbruggen)
How do you send .htaccess username and pass? <alcazar@netcomp.net>
How to avoid CGI and OPEN3 interactions??? Bobd@my-dejanews.com
Re: How to avoid CGI and OPEN3 interactions??? <rootbeer@teleport.com>
Re: How to get exit code in Win32/UNIX (Jonathan Stowe)
Re: How to Get Index if given a value in the array??? (Mike Stok)
Re: How to Get Index if given a value in the array??? (Larry Rosler)
Re: How to Get Index if given a value in the array??? (Martien Verbruggen)
Re: LABOR CRISIS: Perl SW Guru NEEDED MA Intranet Start (Earl Hood)
Mirror 2.9 - Now Available <lmjm@icparc.ic.ac.uk>
Re: More Perlish file size (bytes, KB, MB) (Larry Rosler)
Re: Need some helps from Perl experts (Martien Verbruggen)
Re: new to OO Perl <zenin@bawdycaste.org>
Re: Perl class for newbie? <rootbeer@teleport.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 1 Jun 1998 23:28:10 GMT
From: ehood@geneva.acs.uci.edu (Earl Hood)
Subject: Re: A Email to WWW GaTeWaY, is there such a Thing?
Message-Id: <6kvdea$gvg@news.service.uci.edu>
[ courtesy cc to the mhonarc mailing list]
In article <35741de3.362727078@news.teleport.com>,
Tim Roberts <timr@probo.com> wrote:
>f95pegr@granis.hemmet.s-hem.chalmers.se (Peter Granroth) wrote:
>>on Wed, 27 May 1998 21:21:08 -0500, Igor shared with us:
>>> If you know where I can find email-to-www gateway (a-la Hotmail) so that
>>> I could read email from my Web Browser via HTTP, please email me.
>>May I ask, why would you like to do that????
>I'll give you a scenario. My primary mail server is at my own office.
>However, I do a fair amount of work at client locations, where they have
>firewalls of various kinds.
>There are several ways I can read my mail from the client's location. I
>can telnet into our server and run the Linux mail command; however, for
>some reason, access through the telnet proxy servers appears to be in
>permanent molasses mode. I often have a one MINUTE delay for a command to
>respond. Plus, the Linux mail we use doesn't have a "more" option, so I
>can only see the last 50 lines of each message. However, the http proxy is
>quite responsive.
>So, I telnet in, fire off the MHonArc package which converts my mail file
>to html pages, logout, and pop up a web browser to actually read the mail.
>Much nicer.
Another approach is to automate the conversion process as mail comes in
(either via cron or .forward) with MHonArc (to avoid the telnet). For
example, when you know you'll be away, you can set up the job to keep
an archive the last X number of messages (X being a number to your
liking).
If using Apache, you can have the archive in a location that is
protected via a local .htaccess/.htpasswd to prevent wandering users
reading your mail. This way you can do secure checking of your mail
via the web while you are away to see if anything important has arrived
that needs your attention.
--ewh
P.S. This nifty little idea was suggested to me from a friend during
a personal conversation awhile back (as a solution to a related problem).
P.P.S. Since this is comp.lang.perl.misc, I should not forget to
mention that MHonArc is written in Perl.
<URL:http://www.oac.uci.edu/indiv/ehood/mhonarc.html>
--
Earl Hood | University of California: Irvine
ehood@medusa.acs.uci.edu | Electronic Loiterer
http://www.oac.uci.edu/indiv/ehood/ | Dabbler of SGML/WWW/Perl/MIME
------------------------------
Date: Mon, 01 Jun 1998 21:07:05 GMT
From: michaeldore@hotmail.com (Michael Dori)
Subject: Re: Any kind of help is hard to find.
Message-Id: <3571de77.12706826@news.nacs.net>
On Sun, 31 May 1998 21:57:05 GMT, r.tsch@octave2.ch (Rene Tschannen)
wrote:
>On Sun, 31 May 1998 19:37:33 GMT, michaeldore@hotmail.com (Michael
>Dori) wrote:
>>[snip]
>>I do not know if this
>>clique-ish attitude is intended or not, but it makes obtaining
>>information from experienced users a bit like pulling teeth with
>>tweesers from a wolverine that has not had his morning coffee.
>>
>>I know that my opinion will probably
>>not garner me any assistance on the previous issue that i have posted
>>re: help on an algorith for a search engine for my site, but i hope
>>that i speak for more than one new person who has asked a question,
>>been snided at or given cryptic or sar-caustic remarks, and never
>>returned to this or any other group because of lack of support.
>
>I was looking at the posting you mentioned - as a newbie I can't give
>you the desired assistance - but to me it seems you're expecting a
>lot. Maybe you can present your problems in smaller chunks? If I scan
>through the questions here, almost every posting is answered if there
>is some code provided related to the tasks you want to master, or if
>someone asks for help with a specific function.
I am not looking for an answer, but input in terms of the type ... it
is more efficient to do it this way ... etcetera ...
>
>And what's about the answer from Jonathan Stowe? I'm learning a lot
>from hints like his - but afterwards I have to figure out things for
>my own to put things together.
>
>I just can't imagine that anyone here would assign a lack of
>intelligence to you if I see the very detailed and structured style of
>your posting. (This is not meant sarcastically!!!) Why can't you just
>go ahead with your capabilities and use them to read the docs and
>FAQ's - and then experiment with code?
i am experimenting with code, and am almost complete, but the fact
remains that all i was looking for was suggestions, not caustic
nitpicking ...
>
>>I thought that programmers stuck together, supported each other, and
>>helped when they could. Hmmm ... maybe i was wrong there ...
>>
>
>I hope you're not wrong here, and that some programmers will stuck to
>you and support you, but probably anyone won't give you the whole
>piece at once ... did you find this in other news groups? For me this
>news group is a place to get high quality knowledge - try this in an
>M$ Access group as a comparison! (That's not a curse ... I don't wish
>to anyone to have to work with M$ Access :-) ... )
>
>The meaning of communication lies in the answers we get - kicking the
>door of an ivory tower will probably not result in the answers you
>wish - at least not very often, I think. Try another approach to make
>them speak to you - you even don't need to love them or become one of
>them for this to happen ... but consider, there is nobody around here
>I suppose who is willing to let their teeth pulled out from you with
>tweezers, even if you're offering gallons of coffee or harder stuff to
>them in advance ... ;-)
>
>Good luck!
>
>Rene
I appreciate the comment ..... truly ...
Michael Dori
michaeldore@hotmail.com
------------------------------
Date: Mon, 01 Jun 1998 21:05:52 GMT
From: michaeldore@hotmail.com (Michael Dori)
Subject: Re: Any kind of help is hard to find.
Message-Id: <35731779.79507273@news.nacs.net>
On Mon, 01 Jun 1998 09:56:16 +0100, "F.Quednau"
<quednauf@nortel.co.uk> wrote:
>There we go again (Imagine hard Hip Hop beats spiced up with the sound of
>my hardDisk when NT4 is leaking all over the place again):
>
>
>Michael Dori wrote:
>
>> I have noticed that all the help that is proffered on most questions,
>> especially from new users, is usually returned in the form of "LOOK IT
>> UP".
>
>I find it amazing that people's experiences can differ so widely when
>dealing with the same group. But then Newsgroups are just an (useful)
>extension of society, and therefore everyone perceives the services
>provided, etc. completely different. Also quite redundant to discuss
>about. So a solution would be to say, e.g. "I still can't manage to embed
>Perl in my toaster, however I LOOKED into the FAQ..." A potential replier
>would then KNOW that you looked for it, and, if that person already
>embedded Perl into the toaster (he / she? are there any shes? surely
>already did), will most certainly help you (That's the feeling I've got
>in this newsgroups anyway)...So I suppose that in future I will state
>myself which resources I already used.
Then maybe i should have posted my algoritm help message as a RFC? ...
Thanks, truly, for the input ...
Miek Dori
michaeldore@hotmail.com
------------------------------
Date: Mon, 01 Jun 1998 23:53:20 GMT
From: Barry Roomberg <broom@voicenet.com>
Subject: Bug in NET::FTP or am I just stupid?
Message-Id: <35730641.B03305FF@voicenet.com>
Problem:
It seems that NET::FTP put(fd,up_file) does
not recognize the output of a pipe as a file
descriptor.
Error:
**************************************************************
Cannot open Local file UNCOMPRESS: No such file or directory
at ./unc_put.pl line 83
**************************************************************
After being given the following bit of code:
**************************************************************
&status("Starting uncompress");
open (UNCOMPRESS, "uncompress < $from|") ||
&my_die("Could not start uncompress for file [$from]:[$!]");
&status("Starting upload");
if (! $ftp->put(UNCOMPRESS, $to)){
&my_die("Could not ftp-put file [$to]:[$@][$!]");
}
**************************************************************
I ran a loop reading the output from the pipe and it works
fine. How do I tell put() that it is REALLY a fd, and
not a file?
------------------------------
Date: 1 Jun 1998 23:07:59 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Counter or Pause function in Perl?
Message-Id: <6kvc8f$u3$4@comdyn.comdyn.com.au>
In article <3572cfa7.0@news1.ibm.net>,
"rickr" <rickr@mail.net> writes:
> Is there a counter or pause function built into Perl? I am currently
> achieving the pause effect by using
# perldoc -f sleep
And to prevent your next question:
# perldoc perlfaq8
/How can I sleep() or alarm() for under a second?
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | That's not a lie, it's a terminological
Commercial Dynamics Pty. Ltd. | inexactitude.
NSW, Australia |
------------------------------
Date: Mon, 01 Jun 1998 23:02:05 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: file output and modules
Message-Id: <35732f79.9780384@news.btinternet.com>
On Mon, 01 Jun 1998 06:57:22 GMT, Jonathan Stowe wrote :
>open(MAIL" | /usr/bin/mail") || die;
>
>print MAIL, "this is a test";
>
No wonder I had a headache this morning. That should of course be:
open(MAIL," | /usr/bin/mail") || die;
print MAIL "this is a test";
You guys must have had a weekend like mine to have missed that.
/J\
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: 1 Jun 1998 23:14:04 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: HELP ME PLEASE!
Message-Id: <6kvcjs$u3$5@comdyn.comdyn.com.au>
Please read the following information on how to choose a good subject
line:
http://www.perl.com/CPAN/authors/Dean_Roehrich/subjects.post
In article <3573188E.F48B2637@wpo.iupui.edu>,
Elopez <elopez@wpo.iupui.edu> writes:
> <HTML>
Please don't post in HTML. Usenet is a plain text medium. People who
don't use crippled newsreaders that come with web browsers won't be
able to read your message in a relaxed way. Normally I would stop
here, but I'm feeling generous today.
> <P><B>My question is this:</B> What could I write/Include to the script
> so it can avoid including on the search resutls the HTML pages that are
> named as ("left_pagename.html" or "header_pagename.html" , and "body_pagename.html"?
Apart from the fact that I really don't understand what exactly your
asking here, it smells like a HTML question, not a perl question.
The perl aspect is simple: If you don't want it to appear, then don't
print it.
Are you asking how you can send output to different frames? That's a
html/cgi question. This is a perl newsgroup. The CGI and HTML
newsgroups can be found in the comp.infosystems.www.* hierarchy.
> <P>Please help me with this, I don't know any PERL.
Then maybe you should let someone else work on the script. Seriously.
Or first learn the language, then program. Make sure you know which
functionality is Perl, which is CGI, and which is HTML.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | The gene pool could use a little
Commercial Dynamics Pty. Ltd. | chlorine.
NSW, Australia |
------------------------------
Date: Mon, 01 Jun 1998 22:09:46 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Help with Error message
Message-Id: <35732257.6450776@news.btinternet.com>
On Mon, 01 Jun 1998 11:25:30 -0700, Matthew Genesi wrote :
>Im trying to learn perl and do not understand the following error
>message. After getting this message the program still runs and seems to
>work.
>
>value of <HANDLE> construct can be "0"; test with defined() at ./test.pl
>line 65535
>
>Can someone tell me what this error message means?
>
I can cut and post a bit from the perldiag manpage (perldoc)
Value of %s can be "0"; test with defined()
(W) In a conditional expression, you used <HANDLE>, <*>
(glob), `each()', or `readdir()' as a boolean value. Each of
these constructs can return a value of "0"; that would make
the conditional expression false, which is probably not what
you intended. When using these constructs in conditional
expressions, test their values with the `defined' operator.
Post back a snippet of code if you cant see round this.
/J\
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: Mon, 1 Jun 1998 22:11:07 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Help with Error message
Message-Id: <Etw8AJ.L56@news.boeing.com>
In article <3572F21A.41C6@sierratel.com>,
Matthew Genesi <mattge@sierratel.com> wrote:
>Im trying to learn perl and do not understand the following error
>message. After getting this message the program still runs and seems to
>work.
>
>value of <HANDLE> construct can be "0"; test with defined() at ./test.pl
>line 65535
>
>Can someone tell me what this error message means?
>
>Matt
Try this:
(echo foo; echo "0"|tr -d '\12') | perl -e 'print $l while defined($l=<>)'
which prints both lines: -> foo
-> 0
Now leave off the "defined":
(echo foo; echo "0"|tr -d '\12') | perl -e 'print $l while $l=<>'
which now prints only: -> foo
So, you lose the last line because "0" evaluates to false;
whereas, defined("0") evaluates to true and saves the day.
A bare <> as in while (<>) will also work.
If you say "use diagnostics" at the top of your script, you'll
get the following explanation:
(W) In a conditional expression, you used <HANDLE>, <*> (glob), each(),
or readdir() as a boolean value. Each of these constructs can return a
value of "0"; that would make the conditional expression false, which is
probably not what you intended. When using these constructs in conditional
expressions, test their values with the defined operator
HTH,
--
Charles DeRykus
------------------------------
Date: Mon, 01 Jun 1998 22:59:04 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Help with Error message
Message-Id: <Pine.GSO.3.96.980601155408.15370W-100000@user2.teleport.com>
On Mon, 1 Jun 1998, Larry Rosler wrote:
> For historical reasons, the warning doesn't appear if the implicit
> assignment to $_ is used:
>
> while (<HANDLE>) { .. }
Well, it may by historical, but the real reason is that the warning isn't
needed there: That code is semantically equivalent to this:
while (defined($_ = <HANDLE>)) { ... }
That is to say, the defined() call is already there, so no warning is
necessary.
In a future version of Perl, in fact, the defined() call will be implied
when the conditional of a while is a simple assignment from a line input
operator to a scalar. So, in the future, this will neither need nor cause
a warning:
while ($line = <HANDLE>) { ... }
For this, you can thank Larry. Thanks, Larry! (The other one, that is. :-)
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 1 Jun 1998 22:56:56 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Help with pipes, bidirectional communication
Message-Id: <6kvbjo$u3$2@comdyn.comdyn.com.au>
In article <6kts8a$7qs@bgtnsc02.worldnet.att.net>,
revok@aol.com (John Sandstrom) writes:
> I'm also curious why this program creates a huge file called
> decode.core.
Hmm. It looks like your decode program dumped core for some reason.
Try removeing that core image, and rerunning the perl script. If the
core file re-appears, then you know for certain that it is caused by
the decode program running in the perl script. I can't tell you why it
does that from the perl script and not from the command line, but it
might be a slight bug in IPC::Open2?
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au |
Commercial Dynamics Pty. Ltd. | What's another word for Thesaurus?
NSW, Australia |
------------------------------
Date: Mon, 1 Jun 1998 15:56:48 -0500
From: "Ric Alcazar" <alcazar@netcomp.net>
Subject: How do you send .htaccess username and pass?
Message-Id: <uuzJK$Zj9GA.235@upnetnews05>
Hello,
I'm trying to run an authorization script for a section of my website.
I've created a script which prompts user for login and password (and if
correct) sends them on to another page within my website. Unfortunately...
this does not provide as much security as I like. (A user could simply just
enter the URL of the page and get sent right there.) I've, therefore,
implemented a server authentication (.htaccess) to protect those documents.
This bring up another piece to my puzzle. Now the user has to
authenticate twice (once for my script and again for the server) to get to
the page. I'd like for the user only to have to authenticate once. Is
there anyway that I can pass the username and password from my perl script
to the server authentication? This would help to solve the dilemma of
having to enter your login and password twice. Please help!
Ric.
------------------------------
Date: Mon, 01 Jun 1998 21:49:21 GMT
From: Bobd@my-dejanews.com
Subject: How to avoid CGI and OPEN3 interactions???
Message-Id: <6kv7l1$4q2$1@nnrp1.dejanews.com>
Maybe I missed something... But I've noticed some strange behavior that I
cannot easily explain...
I've written some CGI scripts using CGI that need to dispatch various commands
for wich I'm interasted in getting both STDERR and STDOUT from. I decided to
use "open3" because it splits STDOUT and STDERR for me, and all I have to do
is close the child's Standard input and waitpid...
The problem is this... Somehow, if there is a CGI object arround, when I do
the open3 it generates a new header somehow. This causes unwanted text to
appear at the beginning of my document, which is quite unacceptable...
I've got arround the problem by *not* doing the "$query = new CGI;" until all
the open3 calls are done and that seems to help, but I'm still a bit confused
as to why this would happen and how I really should avoid it in the future...
Anybody got any ideas?
Thanks,
-= bob =-
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: Mon, 01 Jun 1998 22:53:41 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: How to avoid CGI and OPEN3 interactions???
Message-Id: <Pine.GSO.3.96.980601155233.15370V-100000@user2.teleport.com>
On Mon, 1 Jun 1998 Bobd@my-dejanews.com wrote:
> I decided to
> use "open3" because it splits STDOUT and STDERR for me, and all I have to do
> is close the child's Standard input and waitpid...
>
> The problem is this... Somehow, if there is a CGI object arround, when I do
> the open3 it generates a new header somehow.
This sounds as if you have unflushed output at the time of the fork. Could
that be the case? Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Mon, 01 Jun 1998 22:09:45 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: How to get exit code in Win32/UNIX
Message-Id: <35731d63.5255608@news.btinternet.com>
On Mon, 1 Jun 1998 14:57:59 -0400, Brian J. Sayatovic wrote :
> I'm writing a script which I hope to have work on UNIX and NT. In this
>script, I execute a batch of processes and would like to have the script be
>aware of any horrible probelems with the porocesses, like a SEGV or
>DivByZero error. In UNIX, I've been told I can use the $?. I'm not too
>sure if this works in NT since I'm using Win32::Process::Create (as is used
>in the Win32 version open3 I'm using.)
>
<snip>
You probably will need to use
Win32:GetLastError
and
Win32::FormatMessage
to get a nice looking output.
/J\
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
------------------------------
Date: 1 Jun 1998 23:25:01 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: How to Get Index if given a value in the array???
Message-Id: <6kvd8d$hmf@news-central.tiac.net>
In article <35730669.97CC8349@io.com>, Todd A. Guillory <tag@io.com> wrote:
>I want to get the index if I'm given a value that occurs in an array (the
>opposite of the way it normally occurs).
>
>Is there a quicker way to do this in PERL than what I have below?
>
>For example, if the $input{'month'} is "April" I have to use a for loop to
>find that is index value 3. Is there a "PERL" way to do this?
>
>@months =
>("January","February","March","April","May","June","July","August","September","October","November","December");
>
>for ($index=0; $index <= (@months - 1); $index++ )
> {
> if ( $months[$index] eq $input{'month'} )
> {
> $monthnumber = $index + 1;
> } # end if
> } # end for
> }
It depends how often you do the lookup and whether you expect to find more
than one of the thing you're looking for.
One thing you can do is use last to get out of the if and the for loops
once you've found the thing you're interested in if you do this once in a
program.
undef $found;
for ($index = 0; $index <= $#months; $index++)
if ($months{$index} eq $input{'month'}) {
$found = $index;
last;
}
}
if (defined $found) {
...
}
If you do multiple lookups on an array containing unique items then it
might be worth using a hash to store month name -> index mappings
# initialise dictionary
@monthIndex{@months} = (0 .. $#months);
# later in the code
if (defined ($index = $monthIndex{$input{'month'}})) {
...
}
For more ideas you might consult section 4 of the FAQ, on a recent perl
system the command
perldoc perlfaq4
should get it, otherwise browse http://www.perl.com and look at the CPAN
links.
If you're getting months off a form then the Text::Abbrev module which
comes with perl might help perl help you help your users...
Hope this helps,
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@colltech.com | Collective Technologies (work)
------------------------------
Date: Mon, 1 Jun 1998 15:16:07 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: How to Get Index if given a value in the array???
Message-Id: <MPG.fdcc8079ef2a505989683@hplntx.hpl.hp.com>
In article <35730669.97CC8349@io.com>, tag@io.com says...
> I want to get the index if I'm given a value that occurs in an array (the
> opposite of the way it normally occurs).
>
> Is there a quicker way to do this in PERL than what I have below?
...
You can find hints in perlfaq4: How can I tell whether an array contains
a certain element?
Also, there was a discussion last month that you can find by power-
searching DejaNews: ~g compl.lang.perl.misc ~s index AND array.
--
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com
------------------------------
Date: 1 Jun 1998 23:29:14 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: How to Get Index if given a value in the array???
Message-Id: <6kvdga$u3$6@comdyn.comdyn.com.au>
In article <6kv3sk$e7s$1@malgudi.oar.net>,
"Brian J. Sayatovic" <bjs@iti-oh.com> writes:
> If you're going to do this only once, this seems like a good way. However,
> if you're going to be looking up multiple values in the array over-and-over,
> you should try implementing a hash of it. This will only work if the array
> contains unique values. Still, it should be faster since whatever search
> algorithm is used for the has is almost certainl faster than a linear
> search -- and faster since its running below perl instead of being
> interpreted:
This came up a little while ago. I suggested the same then, and even
did some benchmarking.
Do a search on www.dejanews.com
~g comp.lang.perl.misc & ~a Verbruggen & ~s Finding
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | 75% of the people make up 3/4 of the
Commercial Dynamics Pty. Ltd. | population.
NSW, Australia |
------------------------------
Date: 1 Jun 1998 23:11:35 GMT
From: ehood@geneva.acs.uci.edu (Earl Hood)
Subject: Re: LABOR CRISIS: Perl SW Guru NEEDED MA Intranet Start-up 80K+>+Equity
Message-Id: <6kvcf7$g9u@news.service.uci.edu>
In article <3573174E.1EBA@min.net>, John Porter <jdporter@min.net> wrote:
>Eric Bohlman wrote:
>> Ronald J Kimball <rjk@coos.dartmouth.edu> wrote:
>> If the supply remains low, certainly. But the alleged software labor
>> shortage is usually invoked to justify
>> 1) Relaxation of restrictions on hiring foreign nationals
>> and
>> 2) Increasing the number of CS graduates
>> Both of which would increase the supply of programmers who would be
>> willing to work for a low cost to the employer.
>But the whole point is why (and how) employers are justifying keeping
>wages low. If I were an employer, and that were my objective, I
>would be saying, "Sorry, I won't pay programmers any more than this,
>because there's a glut of programmers."
But that is not true statement, and people know it, so companies
cannot state it. Companies have to be more clever at it.
>But they're saying the
>opposite,
>so therefore that's not their objective.
And how does that prove it's not their objective. Even you say:
>It may be that the shortage is being exaggerated for political
>purposes, such as those you mentioned
In the age of downsizing, companies want the cheapest labor they can
get, even at the cost of product quality (since clever marketing has
been sufficient, for now, to sell products). Companies can still make
a profit if they increased wages, but it would not be as big as they
want it. What is the incentive for a company to hire good talent at
higher wages when they can still sell their products with lesser
talented people at lower wages?
There is a pool of potential employees out there. However, with
downsizing, many of those employees are very experienced. Hiring them
back into the work force would defeat the whole purpose of the
downsizing/cost-cutting movement. Therefore, the companies complain
that there is a lack of skill out there inorder to get political favor
to create an environment where lower wage workers can be hired (foreign
employees and recent college/vocational graduates).
Today, companies are working in the mode of what can give us the most
profit *now*. What can we do to satisfy our share holders *now*.
Starting to hire people at higher wages counters this, even though it
may be good policy in the long term. When company departments are
evaluated based upon the next quartely profit, they are very
apprehensive to perform any action that will cut into the profit (or
department managers may lose their jobs). It is uncommon to find
companies willing to make an investment (in employees) that may hurt
profits in the short-term, but pay-off in the long-term. We are in the
age of instant gratification.
What high-tech companies are stating is a partial truth. What is
probably more accurate is, "There is a shortage in the high-tech
skilled labor market at the wages we are willing to pay." They can
still make a profit, but not at the levels shareholders and execs
desire.
I have yet to experience this "shortage" of software/engineering labor.
--ewh
--
Earl Hood | University of California: Irvine
ehood@medusa.acs.uci.edu | Electronic Loiterer
http://www.oac.uci.edu/indiv/ehood/ | Dabbler of SGML/WWW/Perl/MIME
------------------------------
Date: Mon, 01 Jun 1998 13:42:55 +0000
From: Lee McLoughlin <lmjm@icparc.ic.ac.uk>
Subject: Mirror 2.9 - Now Available
Message-Id: <3572AFDF.819F9FE6@icparc.ic.ac.uk>
Mirror 2.9 is now available from:
http://sunsite.org.uk/packages/mirror/
ftp://sunsite.org.uk/packages/mirror/
For those of you who are not familiar with it:
Mirror was designed to duplicate a directory hierarchy between two
machines. It avoids copying files unnecessarily by comparing the file
time-stamps and file sizes before transferring.
The latest version is Mirror 2.9 which will run on Un*x, Wind*ws 95 and
Wind*ws NT. Its sole requirement is Perl 4, or better still, Perl 5.
--
Lee McLoughlin. Phone: +44 171 594 8388
IC-Parc, Imperial College, Fax: +44 171 594 8432
South Kensington, London. SW7 2AZ. UK. Email: lmjm@icparc.ic.ac.uk
------------------------------
Date: Mon, 1 Jun 1998 15:31:38 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: More Perlish file size (bytes, KB, MB)
Message-Id: <MPG.fdccba49da6a4f1989684@hplntx.hpl.hp.com>
In article <6kv4q7$qup@newshub.atmnet.net>, choleman@simpact.com says...
> This works but how about something more Perlish?
>
> my $s = -s "$MP1001__PARTS_DIR/HT-201/$_.html";
> if ($s < 500)
> {$thesize = "$s bytes";}
> elsif ($s < 500000)
> {$thesize = ($s/1000)." KB";}
> else
> {$thesize = ($s/1000000)." MB";}
As much C'ish as Perlish:
$thesize = $s < 500 ? "$s bytes" : $s < 500000 ? ($s/1000)." KB" :
($s/1000000)." MB";
You might consider shortening those fractions to a specified precision.
Use 'int' if you don't mind truncation, 'sprintf ...' if you prefer
rounding.
--
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com
------------------------------
Date: 1 Jun 1998 23:03:52 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Need some helps from Perl experts
Message-Id: <6kvc0o$u3$3@comdyn.comdyn.com.au>
Please read the following information on how to choose a good subject
line:
http://www.perl.com/CPAN/authors/Dean_Roehrich/subjects.post
In article <3572A4A9.DBF0FDF0@forfree.at>,
Seman Bajau <wat@forfree.at> writes:
> This is a multi-part message in MIME format.
> --------------E552187F8E161D2D7538D3E2
Please don't do that. Usenet is a plain text medium. Encoded multipart
messages have no place here.
> I've downloaded free scripts from Selena Sol's archive. I already tried
> vainly to install the web calendar scripts but until now still not
> working. So anyone out there who already use the Selena Sol's web
If you have problems with specific scripts, you should contact the
author of the scripts.
have you tried reading the documentation that should come with the
scripts?
> calendar scripts and working, please give some ideas to me how to debug
> the scripts. I tried to implement it in UNIX platform. I used CERN web
The same way as you would debug any other CGI application.
If you have questions about CGI and perl, please consider the
following documentation:
Perl CGI FAQ and (no offense) Idiot's guide:
http://www.perl.com/CPAN/doc/FAQs/cgi/idiots-guide.html
http://www.perl.com/CPAN/doc/FAQs/cgi/perl-cgi-faq.html
Section 9 of the perl FAQ:
# perldoc perlfaq9
> I also attached the web calendar scripts downloaded from Selena Sol's
> archive that I've already made some modifications to the scripts so that
> you can pin-point my mistakes inside the scripts.
Do you really believe that I am going to decode whatever you attached,
and then run through hundreds or thousands of lines of code just to
humour you?
> Thank you for any suggestions and ideas contributed for making the
> scripts working.
I could send you an email with my consultancy ratings, after which you
could send me an international money order and the scripts. I will
then gladly do some work on them then.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au |
Commercial Dynamics Pty. Ltd. | Curiouser and curiouser, said Alice.
NSW, Australia |
------------------------------
Date: 1 Jun 1998 22:28:47 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: new to OO Perl
Message-Id: <896740552.122693@thrush.omix.com>
Larry Rosler <lr@hpl.hp.com> wrote:
: I hesitate to say YMMV, because relatively speaking it probably won't.
>snip<
Well, it does, a little. But in really odd ways depending on just
how one defineds the constant. I've always taken it for granted
that sub FOO { 1 } would be more or less the same as constant FOO =>
1, but it's not. Not by a long shot:
$ perl foo.pl
Benchmark: timing 524288 iterations of array, base, constant, constant_mod,
constant_sub, hash, variable...
array: 2 secs ( 0.00 usr 1.27 sys = 1.27 cpu)
base: 1 secs ( 0.00 usr 0.53 sys = 0.53 cpu)
constant: 1 secs ( 0.00 usr 1.27 sys = 1.27 cpu)
constant_mod: 1 secs ( 0.00 usr 1.26 sys = 1.26 cpu)
constant_sub: 10 secs ( 0.00 usr 9.00 sys = 9.00 cpu)<---WTF?
hash: 2 secs ( 0.00 usr 2.48 sys = 2.48 cpu)
variable: 3 secs ( 0.00 usr 2.03 sys = 2.03 cpu)
This is in direct opposition to what perlsub says about inlining
constant subs. It does show (as your example does) that in
modern perls a constant accessing an array takes about half the
time, just as long as you don't use sub EIGHT { 8 }...
With or with out the speed however, you do get the advantage of
compile time field name typo checking. -Use strict will catch
misspelled bare word field names at compile time, unlike hash
keys which often will never even warn at run time. The down
side is your name space is a mess...
#!/usr/local/bin/perl
use Benchmark;
@array = 0 .. 9;
%hash = ( NAME => 8 );
*EIGHT = sub () { 8 };
sub EIGHT_SUB { 8 };
use constant EIGHT_MOD => 8;
$eight = 8;
timethese (2 << 18, {
array => q{ $x = $array[8] },
constant => q{ $x = $array[EIGHT] },
constant_sub => q{ $x = $array[EIGHT_SUB] },
constant_mod => q{ $x = $array[EIGHT_MOD] },
variable => q{ $x = $array[$eight] },
hash => q{ $x = $hash{NAME} },
base => q{ $x = $x },
} );
__END__
--
-Zenin
zenin@archive.rhps.org
------------------------------
Date: Mon, 01 Jun 1998 22:39:00 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Perl class for newbie?
Message-Id: <Pine.GSO.3.96.980601153102.15370R-100000@user2.teleport.com>
On Mon, 1 Jun 1998, Dan Franco wrote:
> Can anyone recommend a good Perl course for a non programmer? Perhaps
> something that teaches the basics of Perl along with general
> programming concepts?
I don't recommend that. Perl is a very powerful, flexible language. Perl
lets you break the rules when you know better. But how can you know better
unless you first learn the rules?
A good introductory course on programming will teach you important
concepts which will make learning Perl easier and more useful in the long
run. For a first programming language, I usually recommend Pascal - not
because it's a great language that you'll want to use for everything, but
because it's generally taught at your local community college by
competent, patient instructors who will teach you how good programming is
done for a nominal fee.
> Please remove the DONTSPAM from my email address to reply to me.
Please remove the DONTSPAM from your email address to get email courtesy
copies of replies. :-)
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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". 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 2782
**************************************