[13700] in Perl-Users-Digest
Perl-Users Digest, Issue: 1110 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Oct 18 18:07:33 1999
Date: Mon, 18 Oct 1999 15:05:14 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <940284314-v9-i1110@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 18 Oct 1999 Volume: 9 Number: 1110
Today's topics:
Re: "Proper" way to load a file (Tad McClellan)
Re: "Protecting" Perl source code <gellyfish@gellyfish.com>
Re: animated gif won't blink <alternative_ca@hotmail.com>
Re: animated gif won't blink <gellyfish@gellyfish.com>
Re: Baffled! (Joe Petolino)
Re: can i make a cgi run it self <spike_YYwhiteYY@YYdellYY.com>
Re: Data structure problem. Please help! <aqumsieh@matrox.com>
embedding perl in win32 <sjoseph7@worldnet.att.net>
Re: encryption and crypt() ? (Alan Curry)
Re: equiv. of nice & simple ksh syntax <gellyfish@gellyfish.com>
Re: file xfer via modem <gellyfish@gellyfish.com>
Re: got it working, thx :) <dane@forum.dk>
Re: Ignore the idiots <nolenj@worldnet.att.net>
Re: Ignore the idiots <gellyfish@gellyfish.com>
MS VC++ setting for embedding Perl Interpreter in C/C++ <a79543@yahoo.com>
need cgi script <twilson@peruseweb.com>
Re: need cgi script <msalter@bestweb.net>
Re: need cgi script <camerond@mail.uca.edu>
OT: Din paper sizes (was Re: PDFlib size settings) <gellyfish@gellyfish.com>
Re: OT: Din paper sizes (was Re: PDFlib size settings) (Sam Holden)
Re: Q: Truncate string length? emlyn_a@my-deja.com
Re: shifting a hash <aqumsieh@matrox.com>
sorting arrays secnarf@my-deja.com
Re: sorting arrays (Brett W. McCoy)
Re: Unix Utilities: Perl Versions <aqumsieh@matrox.com>
Re: Uses of # (Damian Conway)
Re: variables on the right side one Reg Exp <gellyfish@gellyfish.com>
Re: what is SHTML ? (Brett W. McCoy)
WHATS WRONG WITH THIS CODE? <golf@tfz.net>
Re: why don't this darm s..... work <nguyend7@msu.edu>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 18 Oct 1999 08:36:28 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: "Proper" way to load a file
Message-Id: <c84fu7.ega.ln@magna.metronet.com>
Larry Rosler (lr@hpl.hp.com) wrote:
: In article <x3yzoxk5nbc.fsf@tigre.matrox.com> on Fri, 15 Oct 1999
: 17:25:11 -0400, Ala Qumsieh <aqumsieh@matrox.com> says...
: ....
: > Or maybe you can save only the lines that you want and discard some
: > lines that aren't necessary:
: >
: > while (<FILE>) {
: > if ($_ == $I_Want_This_Line) {
: > $contents .= $_;
: > }
: > }
: Just to pick a tiny nit, I doubt very much that you want '==' in that
: comparison, instead of 'eq'.
... or, it might be that == is correct, and $_ was meant to be $.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 18 Oct 1999 19:53:37 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: "Protecting" Perl source code
Message-Id: <7ufts1$6iv$1@gellyfish.btinternet.com>
On Mon, 18 Oct 1999 03:40:01 GMT Craig Berry wrote:
> Jonathan Stowe (gellyfish@gellyfish.com) wrote:
> : In comp.lang.perl.misc Craig Vincent <webmaster@webdream.com> wrote:
> : >
> : > the underworld webmaster market
> :
> : I get this picture of evil webmasters smacking their ho^H^Hprogrammers
> : and sending them back out on the street ...
>
> What, it's different where you work?
>
Well OK I must admit I *do* play the 'evil analyst' card occasionally when
have difficulty getting a specification from certain PHB types and I *did*
threaten to have one of the System Administrators cut up with an angle
grinder and left in bin bags around the neighbourhood - but isnt this stuff
in every AP's toolkit ...
/J\
--
Jonathan Stowe <jns@gellyfish.com>
<http://www.gellyfish.com>
Hastings: <URL:http://dmoz.org/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Mon, 18 Oct 1999 19:15:05 GMT
From: "Olwynn" <alternative_ca@hotmail.com>
Subject: Re: animated gif won't blink
Message-Id: <ZkKO3.3251$H%5.181209@sapphire.mtt.net>
When I have my perl
>cgi reference the gif " print "<td align=center><img
>src=\"http://my.machine.com/icons/green_ball.gif\"></td>\n"; " the icon
>frame shows up in the browser and flashes once the color its suppose to
>be and then stops animating. Is it a permission problem? Did I call
>the image wrong in my script? Thanks for the help...
This looks like a browser issue to me. Check the file using all the popular
browsers. In some instances, the animated gif is played through once and
then stopped. use the loop parameter inside the <img> tag (check your html
docs). Try this:
<img src=\"http://my.machine.com/icons/green_ball.gif\" LOOP="infinite">
and check it then. Alternately, verify it in several browsers first, some
older versions do not default to infinite loops of animated.gif files.
Richard
------------------------------
Date: 18 Oct 1999 20:50:25 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: animated gif won't blink
Message-Id: <7ug16h$6je$1@gellyfish.btinternet.com>
In comp.lang.perl.misc mr_potato_head@my-deja.com wrote:
> Hi,
> I have apache 1.3.4 installed on my ultra1 running solaris 2.6 and I
> can't get the animated gif to blink.
Oh my blessed aunt !
I thought that mr_potato_head was just some over cutesy Usenet handle
but now I am coming round to the view that this character really has
got starchy vegetable matter between his plastic ears ... but how does he
type with those pudgy three fingered hands and no arms ?
/J\
--
Jonathan Stowe <jns@gellyfish.com>
<http://www.gellyfish.com>
Hastings: <URL:http://dmoz.org/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: 18 Oct 1999 20:30:37 GMT
From: petolino@joe.Eng.Sun.COM (Joe Petolino)
Subject: Re: Baffled!
Message-Id: <7ug01d$8er$1@engnews2.Eng.Sun.COM>
>A few weeks ago, I suggested that the use of a literal string as the
>first argument to split() should draw a warning. If that were the case
>(and assuming the programmer used '-w'), this incessant problem *might*
>go away!
Good idea. Is it even defined what happens when you use a literal string
that can't be parsed as a regular expression match? The documentation of
split(), both in the Camel book and in perlfunc, says nothing about it
except for the special case of ' '.
-Joe
------------------------------
Date: Mon, 18 Oct 1999 16:16:50 -0500
From: "Spike White" <spike_YYwhiteYY@YYdellYY.com>
Subject: Re: can i make a cgi run it self
Message-Id: <7ug2fe$7vj$1@galaxy.us.dell.com>
Brett W. McCoy wrote in message ...
>Also Sprach Yuval Hamberg <yhm@inter.net.il>:
>
>>Can I make a CGI script run let say at 11:55PM every night automatically?
>
>Depends on whether or not your operating system will let you run regularly
>scheduled processes.
Most every OS does. For the common ones that don't (and even the ones
that do), there's about a bazillion job scheduling packages that allow you
to
do this.
------------------------------
Date: Mon, 18 Oct 1999 15:16:44 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Data structure problem. Please help!
Message-Id: <x3yr9isbht0.fsf@tigre.matrox.com>
Zhengdong Zhang <zzhang@bayou.uh.edu> writes:
> The hash %selected_individuals has a even number of key-value pairs.
> The key is a common integer. The value is an array reference. Every
> array element is a hash reference. This hash has one key-value pair.
I can't tell for sure, but I have a feeling that you can use a simpler
data structure. But anyway, "if it ain't broken, don't fix it."
> @k = keys %selected_individuals;
> $i = 0;
> for ($i = 0; $i < @k; $i+=2)
> {
> $cross_point = int(rand(2 * $num_oth)); ### randomly pick a
> crossover point.
What is $num_oth? How does it relate to the length of the array
@{$selected_individuals{$k[$i]}} ? How big can $cross_point become?
> for $j (0..$cross_point)
> {
> %temp = %{$selected_individuals{$k[$i]}->[$j]};
> ### line 214 @{$selected_individuals{$k[$i]}} ?
If the array @{$selected_individuals{$k[$i]}} has fewer elements than
$cross_point, then you will be trying to access an undefined value,
and then treating it as an array ref. This is the source of your
problem.
If you are sure that $cross_point is the total number of elements in
the array, then you should subtract 1 from it:
for $j (0 .. $cross_point-1) {
> Your suggestion will be appreciated.
I suggest you add some print() statements in your code just to check
the size of your array, it's contents, and the value of
$cross_point. This will surely lead you to the solution.
HTH,
--Ala
------------------------------
Date: Mon, 18 Oct 1999 13:10:23 -0700
From: Santosh Joseph <sjoseph7@worldnet.att.net>
Subject: embedding perl in win32
Message-Id: <380B7EAF.E7DD674A@worldnet.att.net>
So, I downloaded the most recent ActiveState perl (520) and started
reading the perlwin32faq10: Embedding and Extending
I copied and pasted the first example and I get these errors when I
compile:
****************
MyPerl.cpp
C:\Perl\lib\CORE\perlhost.h(41) : error C2065: 'win32_mkdir' :
undeclared identi
fier
C:\Perl\lib\CORE\perlhost.h(45) : error C2065: 'win32_chdir' :
undeclared identi
fier
C:\Perl\lib\CORE\perlhost.h(49) : error C2065: 'win32_rmdir' :
undeclared identi
fier
MyPerl.cpp(52) : error C2352: 'CPerlObj::Perl_newXS' : illegal call of
non-stati
c member function
****************
My Makefile and MyPerl.cpp look exactly the same as in the faq. Is
there a compiler switch that should be included? Has anybody been able
to sucessfully compile this example?
I was able to build win32 perl on my machine.
Thanks,
-Santosh
------------------------------
Date: Mon, 18 Oct 1999 19:20:42 GMT
From: pacman@defiant.cqc.com (Alan Curry)
Subject: Re: encryption and crypt() ?
Message-Id: <eqKO3.14928$E_1.870775@typ11.nn.bcandid.com>
In article <MPG.12750deb490f435198a0b9@nntp.hpl.hp.com>,
Larry Rosler <lr@hpl.hp.com> wrote:
>In article <JnJO3.14697$E_1.861761@typ11.nn.bcandid.com> on Mon, 18 Oct
>1999 18:09:45 GMT, Kragen Sitaker <kragen@dnaco.net> says...
>> because most of them pass the whole password entry.
>
>As they should, because why waste a useless substr?
And because if the "pure perl crypt()" is intended to be compatible with the
system's libc crypt(), it can't assume the old DES two-character-salt
algorithm all the time.
perl -le 'print crypt q/pass/,q/$1$sucker/'
$1$sucker$hDt2ALSxSrkO11UYVsFUb/
perl -le 'print crypt q/pass/,q/$1$sucker$hDt2ALSxSrkO11UYVsFUb/'
$1$sucker$hDt2ALSxSrkO11UYVsFUb/
perl -le 'print crypt q/pass/,q/$1/' # oops
$1IXJmemGtVUI
If it's only intended for systems without a libc crypt(), though, I guess
this doesn't matter.
--
Alan Curry |Declaration of | _../\. ./\.._ ____. ____.
pacman@cqc.com|bigotries (should| [ | | ] / _> / _>
--------------+save some time): | \__/ \__/ \___: \___:
Linux,vim,trn,GPL,zsh,qmail,^H | "Screw you guys, I'm going home" -- Cartman
------------------------------
Date: 18 Oct 1999 21:31:57 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: equiv. of nice & simple ksh syntax
Message-Id: <7ug3kd$6pa$1@gellyfish.btinternet.com>
On Mon, 18 Oct 1999 17:58:06 +0100 Mark Hamlin wrote:
> Below is the Korn script outline, how do I achieve this in Perl. I want to
> keep
> the simplicity of the Korn method, ie :
>
> 1) no external requirements such as modules - no DBI!,
> 2) readability,
>
<snip example of reading to and writing too process>
I would suggest using the module IPC::Open2 which is part if the standard
Perl distribution - but if you really will insist on not using *any*
modules then you could do something like this :
#!/usr/bin/perl
$yow =<<`EEEK`;
2>/dev/null dbaccess tdcusers - <<ZOW
select * from codes
ZOW
EEEK
print $yow
Of course you will want to use whatever external program it is you want
to use ...
/J\
--
Jonathan Stowe <jns@gellyfish.com>
<http://www.gellyfish.com>
Hastings: <URL:http://dmoz.org/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: 18 Oct 1999 20:29:57 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: file xfer via modem
Message-Id: <7ug005$6ja$1@gellyfish.btinternet.com>
On Sun, 17 Oct 1999 20:22:10 +1700 Aaron Lister wrote:
> I need to be able to transfer a file via a modem. I want this to be
> automated. Does anyone know if a module exists that may allow me to do
> this. If not, any suggestions?
>
XModem, YModem. Zmodem, Kermit, UUCP ? Some proprietary protocol ?
I'd take a look at CPAN <http://www.cpan.org> and see if any one of
the hundreds of modules there that will suit your purpose - as without
any more information there is little we can advise ...
/J\
--
Jonathan Stowe <jns@gellyfish.com>
<http://www.gellyfish.com>
Hastings: <URL:http://dmoz.org/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Mon, 18 Oct 1999 23:36:59 +0100
From: "dane" <dane@forum.dk>
Subject: Re: got it working, thx :)
Message-Id: <EqMO3.628$Oh5.865@news.get2net.dk>
only one problem now:
$ENV{'REMOTE_HOST'} returns a blank :Oo
Any clues?
Jason P Tribbeck <jtribbeck@argogroup.com> skrev i en
nyhedsmeddelelse:380AC589.B9DBE8A0@argogroup.com...
> dane wrote:
> >
> > I have been trying to make this script work for quite some time now.
> > I have added this line to my html file:
> > <!--#exec cgi="/cgi-bin/get.cgi" -->
> > and the get.cgi file looks like this:
> >
> > #!/usr/local/bin/perl
> > print <<end;
> > Content-Type: text/html
> > end
> >
> > #search for dk in Host Addr. string
> > if($ENV{'REMOTE_HOST'} =~ /dk/)
> > { print <<end;
> > <p>ok from Denmark</p>
> > end }
> > else
> > { print <<end;
> > <p>not from dk</p>
> > end }
>
>
> Above and beyond the structure of the PERL code above, you must have a
> blank line after all the headers, so put a blank line after the
> Content-Type: line - ie.
>
> print <<end;
> Content-Type: text/html
>
> end
>
> --
> Jason Tribbeck Argo Interactive
> ltd
> Senior Design Engineer 7 Dukes Court,
> Chichester
> West Sussex, PO19
> 2FX
> Tel: +44 1243 815 815 Fax: +44 1243 815 805
> England
------------------------------
Date: Mon, 18 Oct 1999 16:18:06 -0500
From: "Nolen Johnson" <nolenj@worldnet.att.net>
Subject: Re: Ignore the idiots
Message-Id: <7ug1nh$1de$1@bgtnsc03.worldnet.att.net>
Is Abigail a "he"?
if so, why a woman's name?
just wondering.....
<emlyn_a@my-deja.com> wrote in message news:7udqgp$kh1$1@nnrp1.deja.com...
> Ignore Abigail - People like him make this place a whole lot more
> intimidating to use (which is their intent, I think). I mean what hell
> is this forum for if you can't ask a simple Perl question like you did?
>
> Someone should boot his ass.
>
> Don't know the answer (I'm still learning myself), but have fun.
>
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
------------------------------
Date: 18 Oct 1999 19:45:04 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Ignore the idiots
Message-Id: <7uftc0$6is$1@gellyfish.btinternet.com>
On Mon, 18 Oct 1999 00:44:10 GMT emlyn_a@my-deja.com wrote:
> Ignore Abigail - People like him make this place a whole lot more
> intimidating to use (which is their intent, I think). I mean what hell
> is this forum for if you can't ask a simple Perl question like you did?
>
Ignore this fool - People like this make this place all the more worthless
for these seeking information that perhaps they couldnt find from the
most cursory examination of the documentation.
> Someone should boot his ass.
>
Everyone should *plonk* you.
> Don't know the answer (I'm still learning myself), but have fun.
>
If you didnt know the answer and have nothing to contribute why did you
post whining about people not giving the answers to questions that even
the most brief attempt at discovering the answers from the documentation
would have shed some light.
*plonk*
/J\
--
Jonathan Stowe <jns@gellyfish.com>
<http://www.gellyfish.com>
Hastings: <URL:http://dmoz.org/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Mon, 18 Oct 1999 19:11:31 GMT
From: Rob Bertegerer <a79543@yahoo.com>
Subject: MS VC++ setting for embedding Perl Interpreter in C/C++ program
Message-Id: <7m8LOCPoHx5Xt2VCbh7ZnpRrndC7@4ax.com>
Hi,
I'm having difficulties embedding the perl interpreter into a MS C++
project files. It can't find any of the libraries extern.h, etc ...
I can embed the perl interpreter just fine if I take the makefile
approach specified in the activestate documentation, but I can't
get it to work within the visual environment.
Any suggestions would be welcome
Thanks
------------------------------
Date: Mon, 18 Oct 1999 15:18:21 -0400
From: "T. Wilson" <twilson@peruseweb.com>
Subject: need cgi script
Message-Id: <380B727D.F5AADC43@peruseweb.com>
Willing to pay for:
I need a simple autoresponder as follows:
1. the user fills out an online form
2. the form data is sent to a specified email address
3. the user recieves a confirmation email
It must be configuable for use on multiple domains with different email
addresses.
Please send quote
Thanks
T. Wilson
--
Peruse Web Development
1712-1375 Prince of Wales Dr.
Ottawa, ON
K2C 3L5
phone (613) 723-1594
fax (613) 727-1402
http://www.peruseweb.com
------------------------------
Date: Mon, 18 Oct 1999 20:10:34 GMT
From: Mike Salter <msalter@bestweb.net>
Subject: Re: need cgi script
Message-Id: <Pine.BSF.4.05.9910181608250.23904-100000@monet.bestweb.net>
On Mon, 18 Oct 1999, T. Wilson wrote:
TW>Willing to pay for:
TW>
TW>I need a simple autoresponder as follows:
TW>
TW>1. the user fills out an online form
TW>2. the form data is sent to a specified email address
TW>3. the user recieves a confirmation email
TW>
Go to Yahoo and search on formmail, as this is the standard script as I
recall for doing this sort of thing. If the author doesn't charge for it,
send him a donation or something.
Mike
------------------------------
Date: Mon, 18 Oct 1999 16:31:06 -0500
From: Cameron Dorey <camerond@mail.uca.edu>
Subject: Re: need cgi script
Message-Id: <380B919A.6676D810@mail.uca.edu>
"T. Wilson" wrote:
>
> Willing to pay for:
>
> [uninteresting off-topic blather snipped]
>
> [interesting off-topic question retained]
> Please send quote
"Never attribute to malice what can be adequately explained by
stupidity." - Anon.
"The optimist thinks this is the best of all possible worlds, and the
pessimist knows it." - J. Robert Oppenheimer
"You can lead a horse to water, but if you can get him to float on his
back, you've got something." - Anon.
Three of my favorite quotes. I'll take a check, but I prefer cash.
Cameron
--
Cameron Dorey
Associate Professor of Chemistry
University of Central Arkansas
Phone: 501-450-5938
camerond@mail.uca.edu
------------------------------
Date: 18 Oct 1999 20:03:46 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: OT: Din paper sizes (was Re: PDFlib size settings)
Message-Id: <7ufuf2$6j5$1@gellyfish.btinternet.com>
On Sat, 16 Oct 1999 00:22:35 +0930 Henry Penninkilampi wrote:
> In article <37FDFA26.51DFD78D@inx.de>, Daniel Krajzewicz
> <krajzewicz@inx.de> wrote:
>
>> Do someone know how to encode the german DIN A4-norm ?
>
> I don't know what DIN stands for, but the dimensions for A4 are 595x842
> points, if that helps.
>
Is that right ? I do know that the ratio of the sides is exactly 1:sqrt(2)
and (unless gnu bc is bugged )
(842 / 595)^2
2.00258173857778405477
Not that one would notice that difference on a gnats cock over 11" anyway ;-}
/J\
--
Jonathan Stowe <jns@gellyfish.com>
<http://www.gellyfish.com>
Hastings: <URL:http://dmoz.org/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: 18 Oct 1999 21:16:37 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: OT: Din paper sizes (was Re: PDFlib size settings)
Message-Id: <slrn80n3hl.eht.sholden@pgrad.cs.usyd.edu.au>
On 18 Oct 1999 20:03:46 -0000, Jonathan Stowe <gellyfish@gellyfish.com> wrote:
>On Sat, 16 Oct 1999 00:22:35 +0930 Henry Penninkilampi wrote:
>> In article <37FDFA26.51DFD78D@inx.de>, Daniel Krajzewicz
>> <krajzewicz@inx.de> wrote:
>>
>>> Do someone know how to encode the german DIN A4-norm ?
>>
>> I don't know what DIN stands for, but the dimensions for A4 are 595x842
>> points, if that helps.
>>
>
>Is that right ? I do know that the ratio of the sides is exactly 1:sqrt(2)
Since sqrt(2) is irrational, how can that be possible?
--
Sam
The very fact that it's possible to write messy programs in Perl is also
what makes it possible to write programs that are cleaner in Perl than
they could ever be in a language that attempts to enforce cleanliness.
--Larry Wall
------------------------------
Date: Mon, 18 Oct 1999 19:59:19 GMT
From: emlyn_a@my-deja.com
Subject: Re: Q: Truncate string length?
Message-Id: <7ufu6f$n0$1@nnrp1.deja.com>
> how'd you get s close and not get it? don't you have The Book?
>
> $TheField = substr($TheField, 0, 500);
>
> hth-
> --
> Michael Budash ~~~~~~~~~~ mbudash@sonic.net
>
Ha ha. I didn't realize you could make a $var equal to a substr($var,
0, 500).
Thanks.
Emlyn
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 18 Oct 1999 13:44:39 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: shifting a hash
Message-Id: <x3yso38bm2i.fsf@tigre.matrox.com>
Tom Kralidis <tom.kralidis@ccrs.nrcanDOTgc.ca> writes:
> key value
>
> 33.44 444
> 55.69 741
> 88.88 777
>
> The has gets created by a foreach loop, with:
>
> push(@{ $errorList{$error} }, $pointID );
>
> The has gets sorted so that the highest key's value is returned, then
> used to zero weight the key's value in another file. The above case
> would return value 777, with the following code:
>
> foreach (reverse sort keys %errorList)
This sorts lexicographically. You don't want that since your keys are
numbers. Sort numerically:
foreach (sort { $b <=> $a } keys %errorList) {
Notice how I dropped the reverse() by interchanging $a and
$b. Convenient (and probably faster too, but I didn't benchmark).
> For each iteration of this process, I would like to shift (delete the
> first value) the has so that the script looks for a value that has not
> been zero-weighted in the previous loop. I have tried:
>
> shift(@{ $errorList{$error} }, $pointID );
>
> to remove the first key - value, and return the highest value's key that
> has not been used by the loop, but no luck.
>
> Does anyone have any advice on this? Am I better useing a
> multi-dimensional array?
It depends. Do you want to keep the already-zero-weighted elements in
the hash? If not, then simply use the delete() function to delete
whatever keys you don't need.
If, OTOH, you want to ignore them, but keep them in the hash, then I
would create a temporary array of zero-weighted keys. Then, in each
iteration, you can check to see if your key exists in this temp array
(or maybe even a hash). If it does, skip to the next key.
{
my %seen;
foreach (sort { $b <=> $a } keys %errorList) {
# Skip if you have seen this key before.
next if exists $seen{$_};
# If we reached here, then we haven't seen
# this key before.
# Do whatever you want with $_.
# Set %seen appropriately.
$seen{$_} = 1;
}
}
Maybe you can even use grep() in the foreach() expression to filter
your already-zero-weighted keys.
The possibilities are numerous. It depends on what you want.
HTH,
--Ala
------------------------------
Date: Mon, 18 Oct 1999 18:59:36 GMT
From: secnarf@my-deja.com
Subject: sorting arrays
Message-Id: <7ufqmi$u1j$1@nnrp1.deja.com>
I have the contents of a table in an array. I only want to sort the by
the contents of the first line of the table row, which looks like -
<TR><TD>xxxx</TD>. Can I use sort for this? How can I set the <TR> as
the delimiter? Is there an easier way to accomplish this?
I really just need ideas.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 18 Oct 1999 19:46:49 GMT
From: bmccoy@foiservices.com (Brett W. McCoy)
Subject: Re: sorting arrays
Message-Id: <slrn80muhm.as8.bmccoy@moebius.foiservices.com>
Also Sprach secnarf@my-deja.com <secnarf@my-deja.com>:
>I have the contents of a table in an array. I only want to sort the by
>the contents of the first line of the table row, which looks like -
><TR><TD>xxxx</TD>. Can I use sort for this? How can I set the <TR> as
>the delimiter? Is there an easier way to accomplish this?
>
>I really just need ideas.
Take a look at the documentation for the sort function: perldoc -f sort.
You can do all kinds of stuff with it. The important thing is to have
your data organized properly so you can sort it the way you want.
--
Brett W. McCoy bmccoy@foiservices.com
Computer Operations Manager (Alpha Geek) http://www.foiservices.com
FOI Services, Inc./DIOGENES 301-975-0110
---------------------------------------------------------------------------
------------------------------
Date: Mon, 18 Oct 1999 13:25:43 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Unix Utilities: Perl Versions
Message-Id: <x3yu2nobmy0.fsf@tigre.matrox.com>
bayinnaung@my-deja.com writes:
> I came across a page full of Unix utilities that
> had been rewritten in Perl about a week ago.
> I believe the author was Tom Christiansen...
> and I cannot find it again...you'd think that there
> would be a lot of links to it...
You mean the PPT (Perl Power Tools) ?
> Does anyone know where it is?
sure:
http://language.perl.com/ppt/
--Ala
------------------------------
Date: 18 Oct 1999 20:04:23 GMT
From: damian@cs.monash.edu.au (Damian Conway)
Subject: Re: Uses of #
Message-Id: <7ufug7$e7b$1@towncrier.cc.monash.edu.au>
tgy@chocobo.org (Neko) writes:
>> I would write a verse
>> of haiku to show the point,
>> but I'm not that good. :-)
> To be pedantic,
> the word 'haiku' has three
> not two syllables
Three when it's at home.
For gaijin, only two.
So the Oxford says.
Damian
------------------------------
Date: 18 Oct 1999 21:05:23 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: variables on the right side one Reg Exp
Message-Id: <7ug22j$6o6$1@gellyfish.btinternet.com>
On 18 Oct 1999 02:09:08 -0400 Garrett Walker wrote:
>
Yes.
/J\
--
Jonathan Stowe <jns@gellyfish.com>
<http://www.gellyfish.com>
Hastings: <URL:http://dmoz.org/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Mon, 18 Oct 1999 19:48:42 GMT
From: bmccoy@foiservices.com (Brett W. McCoy)
Subject: Re: what is SHTML ?
Message-Id: <slrn80mul6.as8.bmccoy@moebius.foiservices.com>
Also Sprach David Christensen <dchristensen@california.com>:
>>i know what HTML is, but what is SHTML ?
>
>I think it is an acronym for "scripted HTML" -- e.g. an html page
>that contains scripting code. You name your file foo.shtml to
>alert your web server that it needs to interpret the page and not
>just send it.
SHTML typically means the page contains a server-side include
(SSI) or some other kind of server directive.
--
Brett W. McCoy bmccoy@foiservices.com
Computer Operations Manager (Alpha Geek) http://www.foiservices.com
FOI Services, Inc./DIOGENES 301-975-0110
---------------------------------------------------------------------------
------------------------------
Date: Mon, 18 Oct 1999 17:27:34 -0400
From: "Jim" <golf@tfz.net>
Subject: WHATS WRONG WITH THIS CODE?
Message-Id: <7ug3f0$lvk$1@bgtnsc01.worldnet.att.net>
#!/usr/bin/perl
print "Content-Type: text/html\n\n";
print "<HTML><HEAD>\n";
print "<TITLE>CGI Test</TITLE>\n";
print "</HEAD>\n";
print "<BODY><A HREF=\"http://someplace.com\">Click Here</A>\n";
print "</BODY></HTML>";
It gives me a 500 error. All I want to know is if there are any errors in
this code. thanks
Jim
------------------------------
Date: 18 Oct 1999 03:53:54 GMT
From: Dan Nguyen <nguyend7@msu.edu>
Subject: Re: why don't this darm s..... work
Message-Id: <7ue5ki$fra$1@msunews.cl.msu.edu>
dane <dane@forum.dk> wrote:
: #!/usr/local/bin/perl
: print "Content-Type: text/html\n\n";
: #search for dk in Host Addr. string
: if($ENV{'REMOTE_HOST'} =~ /dk/) {
: print "<p>ok from Denmark</p>";
: }
: else {
: print "<p>not from dk</p>";
: }
1.) You shouldn't make things more complicated then they are.
2.) And just testing for dk is wrong since some host will have dk in
the middle. Try /\.dk$/
: "Premature end of script headers"
3.) Premature end of scipt headers is the error return to the
browser. Check the web server's error log for more valuable info.
--
Dan Nguyen | It is with true love as it is with ghosts;
nguyend7@msu.edu | everyone talks of it, but few have seen it.
dnn@debian.org | -Maxime De La Rochefoucauld
25 2F 99 19 6C C9 19 D6 1B 9F F1 E0 E9 10 4C 16
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V9 Issue 1110
**************************************