[8610] in Perl-Users-Digest
Perl-Users Digest, Issue: 2227 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Apr 1 17:07:24 1998
Date: Wed, 1 Apr 98 14:00:33 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 1 Apr 1998 Volume: 8 Number: 2227
Today's topics:
Arrays are shared across Perl/C berrier <ni@aoe.vt.edu>
Re: Date manipulations? <pas@unh.edu>
File locking (Paul Neubauer)
foreach loop & current element index <afs101@psu.edu>
Re: foreach loop & current element index <Richard.Schofield@fmr.com>
Re: foreach loop & current element index <jdf@pobox.com>
Re: foreach loop & current element index <jdf@pobox.com>
Re: foreach loop & current element index <afs101@psu.edu>
gathering EMail address via CGI <Glenn.J.Schworak@state.or.us>
How can I replace from a list? <delegz@NOSPAM.rpi.edu>
How to pass user_name and password to each perl CGI scr <tsui@cbmi.upmc.edu>
Re: Identifying how a perl program was called <Glenn.J.Schworak@state.or.us>
Re: Is there a "Newsgroup" for Newbies to Perl? (Chris Vogel)
Re: Is there a "Newsgroup" for Newbies to Perl? smitty77@pacbell.net
Re: Is there a "Newsgroup" for Newbies to Perl? smitty77
Keyword Search Script? (Frank Vollono)
Keyword Searching a web page (Frank Vollono)
Overhead created by a lot of file access <andrew@boothman.easynet.co.uk>
Passing a list of lists to a function <viren@base4.com>
Re: Passing a list of lists to a function <jdf@pobox.com>
Re: Passing a list of lists to a function <cmargoli@world.northgrum.com>
Re: Passing a list of lists to a function <kapur@cbl.ncsu.edu>
Re: PERL Far Eastern Language Support <amr@nospam.miyako.japanologie.kultur.uni-tuebingen.de>
Problems building Perl 5.004_4 (Jerry L. Campbell)
Re: REQ: algorithm for DES::encrypt/decrypt of text str (Mike Stok)
Re: String Manipulation Question <jdf@pobox.com>
System() command questions <khnguyen@comp.uark.edu>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 01 Apr 1998 16:36:59 -0800
From: nisy <ni@aoe.vt.edu>
Subject: Arrays are shared across Perl/C berrier
Message-Id: <3522DDAA.47637784@aoe.vt.edu>
How to make arrays shared across the berrier of Perl-->C and C-->Perl
when C routines are called from Perl in NT ? Thanks.
------------------------------
Date: 1 Apr 1998 19:46:28 GMT
From: Paul A Sand <pas@unh.edu>
Subject: Re: Date manipulations?
Message-Id: <6fu5ik$pkb@mozz.unh.edu>
On 30 Mar 1998 23:39:40 GMT, Burt Lewis <burt@ici.net> wrote:
>>I need to determine 2 dates based on today's date.
>>
>>The first date I need to know is the prior Saturday and the
>>second date I need is the subsequent Saturday.
The Date::Manip stuff from CPAN makes this pretty easy:
#!/usr/bin/perl
use Date::Manip;
$prevsat = &Date_GetPrev("today", "Sat", 0);
$nextsat = &Date_GetNext("today", "Sat", 0);
print "Last Saturday was ", &UnixDate($prevsat, "%D"), "\n";
print "Next Saturday is ", &UnixDate($nextsat, "%D"), "\n";
Consider this a small ad for Date::Manip from a happy user.
--
-- Paul A. Sand | Disclaimer:
-- University of New Hampshire | the renouncing, repudiating, or
-- pas@unh.edu | denying of a claim.
-- http://pubpages.unh.edu/~pas | But that's not important right now.
------------------------------
Date: Wed, 1 Apr 1998 16:27:22 -0500
From: prn@bsu.edu (Paul Neubauer)
Subject: File locking
Message-Id: <MPG.f8c7b423177fd4998968e@news.bsu.edu>
Hi all,
I've been looking at various file locking schemes and have a question
that does not appear to be covered in any of the various FAQs or man
pages.
It appears that the "normal" idiom for locking would go something like:
open FH, ">$filename" or die("can't open $filename : $!");
flock (FH, LOCK_EX);
...print stuff to file ...
flock (FH, LOCK_UN);
close FH;
But it seems (and yes, I do understand that I may be putting my foot
firmly into my mouth) that this could suffer from the same potential
problems as the code (that one might use as an "alternative" to flock) in
perlfaq6 where it says:
> A common bit of code NOT TO USE is this:
>
> sleep(3) while -e "file.lock"; # PLEASE DO NOT USE
> open(LCK, "> file.lock"); # THIS BROKEN CODE
>
> This is a classic race condition: you take two steps to do
> something which must be done in one.
Perlfaq6 suggests
> sysopen(FH, "file.lock", O_WRONLY|O_EXCL|O_CREAT, 0644)
> or die "can't open file.lock: $!":
as a potentially better alternative.
I understand that this may turn out to be more an OS question (the OS in
question would be Solaris 2.6) than a perl question, but what do folks
think about this, which corresponds to the atomic lockfile creation
above:
sysopen(FH, $filename, O_WRONLY|O_EXCL|O_TRUNC, 0644)
or die("can't open $filename : $!");
as a possibly preferable alternative to the "normal" code fragment with
flock() above? Would this be better? It looks to me like the "normal"
code has the same race condition weakness of opening (and truncating) the
file and only later (usually not much later, but you never know) actually
locking the file so some other process cannot read it. Am I correct or
am I all wet?
Paul
--
Paul Neubauer prn@bsu.edu
http://nova.bsuvc.bsu.edu/prn/
PGP Public Key at http://nova.bsuvc.bsu.edu/prn/key.html
------------------------------
Date: Wed, 01 Apr 1998 14:55:10 -0500
From: Alexandra Stehman <afs101@psu.edu>
Subject: foreach loop & current element index
Message-Id: <35229B9D.C3C49A3B@psu.edu>
Hi all,
Just a quick question - I guess a for loop might be a better way to go
about this, but a student asked the question and I want to be sure when
I say "There is no way to do this".
The question was: "When in a foreach loop, is there a special variable
or perl function that can be used to determine the index of the current
array element?"
I mentioned the ability to assign the array to a scalar to determine the
number of elements in the array and then use a for loop in conjunction
with its index to keep track of the current position in the array, but
he "just wanted to know". I don't think there is a way to do what he
asked, but I figured that if there were, at least one person on this
newsgroup would know!
Thanks,
Alexandra Stehman
------------------------------
Date: Wed, 01 Apr 1998 15:32:37 -0500
From: Rick Schofield <Richard.Schofield@fmr.com>
To: alexx@psu.edu
Subject: Re: foreach loop & current element index
Message-Id: <3522A465.DBFFA349@fmr.com>
Alexandra Stehman wrote:
> Hi all,
>
> Just a quick question - I guess a for loop might be a better way to go
> about this, but a student asked the question and I want to be sure when
> I say "There is no way to do this".
>
There's _always_ a way!
> The question was: "When in a foreach loop, is there a special variable
> or perl function that can be used to determine the index of the current
> array element?"
>
Sure. $_. Simple, no?
Rick
------------------------------
Date: 01 Apr 1998 15:51:42 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: foreach loop & current element index
Message-Id: <btulqn8h.fsf@mailhost.panix.com>
> The question was: "When in a foreach loop, is there a special variable
> or perl function that can be used to determine the index of the current
> array element?"
This is addressed in the blue Camel, which I'll take the liberty of
quoting (pg. 100):
Note that there is no way with *foreach* to tell where you are in a
list. ... sometimes you just have to break down and write an
ordinary *for* loop with subscripts. That's what *for* is there
for, after all.
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
------------------------------
Date: 01 Apr 1998 16:08:59 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: foreach loop & current element index
Message-Id: <90ppqmfo.fsf@mailhost.panix.com>
Rick Schofield <Richard.Schofield@fmr.com> writes:
> Alexandra Stehman wrote:
> > The question was: "When in a foreach loop, is there a special variable
> > or perl function that can be used to determine the index of the current
> > array element?"
>
> Sure. $_. Simple, no?
$_ is an alias for the element itself, and does not give the index of
the element. Simple, no!
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
------------------------------
Date: Wed, 01 Apr 1998 16:08:51 -0500
From: Alexandra Stehman <afs101@psu.edu>
Subject: Re: foreach loop & current element index
Message-Id: <3522ACE3.4752A5C6@psu.edu>
Simple? Not quite. For files, the special variable $. will return the
current input line number of the last filehandle read, but this isn't a
file. The array index is what's needed, and $_ won't return that. It
returns the current input, and only if no iteration variable was declared for
the foreach loop. For example:
THE CODE:
#!/usr/bin/perl
@allfish=("one fish","two fish","red fish","blue fish");
foreach $fish(@allfish){
print "The current fish is $fish\n";
print "and \$_ is: ", $_, "\n";
}
produces this OUTPUT:
>fish.pl
The current fish is one fish
and $_ is:
The current fish is two fish
and $_ is:
The current fish is red fish
and $_ is:
The current fish is blue fish
and $_ is:
Whereas the CODE:
#!/usr/bin/perl
@allfish=("one fish","two fish","red fish","blue fish");
foreach (@allfish){
print "The current fish is $_\n";
print "and \$_ is: ", $_, "\n";
}
produces the OUTPUT:
The current fish is one fish
and $_ is: one fish
The current fish is two fish
and $_ is: two fish
The current fish is red fish
and $_ is: red fish
The current fish is blue fish
and $_ is: blue fish
So as you can see, $_ will return the current input to the loop condition
statement, which in this case is the current array element; however, it does
not return the current array index. This problem can be solved by using a
simple for loop, like
for ($i=1; $i==@theArray; $i++){...}
where the loop stops when $i is equal to the number of elements in
@theArray. But that wasn't the students' question.
Thank you anyway for your reply!
Rick Schofield wrote:
> Alexandra Stehman wrote:
>
> > Hi all,
> >
> > Just a quick question - I guess a for loop might be a better way to go
> > about this, but a student asked the question and I want to be sure when
> > I say "There is no way to do this".
> >
>
> There's _always_ a way!
>
> > The question was: "When in a foreach loop, is there a special variable
> > or perl function that can be used to determine the index of the current
> > array element?"
> >
>
> Sure. $_. Simple, no?
>
> Rick
------------------------------
Date: Wed, 01 Apr 1998 12:14:44 -0800
From: Glenn Schworak <Glenn.J.Schworak@state.or.us>
Subject: gathering EMail address via CGI
Message-Id: <3522A034.41855B74@state.or.us>
Is it posible with perl to ask the uer's browser what their EMail
address is?
That may be over simplified, but I know that most web browsers store or
at least can access the user's EMail address for use when the user
clicks a mailto: type of link.
I think it would be nice to pre-fill in part of a form that is being
generated by my perl script by asking the user's browser for their EMail
address and using that as the default value for one of the blanks on the
form.
Thanks for any help you can offer.
(just to chalange you, I was something like this done with java once but
can't find it again)
------------------------------
Date: 1 Apr 1998 21:11:59 GMT
From: delegz <delegz@NOSPAM.rpi.edu>
Subject: How can I replace from a list?
Message-Id: <6fuaiv$pis@newsfeeds.rpi.edu>
I have two text documents, let's call Text Document #1 and
Text Document #2. In one of them, Text Document #1, the
following line appears repeatedly
From: G Rideout <rideout@panix.com>
Of course, it is part of a email header. Let's call this line
"X" for simplicity's sake. Anyway, I would like to be able to
have some perl script search Text Document #1 and, every time
it comes to this line "X", replace it with a line from the
second text document, Text Document #2. But where this gets
tricky is that there are 400 lines in Text Document #2, and I
would like to have the script move down line by line from the
top of Text Document #2 every time it is called upon to do a
replacement of "X".
In other words, if the first line of Text Document #2 said,
The cat is black.
then that would be what would replace "X" the first time that
"X" was encountered in Text Document #1. Then, when "X" was
encountered for the second time, it would be replaced with the
second line of Text Document #2, e.g.,
My mother was old.
And so on, down to the last line of Text Document #2.
Someone advised me to use the following:
#!perl -w
open SEARCH, "Text Document #1";
open REPLACE, "Text Document #2";
open OUT, ">#2 Modified";
while (<SEARCH>) {
s/^X$/<REPLACE>/e and chop;
print OUT;
}
close SEARCH;
close REPLACE;
close OUT;
__END__
Telling me that 'the chop is necessary to avoid double
returns. Replace "X" with the text to be replaced'.
The problem is, #2 Modified was created, but it looks
_exactly_ like Text Document #1. I replaced "X" with
From: G Rideout <rideout@\panix.com>
before I ran this. Did I do something wrong?
P.S. I never looked at Perl before until this morning,
at someone's suggestion. Thanks for any help!
Dale
delegz@rpi.edu
------------------------------
Date: Wed, 01 Apr 1998 15:06:24 -0500
From: Rich Tsui <tsui@cbmi.upmc.edu>
Subject: How to pass user_name and password to each perl CGI script?
Message-Id: <35229E40.933E5C24@cbmi.upmc.edu>
passme
Hi there,
If I don't use .htaccess and htpasswd to have restricted web access
via Apache web server,
I have to create my own user name and password page. However, I got
stuck because how
I can pass the user name and password into different perl CGI scripts?
I don't want to use
hidden variable to pass password information. I also tried to assign a
value to
$ENV{'REMOTE_USER'} but it still can't be seen from the other perl CGI.
Any idea is welcome?
Rich Tsui
University of Pittsburgh
------------------------------
Date: Wed, 01 Apr 1998 12:18:55 -0800
From: Glenn Schworak <Glenn.J.Schworak@state.or.us>
To: Miss WILKINS <fr39@dial.pipex.com>
Subject: Re: Identifying how a perl program was called
Message-Id: <3522A12F.73C61C4@state.or.us>
Thanks for your input. Another person pointed this out just a bit ago too. I
have since done what I should have done in the first place. Wrote a little
foreach loop to print out all the ENV keys and values for me. There was a lot
more info than I though available.
The word "duahhhh" describes the way I feel about now. Sorry for wasting
everyone's time with that one.
Miss WILKINS wrote:
> Hi
>
> wouldn't HTTP_Referer do the trick
>
> Iqbal
>
> PS email is iqbal@etc.prestel.co.uk , couldn't be bothered to change my
> mates settings
>
------------------------------
Date: Wed, 01 Apr 1998 15:01:00 +0100
From: C.VOGEL@LINK-GOE.de (Chris Vogel)
Subject: Re: Is there a "Newsgroup" for Newbies to Perl?
Message-Id: <6r0ZYU7ntSB@-sweet.link-goe.de>
Goettingen, Stardate 0938.05
Hi there,
mikenak (Mike Nakagawa) wrote in 35218DCA.6D6F@best.com on
01.04.98 following lines, starting with '*'
* Are you suggesting a RFD for a comp.lang.perl.d group?
No. I think the newsgroup would be overcrowded and there would be
nobody who could handle the bandwith. I'm thinking about a stack of
mailinglists each for a limited count of users who form something like
a studygroup...
Chris.
--
Aus den ueberregionalen Medien wissen wir heute, dass ein Schmetterling in Asien
mit den Fluegeln geschlagen hat, bevor wir im Lokalradio die Sturmwarnung hoeren.
------------------------------
Date: 1 Apr 1998 13:09:58 -0800
From: smitty77@pacbell.net
Subject: Re: Is there a "Newsgroup" for Newbies to Perl?
Message-Id: <6fuaf6$5pc@co-op.newsguy.com>
In article <6ftq01$af3$1@news.ml.com>, fieldva@ml.com says...
>
>
>In article {...}, "smitty77" stunned me by saying:
>>>
>>>smitty77> My first experience with perl was in a class at Silicon
>>>smitty77> Graphics taught by Randall Schwartz. It was a pretty good
>>>smitty77> class, but even then I could tell that Randall had no
>>>smitty77> patience for people who asked what he felt were 'stupid
>>>smitty77> questions'. To each his own, I guess.
>
>
>To which Randal replied:
>
>>>I'm a bit flabberghasted by this...
>
> I, myself, have had the extraordinary good fortune
> to have participated in two Perl classes which were
> led by Randal. I can't even begin to imagine what
> in the world caused Dave to perceive that Randal's
> classes were anything but clear, concise, informative,
> and helpful to the 'nth' degree.
Pay attention, Vance. That's not what I said.
> Hey Dave, by the way, was it Randal who charactized the
> questions you mention as being "stupid"? If not, why
> have you portrayed them as such? Hopefully, your ability
> to deal with technical topics is superior to your comm-
> unication skills. If not, I think I can see how you came
> to your original conclusion.
Vance, Vance, Vance....I was making a point. I never said that Randal
characterized those questions as stupid, which is why I put the term in quotes.
I simply observed that Randal appeared to have no patience for trivial
questions, and I can say they were trivial because I found them to be trivial.
And if I thought they were trivial, certainly they must have been trivial to
Randal. It's ironic that you attack my communication skills rather than what I
was attempting to point out. You're sitting there arguing about how I refer to
the questions rather than how I refer to the manner in which Randal responded to
them.
Apparently, you didn't make the same observation as I did. Perhaps the same
situation never arose. Perhaps Randal handled the situation differently.
Perhaps we just tend to observe things differently. Regardless, I called it as
I saw it. If you disagree, just disagree - don't attack my communication skills
like a sissy.
Dave
>
> Vance
>
>--
>/***************************************************************/
>/* Vance R. Fields Unix System Administrator */
>/* Merrill Lynch World Financial Center */
>/* fieldva@dats.ml.com NYC, NY 10080 (South Tower) */
>/* (212) 236-3989 (voice) (212 236-1039 (fax) */
>/***************************************************************/
>
>
>
------------------------------
Date: 1 Apr 1998 12:58:01 -0800
From: smitty77
Subject: Re: Is there a "Newsgroup" for Newbies to Perl?
Message-Id: <6fu9op$43l@co-op.newsguy.com>
I've hardly 'broadsided' you, Randal. I simply pointed out an observation. I
will explain myself, but isn't it ironic that you get so defensive right off
the bat - somewhat like an inexperienced perl programmer who has been flamed
in this newsgroup by someone who 'broadsides' them.
Here's what I was talking about when I made the statement. When I took your
class 2 years ago, I went into it as an experienced C programmer, and I found
the week long class to be well organized and very well done. I personally
had no problems with how you taught the class or any of its content. When I
asked a question, I did not feel that you did anything wrong or brushed me
aside or treated me disrespectfully. But there were plenty of inexperienced
programmers in the class, too. People with little or no high level
programming experience. These people struggled at times. When some of those
people would ask what in my opinion was a trivial question, I noticed that
you answered very impatiently. Not necessarily rudely or improperly - but
impatiently. Maybe you wanted to keep the class moving for the other members
of the class. Maybe you didn't want to lose a lot of time and not get
through all the material for the day. Regardless of your reasons (and those
are both very good reasons, I think), I just observed that you handled these
situations with impatience. Some instructors I've had have dealt with similar
situations politely informing the person that taking the time to answer their
question would take away from the rest of the people in the class, and they
would handle the person's question off-line after class or during a break. I
simply noticed that you were not all that polite about it. That's all.
It was simply an observation - one that stuck with me. And I've noticed that
some of your responses in this newsgroup appear to be written with the same
tone of impatience. If you're offended by these observations, it isn't
intentional on my part. There aren't any specific examples that I can remember.
The reason I didn't mention it in the class evaluation form was because
personally, I got everything I wanted to out of the class, and more importantly,
at the time, it really didn't warrant bringing up.
For what it's worth, I found your class to be one of the best I've had - if
not the best. I wouldn't be where I am today without the passion for the
perl language that grew based on taking your class. I recommended your class
to many of my co-workers, and I was disappointed, to say the least, when I
found out that you weren't teaching the class anymore after one of my
co-workers took it. (Apparently you were mentoring an associate and were in
the class mainly as an observer, not as the instructor on this occasion). I
would certainly recommend your class to any peer of mine who is an
experienced programmer and wants to learn perl. I would not, however,
recommend your class to a programming novice, but I don't think you'd argue
that your class isn't directed at progamming novices.
I certainly have nothing against you personally, I was merely stating an
observation I made while taking your class. It was hardly meant to be rude
or to harm your reputation in any way. Take it however you see fit - as an
insult or as something you might want to think about next time you're in one
of these situations.
And finally, don't you think that people who ask what may appear to the
experts as an ignorant question feel unfairly 'broadsided' when some
arrogant prick answers them condescendingly and discourteously, while
avoiding the question and brushing them aside to go look at the mile long FAQ?
And before you go thinking I'm referring to you, I'm not. I've never seen
you do that here - but there are plenty of people who you know who do just
that. I would never want to work with any of those people, let alone have
them teach me anything.
Regards,
Dave
In article <8ciuouc4y6.fsf@gadget.cscaper.com>, Randal says...
>
>>>>>> "smitty77" == smitty77 <smitty77@pacbell.net> writes:
>
>smitty77> My first experience with perl was in a class at Silicon
>smitty77> Graphics taught by Randall Schwartz. It was a pretty good
>smitty77> class, but even then I could tell that Randall had no
>smitty77> patience for people who asked what he felt were 'stupid
>smitty77> questions'. To each his own, I guess.
>
>I'm a bit flabberghasted by this. It's not my intention to come
>across as someone who "had no patience for people who asked what he
>felt where 'stupid questions'". Since you've broadsided me, I'm gonna
>ask you why you didn't come up to me in class to tell me your
>perception, or at least write it down on the readily available SGI
>"eval" forms at the end of the week. If you can relate a specific
>conversation in detail, I'll be happy to attempt to recall the
>situation and try to understand what happened.
>
>I take special care to ensure that each and every student gets what
>they came for in my classes. And my associates (rootbeer, Joseph, and
>Chip Salzenberg) do the same, or they don't work with me. I'm
>committed to that. I've bet my company's entire reputation on that.
>When I fall short of that goal, I want to be called on it. But
>please, it's a bit rude to have done that in a public forum such as
>this.
>
>I can assure you that if my general classroom perception was one such
>as yours, SGI wouldn't have let me teach the next class (they're very
>picky about my work there). As it is, I'm booked solid through the
>end of the year with SGI (as well as many other regular clients) and
>generally score 3-5 on the 1-5 scale in *all* areas (except class
>length :-). I'm sorry you had a uniquely different experience, and
>would be happy to try to understand why your experience was different.
>
>Sorry for being lengthy, but attacking my reputation in a public forum
>demands a public response on my part. (And I'd be happy to give
>anyone who asks a list of references to validate my assertion. Just
>write perl-training-info@stonehenge.com for details, or visit
>www.perltraining.com.)
>
>print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
>## legal fund: $20,990.69 collected, $186,159.85 spent; just 153 more days
>## before I go to *prison* for 90 days; email fund@stonehenge.com for details
>
>--
>Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
>Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
>Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger
>merlyn@teleport.com)
>Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
>Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: 1 Apr 1998 20:04:30 GMT
From: hlc4loc@earthlink.net (Frank Vollono)
Subject: Keyword Search Script?
Message-Id: <hlc4loc-0104981208480001@pool018-max11.la-ca-us.dialup.earthlink.net>
Hello all. I am building a web site and would like to have a keyword
script function on it.
We have a large amount of images that we would like to assign keywords to
and have people look for them. For example, if they search for 'offices'
all the images we have should show on the page.
Also how much would it be to have someone do this? or can we get pre-made
scripts?
Thanks
Frank Vollono
hlc4loc@earthlink.net
------------------------------
Date: 1 Apr 1998 20:08:31 GMT
From: hlc4loc@earthlink.net (Frank Vollono)
Subject: Keyword Searching a web page
Message-Id: <hlc4loc-0104981212490001@pool018-max11.la-ca-us.dialup.earthlink.net>
Hello all. I am building a web site and would like to have a keyword
script function on it.
We have a large amount of images that we would like to assign keywords to
and have people look for them. For example, if they search for 'offices'
all the images we have should show on the page.
Also how much would it be to have someone do this? or can we get pre-made
scripts?
Thanks
Frank Vollono
hlc4loc@earthlink.net
------------------------------
Date: Wed, 01 Apr 1998 22:26:33 +0100
From: Andrew Boothman <andrew@boothman.easynet.co.uk>
Subject: Overhead created by a lot of file access
Message-Id: <3522B109.6EC0F7DF@boothman.easynet.co.uk>
Hi All!
I am writing a CGI script in perl that acts as a hierarchical database
of web sites, with all sorts of added bit's to make it better than
Yahoo!
Anyway, the information is stored in semi-colon delimited text files,
with the name of the category stored on the first line.
An example file might be:
Search Engines
Yahoo;http://www.yahoo.com;0;0
Lycos;http://www.lycos.com;0;0
Altavista;http://www.altavista.digital.com;0;0
(the trailing 0's are needed for some of the extra functions of the
database)
The files could become 100+ lines long, if there were 15+ of these
files, what sort of overhead would that place on the server running it?
If all the files had to be read each time the script is run, would there
be a noticeable time lag for the users? (the script could be run up to 7
times, spread across several minutes, in each 'interaction' with the
database)
Also, is there a better way of storing the information then in these
text files?
The server that will eventually run the script is a Sun Netra i server,
with 100+ MB of ram and a 2GB HDD. But the machine has other stuff to do
as well (IP gateway, e-mail, WWW Proxy).
Phew! That was a long message. I'm a perl beginner, and I would really
appreciate any help that you experienced folk could give.
Thanks loads!
--
Andrew Boothman : andrew@boothman.easynet.co.uk
(http://easyweb.easynet.co.uk/~boothman/andrew/)
"Yahoo is a search engine.
Netanyahoo is an Israeli search engine"
-Robin Williams
------------------------------
Date: Wed, 01 Apr 1998 15:00:33 -0500
From: Viren Patel <viren@base4.com>
Subject: Passing a list of lists to a function
Message-Id: <35229CE0.44FE693@base4.com>
Hello. I am trying to pass a list of lists to a function. The LOL is
created outside the function. However, once in the function, I cannot
access the elements of the LoL. I have included my test code along with
the output. Any help on how to do this is greatly appreciated.
=== Code ===
#!/usr/local/bin/perl -w
@tarray = (["Column1", "Column2"]);
@tarray = (@tarray, ["Test1", "Test2"]);
print "$tarray[1][0]\n";
print "$tarray[1][1]\n";
prtArray(@tarray);
exit;
sub prtArray {
my(@array);
@array = $_[0];
print "$array[0][0]\n";
print "$array[0][1]\n";
print "$array->[1][0]\n";
print "$array->[1][1]\n";
}
=== Output ===
Test1
Test2
Column1
Column2
Use of uninitialized value at ./ddd.pl line 22.
Use of uninitialized value at ./ddd.pl line 23.
--
Viren Patel, Ph.D. Phone: (905) 677-0532 ext. 246
Base4 Bioinformatics, Inc. Fax: (905) 677-1122
6299 Airport Rd., Suite 601
Mississauga, ON L4V 1N3, Canada
------------------------------
Date: 01 Apr 1998 16:03:12 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: Passing a list of lists to a function
Message-Id: <afa5qmpb.fsf@mailhost.panix.com>
Viren Patel <viren@base4.com> writes:
> prtArray(@tarray);
You're passing a copy of the entire array in @_, which is fine, but...
> sub prtArray {
> my(@array);
>
> @array = $_[0];
Oops. You're assigning the first element of @_ to @array.
There's more than one way to do what you're trying to do, and you'll
read about them in the following perl documents (and in the Camel):
perlsub, perlref, perllol, perldsc.
One popular way is to pass an array reference, like so:
munge(\@data);
sub munge {
my @array = @{$_[0]};
}
A sneakier way that I enjoy is to use function prototypes:
munge(@data);
sub munge (\@) {
my $aref = shift;
}
I hope this helps.
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
------------------------------
Date: Wed, 1 Apr 1998 21:14:47 GMT
From: Charles Margolin <cmargoli@world.northgrum.com>
Subject: Re: Passing a list of lists to a function
Message-Id: <3522AE47.1DFA@world.northgrum.com>
Viren Patel wrote:
>
> Hello. I am trying to pass a list of lists to a function. The LOL is
> created outside the function. However, once in the function, I cannot
> access the elements of the LoL. I have included my test code along with
> the output. Any help on how to do this is greatly appreciated.
>
> === Code ===
>
> #!/usr/local/bin/perl -w
>
> @tarray = (["Column1", "Column2"]);
>
> @tarray = (@tarray, ["Test1", "Test2"]);
It would be better to say
push @tarray, ["Test1", "Test2"];
rather than copy the previous contents.
>
> print "$tarray[1][0]\n";
> print "$tarray[1][1]\n";
>
> prtArray(@tarray);
>
> exit;
>
> sub prtArray {
> my(@array);
>
> @array = $_[0];
The array has 2 elements, but you are only picking up the first.
>
> print "$array[0][0]\n";
> print "$array[0][1]\n";
>
> print "$array->[1][0]\n";
> print "$array->[1][1]\n";
The scalar $array has not been defined. You should treat
$array[1] the same as $array[0]. Or you could pass in a reference
to @tarray and print the second way.
--
Charles G. Margolin DSSD Internal Information Services
cmargoli@world.northgrum.com Northrop Grumman Corp. 0624/23
margolin@acm.org Hawthorne, California 90250-3277
------------------------------
Date: 01 Apr 1998 16:52:18 -0500
From: Nevin Kapur <kapur@cbl.ncsu.edu>
To: Viren Patel <viren@base4.com>
Subject: Re: Passing a list of lists to a function
Message-Id: <ty3efxus4t.fsf@cbl.ncsu.edu>
[posted and mailed]
Viren Patel <viren@base4.com> writes:
> Hello. I am trying to pass a list of lists to a function. The LOL is
> created outside the function. However, once in the function, I cannot
> access the elements of the LoL. I have included my test code along with
> the output. Any help on how to do this is greatly appreciated.
Let me see if I can step through your code:
> === Code ===
>
> #!/usr/local/bin/perl -w
>
> @tarray = (["Column1", "Column2"]);
>
> @tarray = (@tarray, ["Test1", "Test2"]);
@tarray is now (["Column1", "Column2"],["Test1", "Test2"]), that is, a
2-element array, each element being a reference to an anonymous array.
> print "$tarray[1][0]\n";
> print "$tarray[1][1]\n";
More explicitly, you are asking for $tarray[1]->[0] and
$tarray[1]->[1], which are "Test1" and "Test2".
So far, so good.
> prtArray(@tarray);
>
> exit;
>
> sub prtArray {
> my(@array);
>
> @array = $_[0];
Here is where the problems start. I am not sure if this is what you
intended, but you are throwing away everything but the 1st element of
your argument. In this case, @array is a 1 element array with $_[0] as
its only element.
@array = (["Column1", "Column2"]);
> print "$array[0][0]\n";
> print "$array[0][1]\n";
This works as expected.
> print "$array->[1][0]\n";
> print "$array->[1][1]\n";
You are dereferencing $array, which is undefined as the warnings
indicate. From the perlref manpage:
Note that $array[$x] is NOT the same thing as $array->[$x]
Perhaps you meant $array[1]->[0] and $array[1]->[1], i.e deference
$array[1]. In this case, however, that will not work either, since
@array contains just a single element. You should change
@array = $_[0];
to
@array = @_;
>
> }
>
> === Output ===
>
> Test1
> Test2
> Column1
> Column2
> Use of uninitialized value at ./ddd.pl line 22.
>
> Use of uninitialized value at ./ddd.pl line 23.
I would suggest reading the perllol docs thoroughly.
-Nevin
------------------------------
Date: Wed, 01 Apr 1998 23:07:47 +0200
From: Riechert <amr@nospam.miyako.japanologie.kultur.uni-tuebingen.de>
Subject: Re: PERL Far Eastern Language Support
Message-Id: <3522ACA1.2CF0@nospam.miyako.japanologie.kultur.uni-tuebingen.de>
Just for the files:
The statement at the ActiveState home page just means, that
they started at February 23th, 1998 a mailinglist for Japanese
users of Perl-Win 32.
Andreas Marcel
Creede Lambard wrote:
>
>
> If you're looking to run this on a Win32 machine, there's a note on the
> ActiveState home page (http://www.activestate.com) written in Japanese, so I
> can't read it, but it makes reference to something like Perl-J.
------------------------------
Date: Wed, 01 Apr 98 21:37:56 GMT
From: jlcampbell@amoco.com (Jerry L. Campbell)
Subject: Problems building Perl 5.004_4
Message-Id: <6fubvv$mhc@paperboy.amoco.com>
Building on Solaris 2.5.1 with gcc 2.8.1. Yes to use dynaloader,
yes to use PerlIO (actually built both ways, same result). The tar archive
was downloaded from www.perl.com, advertised as the latest stable
version....
Anybody have any ideas? The errors follow the sig.
Jerry Campbell
jlcampbell@amoco.com
--------------------------------------------------------------------
gcc -c -I/usr/local/include -O -DVERSION=\"1.03\" -DXS_VERSION=\"1.03\"
-I.
/.. -DPERL_CORE -DLIBC="/lib/libc.so" DynaLoader.c
In file included from DynaLoader.xs:107:
/usr/local/include/perl.h:144: warning: `safemalloc' redefined
./../embed.h:1171: warning: this is the location of the previous definition
/usr/local/include/perl.h:145: warning: `saferealloc' redefined
./../embed.h:1172: warning: this is the location of the previous definition
/usr/local/include/perl.h:146: warning: `safefree' redefined
./../embed.h:1170: warning: this is the location of the previous definition
In file included from /usr/local/include/perl.h:611,
from DynaLoader.xs:107:
./../sv.h:256: parse error before `PerlIO'
./../sv.h:256: warning: no semicolon at end of struct or union
./../sv.h:257: warning: data definition has no type or storage class
./../sv.h:272: parse error before `}'
In file included from /usr/local/include/perl.h:1435,
from DynaLoader.xs:107:
./../proto.h:90: parse error before `PerlIO'
./../proto.h:92: parse error before `PerlIO'
./../proto.h:262: parse error before `*'
./../proto.h:263: parse error before `*'
./../proto.h:263: warning: data definition has no type or storage class
./../proto.h:323: parse error before `*'
./../proto.h:323: warning: data definition has no type or storage class
./../proto.h:383: parse error before `Perl_rsignal'
./../proto.h:383: parse error before `Sighandler_t'
./../proto.h:383: warning: data definition has no type or storage class
./../proto.h:384: parse error before `Sigsave_t'
./../proto.h:385: parse error before `Sighandler_t'
./../proto.h:386: parse error before `Perl_rsignal_state'
./../proto.h:386: warning: data definition has no type or storage class
./../proto.h:472: parse error before `PerlIO'
make[1]: *** [DynaLoader.o] Error 1
make[1]: Leaving directory `/web1/Perl/perl5.004_04/ext/DynaLoader'
make: *** [lib/auto/DynaLoader/DynaLoader.a] Error 2
------------------------------
Date: 1 Apr 1998 20:43:55 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: REQ: algorithm for DES::encrypt/decrypt of text strings
Message-Id: <6fu8ub$6t9@news-central.tiac.net>
In article <352283B9.24A7736D@fmr.com>,
Rick Schofield <Richard.Schofield@fmr.com> wrote:
>Howdy,
>
> I need to encrypt/decrypt text strings and want to use
>DES::en[de]crypt to do it. The problem I'm having is how to
>pack the string data into a form acceptible to DES.
>
> I'm assuming I want to separate the string into 8 character
>segments, pack them into 8 byte data and pass the to encrypt.
>That seems easy enough to do, but I seem to be unable to get
>data in the right form. Here's an outline of what I'm trying:
>
> use Crypt::DES;
> my $cipher = new DES $key;
What did $key contain? It should be an 8 byte string.
> $in = "zyxwvuts";
> $packin = pack ("C8", $in);
This probably doesn't do what you want, if $in is already an 8 byte string
then you don't need to do anything to it.
DB<1> use Crypt::DES
DB<2> $session = DES->new (pack 'H*', '0123456789abcdef');
DB<3> $in = "zyxwvuts"
DB<4> $enc = $session->encrypt ($in);
DB<5> print $session->decrypt ($enc)
zyxwvuts
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: 01 Apr 1998 15:33:29 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: String Manipulation Question
Message-Id: <d8f1qo2u.fsf@mailhost.panix.com>
Neil Trenholm <hayward@auracom.com> writes:
> I would prefer to replace the carriage returns with a <BR><BR> before
> writing to the database.
>
> Did I miss this in the man pages or newsgroup ?
You'll want to spend a few hours learning about a concept that's
central to Perl's expressive power: regular expressions. One of the
operators that uses regexes is the "s" operator. To change every
instance of "foo" to "bar" in a string, for example, you'd
s/foo/bar/g;
Your best bet is to buy the book _Learning Perl_ which will walk you
through regexes in a context that leads you to think Perlishly about
programming in general. If you're impatient, and don't want to buy
_Learning Perl_, you may turn to the perlre manpage, which covers
regexes more than adequately for your needs. You'll also need to read
the sections in perlop that deal with the matching and substitution
operators. Hope this helps.
As for missing this topic in the newsgroup, did you use DejaNews to
search? Several of the hits returned from this query answer your
question outright.
http://search.dejanews.com/dnquery.xp?QRY=replace+and+carriage+returns&ST=PS&DBS=1&format=threaded&showsort=score&groups=comp.lang.perl.misc
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
------------------------------
Date: Wed, 1 Apr 1998 15:22:42 -0600
From: "JC" <khnguyen@comp.uark.edu>
Subject: System() command questions
Message-Id: <6fuaut$btu@picayune.uark.edu>
Hello. I'm a beginner at perl. I'm trying to retrieve a html file from a
server using perl.
I can get the first "system" command to run. The telnet program will show
the following:
Trying 208.131.167.6...
Connected to mailhost.infi.net.
Escape character is '^]'.
Then, it will set there until you enter in the following:
GET /~leeann/list7.htm HTTP/1.0
My problem is, I can't get the "GET /~leeann/list7.htm HTTP/1.0" command to
execute after the first system command runs.
The following is my perl code:
=======================================================
#!/usr/local/bin/perl -w
$ServerNam = 'www.richmond.infi.net'; # Server Name
$HttpPort = 80; # Http protocol port
number
$GetIdf = '/~leeann/list7.htm'; # Get Identifier
(/path/file.html)
print "Attempting to access server...\n" || die "Cannot access";
system("telnet $ServerNam $HttpPort &") || die "Cannot Access";
system("GET $GetIdf HTTP/1.0") || die "Cannot Access";
=======================================================
Please, any help is appreciated. What is a good Perl book on this subject?
Thanks.
-JC
------------------------------
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 2227
**************************************