[25008] in Perl-Users-Digest
Perl-Users Digest, Issue: 7258 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Oct 15 21:07:05 2004
Date: Fri, 15 Oct 2004 18:05:06 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 15 Oct 2004 Volume: 10 Number: 7258
Today's topics:
Re: (Newbie) Use of uninitialized value in concatenatio <jurgenex@hotmail.com>
Re: A newbie question <tadmc@augustmail.com>
Re: A newbie question <sbryce@scottbryce.com>
Re: A newbie question <moon@world.universe>
Re: A newbie question <1usa@llenroc.ude.invalid>
Re: A newbie question <spamtrap@dot-app.org>
A perl reporting paradigm?? <noemail@#$&&!.net>
Re: A perl reporting paradigm?? <spamtrap@dot-app.org>
Re: A perl reporting paradigm?? <usa1@llenroc.ude.invalid>
Re: hard references/arrays <tintin@invalid.invalid>
Re: Help needed replacing deprecated syntax <noreply@gunnar.cc>
Re: Help needed replacing deprecated syntax <noreply@gunnar.cc>
Re: HTML::Parser and <p> behaviour? <bigal187@removethis.rx.eastcoasttfc.com>
Re: HTML::Parser and <p> behaviour? <bigal187@removethis.rx.eastcoasttfc.com>
Re: HTML::Parser and <p> behaviour? <bigal187@removethis.rx.eastcoasttfc.com>
Re: HTML::Parser and <p> behaviour? <bigal187@removethis.rx.eastcoasttfc.com>
Re: HTML::Parser and <p> behaviour? <geoff.cox@removethisplease.freeuk.com>
Lowest array value given index (Jim)
Re: Lowest array value given index <1usa@llenroc.ude.invalid>
Re: Lowest array value given index <noreply@gunnar.cc>
Re: Lowest array value given index <tadmc@augustmail.com>
Re: Lowest array value given index <dha@panix.com>
Re: Lowest array value given index <clydenospamorham@nospamorhamgetofftheline.freeservenospamorham.co.uk>
Re: Lowest array value given index <jurgenex@hotmail.com>
PCPRINT+CRLF perl script vjp2.at@at.BioStrategist.dot.dot.com
Re: python for perl programmers? <mkc@stowers-institute.org>
Re: Top posting (was Re: Concatenating an array into on <usenet@morrow.me.uk>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 15 Oct 2004 21:47:20 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: (Newbie) Use of uninitialized value in concatenation (.) or string
Message-Id: <IzXbd.79$EP4.41@trnddc06>
Jesse Cary wrote:
> I am making a script that issues commands, pulls certain text from the
> results and puts that text into an HTML table. I got the first two
> columns to display fine and used my method as a template to fill the
> third column, but I get the error stated in the subject line.
> Below is the code and the text I am pulling the date from;
>
> #CODE#
[snipsnap]
You are missing
use strict;
use warnings;
Add those, clean up your code until you are strict and warning clean, and
chances are your problem will be gone.
If not then please repost your cleaned up and I'm sure someone will be able
to help you.
jue
------------------------------
Date: Fri, 15 Oct 2004 13:13:35 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: A newbie question
Message-Id: <slrncn04qf.7qk.tadmc@magna.augustmail.com>
Moon <moon@world.universe> wrote:
> learning Perl is not my goal, I just want
> to know how to convert a particular Perl script into C.
You will need to learn Perl if you want to translate from Perl.
> I wanted to avoid (by asking experts) getting through
> hundredths of Perl docs and examples about regexps.
Oh I see.
I will take the appropriate action, so long!
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 15 Oct 2004 12:56:12 -0600
From: Scott Bryce <sbryce@scottbryce.com>
Subject: Re: A newbie question
Message-Id: <10n07adhag1ba9@corp.supernews.com>
Moon wrote:
> I wanted to avoid (by asking experts) getting through
> hundredths of Perl docs and examples about regexps.
The irony here is that before I have posted a response to this thread, I
have checked the docs and run a test program. So you save yourself the
trouble, but put me and others through the trouble.
A question or two is fine, we are happy to help out, but using us as a
resource instead of using the docs and Perl itself as a resource is
something different.
You will find in this NG that the people who get the most help are those
who demonstrate that the have put some work into solving the problem
themselves.
------------------------------
Date: Fri, 15 Oct 2004 23:55:21 +0200
From: Moon <moon@world.universe>
Subject: Re: A newbie question
Message-Id: <ylu0jw9qi6x9$.1p6btj31wijfs.dlg@40tude.net>
Dnia Fri, 15 Oct 2004 13:13:35 -0500, postmaniak Tad McClellan odważył się
napisać:
> I will take the appropriate action, so long!
I see you do not identify yourself with the open-source software. Pity! So
long!
--
<Moon>
[adres Reply-To zaszyfrowany ROT13]
------------------------------
Date: 15 Oct 2004 22:03:55 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: A newbie question
Message-Id: <Xns9583B7C532457asu1cornelledu@132.236.56.8>
Moon <moon@world.universe> wrote in
news:ylu0jw9qi6x9$.1p6btj31wijfs.dlg@40tude.net:
> Dnia Fri, 15 Oct 2004 13:13:35 -0500, postmaniak Tad McClellan odważył
> się napisać:
>
>> I will take the appropriate action, so long!
>
> I see you do not identify yourself with the open-source software.
What does _that_ have to do with you being a lazy freeloader?
> Pity! So long!
Good riddance.
------------------------------
Date: Fri, 15 Oct 2004 18:58:20 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: A newbie question
Message-Id: <1tOdnVzROtGRy-3cRVn-qQ@adelphia.com>
Moon wrote:
> to know how to convert a particular Perl script into C. And as in C there
> are no *regexps*
They're not a core part of the language, that's true - but you can use
regular expressions in C. Perl-compatible regular expressions, at that.
<http://www.pcre.org>
sherm--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
------------------------------
Date: Fri, 15 Oct 2004 19:43:47 -0400
From: Fred <noemail@#$&&!.net>
Subject: A perl reporting paradigm??
Message-Id: <pan.2004.10.15.23.43.46.953159@#$&&!.net>
The code that follows is unclear to me. (You have to look at the listing
at bottom.)
The thing I don't get is this line: my $x = <<LINE;
and this line is obviously terminated by this line:
LINE
So having said that, I employed code today such as this to crank out a
smartly formatted report for the suits. But it was only by virtue of the
fact that I had lurked here and found it. I entitled this post: "A perl
reporting paradigm??" because I found the facilty of this code to be
noteworthy in and of itself. I really do not understand what is
transpiring in the netherworld of the spaces between:
my $x = <<LINE;
Check Out my Formatted Data...
With this nifty multiline perl
stuff..... $fred
$y
LINE
All I do know is, without benefit of understanding, I produced a report
that left everyone happy.
I insist on referring to this bit of code as a paradigm becuase it so
easily facilitates the generation of a smartly formatted report. And as
such it should (IMHO) have a place in the docs. (Ok if it does, I didn't
know what to call 'it')
So what I am seeking is the "big picture" for this code.
Thanks in advance, and I *think* it was Sinaur (?) who I got this style
from.
Fred, aka Fred
#******************************
use strict;
use warnings;
my $fred = "25";
my $dash = "-" x 50;
my $y = "END OF LINES";
my $x = <<LINE;
Check Out my Formatted Data...
With this nifty multiline perl
stuff..... $fred
$y
LINE
print "$dash\n$x\n$dash";
------------------------------
Date: Fri, 15 Oct 2004 20:49:43 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: A perl reporting paradigm??
Message-Id: <t7mdnZRzybG17e3cRVn-pw@adelphia.com>
Fred wrote:
> The code that follows is unclear to me.
It's called a "here-doc". It's described in "perldoc perlop", in the
"Quote and Quote-like Operators" section.
sherm--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
------------------------------
Date: 16 Oct 2004 00:55:03 GMT
From: "A. Sinan Unur" <usa1@llenroc.ude.invalid>
Subject: Re: A perl reporting paradigm??
Message-Id: <Xns9583D515ED41Fasu1cornelledu@132.236.56.8>
Fred <noemail@#$&&!.net> wrote in
news:pan.2004.10.15.23.43.46.953159@#$&&!.net:
>
> Thanks in advance, and I *think* it was Sinaur (?) who I got this style
> from.
Assuming you are referring to me, let me point out that, while I would very
much like to, I cannot take credit for here-docs.
Do read
perldoc perlop
as Sherm has recommended.
S i n a n
------------------------------
Date: Sat, 16 Oct 2004 07:48:34 +1300
From: "Tintin" <tintin@invalid.invalid>
Subject: Re: hard references/arrays
Message-Id: <2taka3F1tflofU1@uni-berlin.de>
"Brian McCauley" <nobull@mail.com> wrote in message
news:ckoalr$qu6$1@sun3.bham.ac.uk...
> Tintin wrote:
>
>> "Brian McCauley" <nobull@mail.com> wrote in message
>> news:cklnl4$ied$1@sun3.bham.ac.uk...
> >
>>> push @insert_record => map { @$_[0..5] } @record{'ADDRESS','ELEMENT'};
> >
>> needs to be
>>
>> push @insert_record => map { @{$_}[0..5] } @record{'ADDRESS','ELEMENT'};
>
> Not from perl's perspective it doesn't (for details 'perldoc perlref').
Hmm. On the Perl version I was using (5.8.3 I think), I'm pretty certain it
made a difference. However, I've just tested with 5.8.0 and you are
correct, it makes no difference.
I'll have to double check the results on the platform I had the production
code on.
------------------------------
Date: Fri, 15 Oct 2004 17:17:53 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Help needed replacing deprecated syntax
Message-Id: <2ta846F1svfd5U1@uni-berlin.de>
Page wrote:
> Ok. It's the first line of a function that may or may not have a
> string value parameter passed to it. Basically I'm just setting
> $msg to that parameter, then I check to see if it has a value like
> this: if ($msg ne "") { ... do stuff... }
That test is inappropriate, since $msg will be undef if nothing is
passed to the function. Maybe you mean:
if (defined $msg) { ... do stuff... }
By having warnings enabled, you catch that kind of mistake.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Fri, 15 Oct 2004 17:32:56 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Help needed replacing deprecated syntax
Message-Id: <2ta90eF1skiobU1@uni-berlin.de>
Page wrote:
> Ok. It's the first line of a function that may or may not have a
> string value parameter passed to it. Basically I'm just setting
> $msg to that parameter, then I check to see if it has a value like
> this: if ($msg ne "") { ... do stuff... }
That test is inappropriate, since $msg will be undef if nothing is
passed to the function. Maybe you mean:
if (defined $msg) { ... do stuff... }
By having warnings enabled, you catch that kind of mistake.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Fri, 15 Oct 2004 09:27:30 -0700
From: "187" <bigal187@removethis.rx.eastcoasttfc.com>
Subject: Re: HTML::Parser and <p> behaviour?
Message-Id: <2tac3qF1t9mh8U1@uni-berlin.de>
Anno Siegel wrote:
> 187 <bigal187@removethis.rx.eastcoasttfc.com> wrote in
> comp.lang.perl.misc:
>> Tad McClellan wrote:
>>> Pinocchio (aka: Fred Canis, aka: 187, aka: krakle...)
>>> <spambiat@yahoo.com> wrote:
>>
>> * removes himself from that list *
>>
>> I had a bad day, I don't normally type that bad, /please/ don't
>> associate me with usenet holigans like that *shudders* :-)
>
> Eh... pinoccio? How's your nose?
A little runny lately (bad cold.) My name is Al though. Not knowing the
past deal is here (maybe I'll run a search over at Google's archives.
What ever it is, I want everyone to know my name was incorrectly placed
in Tad's little list (not sure if it was in jest or not.) any ways,
since I know I'm not a part of that, it doesn't matter much on my end,
so in the words of Paul Harvey, "Goooo'Day?!"
------------------------------
Date: Fri, 15 Oct 2004 09:39:22 -0700
From: "187" <bigal187@removethis.rx.eastcoasttfc.com>
Subject: Re: HTML::Parser and <p> behaviour?
Message-Id: <2tad3qF1t9uihU1@uni-berlin.de>
Anno Siegel wrote:
> 187 <bigal187@removethis.rx.eastcoasttfc.com> wrote in
> comp.lang.perl.misc:
>> Tad McClellan wrote:
>>> Pinocchio (aka: Fred Canis, aka: 187, aka: krakle...)
>>> <spambiat@yahoo.com> wrote:
>>
>> * removes himself from that list *
>>
>> I had a bad day, I don't normally type that bad, /please/ don't
>> associate me with usenet holigans like that *shudders* :-)
>
> Eh... pinoccio? How's your nose?
A little runny lately (bad cold.) My name is Al [1] though. Not knowing
the
past deal is here (maybe I'll run a search over at Google's archives.
What ever it is, I want everyone to know my name was incorrectly placed
in Tad's little list (not sure if it was in jest or not.) any ways,
since I know I'm not a part of that, it doesn't matter much on my end,
so in the words of Paul Harvey, "Goooo'Day?!"
[1]
For those who don't like nicknames, my name is m!Al(?:fred)? Newmane)!;
------------------------------
Date: Fri, 15 Oct 2004 09:58:42 -0700
From: "187" <bigal187@removethis.rx.eastcoasttfc.com>
Subject: Re: HTML::Parser and <p> behaviour?
Message-Id: <2tadudF1t5vkrU1@uni-berlin.de>
[It seems my reply as shown twice on my end for some reason, my
apologies if it propagates as such.]
------------------------------
Date: Fri, 15 Oct 2004 12:19:51 -0700
From: "187" <bigal187@removethis.rx.eastcoasttfc.com>
Subject: Re: HTML::Parser and <p> behaviour?
Message-Id: <2tam7fF1uc7ecU1@uni-berlin.de>
187 wrote:
> [It seems my reply as shown twice on my end for some reason, my
> apologies if it propagates as such.]
Ok I don't know if it's just showing this way on m, server or if it
propaged liek this, but I know see 3 of my post. My apologies for my
server's slip up.
------------------------------
Date: Fri, 15 Oct 2004 21:08:09 GMT
From: Geoff Cox <geoff.cox@removethisplease.freeuk.com>
Subject: Re: HTML::Parser and <p> behaviour?
Message-Id: <5re0n0hrg0l8855fco77845d8rmo95mjb7@4ax.com>
On Fri, 15 Oct 2004 11:09:24 -0500, Tad McClellan
<tadmc@augustmail.com> wrote:
Tad,
OK - Although I did not intend to upset anyone - and all I can do is
hope that you to take my word for that - it is apparent that I did.
I do value the help that people have given me to date so I must take
note.
That I will do.
Geoff
------------------------------
Date: 15 Oct 2004 11:08:38 -0700
From: jimnl69@hotmail.com (Jim)
Subject: Lowest array value given index
Message-Id: <3966ee66.0410151008.3b38007@posting.google.com>
I'm trying to find an efficient way of finding the lowest value of an
array but starting at a given index. For example:
@array = (0, 0, 1, 2, 0, 1, 1, 1);
$index = 0;
I want to stay on the 1st element.
@array = (0, 0, 1, 2, 0, 1, 1, 1);
$index = 2;
I want to end up on the 5th element.
@array = (0, 0, 1, 2, 0, 1, 1, 1);
$index = 5;
I want to end up on the 1st element.
Any suggestions on an efficient way to do this? Thanks...
Jim
------------------------------
Date: 15 Oct 2004 18:23:10 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Lowest array value given index
Message-Id: <Xns95839257F92D4asu1cornelledu@132.236.56.8>
jimnl69@hotmail.com (Jim) wrote in news:3966ee66.0410151008.3b38007
@posting.google.com:
> Any suggestions on an efficient way to do this? Thanks...
Jim:
Try to explain what you want to achieve. Your examples do not make much
sense and your problem statement can be iterpreted in many different ways.
You will see that if you actually spend effort stating your problem, it
will be easier to solve.
Sinan.
------------------------------
Date: Fri, 15 Oct 2004 18:25:34 GMT
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Lowest array value given index
Message-Id: <yCUbd.6256$d5.52118@newsb.telia.net>
Jim wrote:
> I'm trying to find an efficient way of finding the lowest value of
> an array but starting at a given index. For example:
>
> @array = (0, 0, 1, 2, 0, 1, 1, 1);
> $index = 0;
>
> I want to stay on the 1st element.
>
>
> @array = (0, 0, 1, 2, 0, 1, 1, 1);
> $index = 2;
>
> I want to end up on the 5th element.
>
>
> @array = (0, 0, 1, 2, 0, 1, 1, 1);
> $index = 5;
>
> I want to end up on the 1st element.
Show us one or two ways you have done it so far, and somebody will
probably comment on the efficiency of the method(s) you are using.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Fri, 15 Oct 2004 13:22:56 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Lowest array value given index
Message-Id: <slrncn05c0.7qk.tadmc@magna.augustmail.com>
Jim <jimnl69@hotmail.com> wrote:
> I'm trying to find an efficient way of finding the lowest value of an
> array but starting at a given index.
(sort @array[$index .. $#array])[0]
> @array = (0, 0, 1, 2, 0, 1, 1, 1);
> $index = 0;
>
> I want to stay on the 1st element.
Now you have changed the problem.
Above you said you want the lowest _value_, now it appears that
you want the _index_ of the lowest value.
Which is it?
> @array = (0, 0, 1, 2, 0, 1, 1, 1);
> $index = 5;
>
> I want to end up on the 1st element.
Huh?
I would have thought that you wanted the 5th element there...
> Any suggestions on an efficient way to do this?
My suggestion above is not efficient with respect to time complexity,
but it is efficient with respect to development time.
You did not say what it was exactly that you mean to optimize...
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 15 Oct 2004 20:03:43 +0000 (UTC)
From: "David H. Adler" <dha@panix.com>
Subject: Re: Lowest array value given index
Message-Id: <slrncn0b8v.t1k.dha@panix2.panix.com>
On 2004-10-15, Jim <jimnl69@hotmail.com> wrote:
> I'm trying to find an efficient way of finding the lowest value of an
> array but starting at a given index. For example:
>
> @array = (0, 0, 1, 2, 0, 1, 1, 1);
> $index = 0;
>
> I want to stay on the 1st element.
>
>
> @array = (0, 0, 1, 2, 0, 1, 1, 1);
> $index = 2;
>
> I want to end up on the 5th element.
Something along the lines of
$result = find_lowest_element(@array[$index..$#array])
should solve part of your problem.
[benchmarks]
Holy moley!
Benchmark: timing 500000 iterations of slice, splice...
slice: 351 wallclock secs (183.32 usr + 1.25 sys = 184.57 CPU)
@ 2709.00/s (n=500000)
splice: 2 wallclock secs ( 0.37 usr + 0.02 sys = 0.39 CPU) @
1282051.28/s (n=500000)
Ok, *don't* do that.
$result = find_lowest_element(splice @array, $index);
dha
--
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
The Teletubbies are coming to America.
They must be stopped!
------------------------------
Date: Fri, 15 Oct 2004 23:06:23 GMT
From: "Clyde Ingram" <clydenospamorham@nospamorhamgetofftheline.freeservenospamorham.co.uk>
Subject: Re: Lowest array value given index
Message-Id: <PJYbd.477$TA1.99@newsfe1-win.ntli.net>
Jim,
"Jim" <jimnl69@hotmail.com> wrote in message
news:3966ee66.0410151008.3b38007@posting.google.com...
> I'm trying to find an efficient way of finding the lowest value of an
> array but starting at a given index. For example:
>
> @array = (0, 0, 1, 2, 0, 1, 1, 1);
<SNIP>
My attempt outputs this:
Scan from element 1 (index 0)
[1,2,3,4,5,6,7,8][]
[0,0,1,2,0,1,1,1][]
Lowest value is 0
at element 1
Scan from element 3 (index 2)
[3,4,5,6,7,8][1,2]
[1,2,0,1,1,1][0,0]
Lowest value is 0
at element 5
Scan from element 6 (index 5)
[6,7,8][1,2,3,4,5]
[1,1,1][0,0,1,2,0]
Lowest value is 0
at element 1
That gets the answers you want.
> Any suggestions on an efficient way to do this? Thanks...
"Efficient" compared with what?
It is conventional for you to show us what you have tried.
Otherwise, respondents cannot compare efficiency of their algorithms with
yours.
(And there is the lurking suspicion that you might have tried nothing at
all.
Such a case is often described as a "homework question".)
I used "splice", "push", and a "for"-loop, which are simple enough, but I
make no claims for great efficiency.
How many elements might you encounter in the array in your production
program?
FWIW, my code is below. (Excuse the length of this posting, people.)
Regards,
Clyde
#!/bin/perl -w
use strict;
use Data::Dumper;
local $Data::Dumper::Terse = 1;
local $Data::Dumper::Indent = 0;
my @array = ( 0, 0, 1, 2, 0, 1, 1, 1 );
my @indices = ( 0, 2, 5 );
for my $index ( @indices ) {
# We are going to skip the leading elements of the array, and
# start our scan from the given index.
# $index numbers from 0 (e.g.: 5)
# $element_nr numbers from 1 (e.g.: 6)
my $element_nr = $index+1;
print "\nScan from element $element_nr (index $index)\n";
my @arr = @array; # Copy array, before splicing it
if ( ($index < 0) or ($index > $#arr) ) {
warn "$index: index out of range 0..$#arr. Ignoring\n\n";
next;
}
# Remember ranges of element numbers in skipping and starting portions
# e.g.: (1..5) and (6..8)
my @skipping_element_nrs = ( 1 .. ($element_nr - 1) );
my @starting_element_nrs = ( $element_nr .. (scalar @arr ) );
# Remove the leading $index elements of @arr, into new array @skip
# e.g.: for index 5, we will skip elements (1..5)
my @skip = splice( @arr, 0, $index );
# Print out 2 arrays of element numbers, one from the starting element
# to the end, the second for the element numbers we skipped.
# e.g.: [6,7,8][1,2,3,4,5]
print Data::Dumper->Dump( [
\@starting_element_nrs, \@skipping_element_nrs ] ) . "\n";
# Then print corresponding 2 arrays of elements
# e.g.: [1,1,1][0,0,1,2,0]
print Data::Dumper->Dump( [\@arr, \@skip] ) . "\n";
# Push the skipped elements onto the end of @arr
push( @arr, @skip );
# Scan the re-formed array @arr for the lowest value and its index
my $new_index_of_lowest = 0;
for my $i (1 .. $#arr) {
$new_index_of_lowest = $i if ($arr[$i] <
$arr[$new_index_of_lowest]);
}
# Work out element nr of lowest, with respect to original array,
# remembering that search wraps around the end of the array
my $old_element_nr_of_lowest = ($new_index_of_lowest+$index)%(scalar
@arr)+1;
print "Lowest value is $arr[$new_index_of_lowest]\n";
print "at element $old_element_nr_of_lowest\n";
}
(End of response)
------------------------------
Date: Sat, 16 Oct 2004 00:01:33 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Lowest array value given index
Message-Id: <xxZbd.167$TW4.3@trnddc07>
Jim wrote:
> I'm trying to find an efficient way of finding the lowest value of an
> array but starting at a given index.
Well, you have to look at every single value between your start index and
the end of the array at least once anyway. In other words obviously your
algorithm cannot become better then O(n).
Therefore the straight-forward, linear approach is probably very close to
optimal already:
my $min = $array[$i]; # $i be the given starting index
for (@array[$i..$#array]) {
if ($min > $_) { $min = $_;}
}
print $min;
jue
------------------------------
Date: Fri, 15 Oct 2004 23:22:04 +0000 (UTC)
From: vjp2.at@at.BioStrategist.dot.dot.com
Subject: PCPRINT+CRLF perl script
Message-Id: <ckpm2s$emk$1@reader1.panix.com>
How do I make this as simple as possible using perl instead of sed
pcprint () { sed 's/$//' < $1 >> ~/pcprint.tmp; echo '' >> pcprint.tmp ; /usr/local/bin/pcprint ~/pcprint.tmp ; rm ~/pcprint.tmp ;}
Following is someone's pcprint script
(I'm not sure what $# -eq and cat$* mean)
#!/bin/sh
# pcprint
echo -n '[5i'
if [ $# -eq 0 ]; then
cat
else
cat $*
fi
echo -n '[4i'
- = -
Vasos-Peter John Panagiotopoulos II, Columbia'81+, Bio$trategist
BachMozart ReaganQuayle EvrytanoKastorian
http://ourworld.compuserve.com/homepages/vjp2/vasos.htm
---{Nothing herein constitutes advice. Everything fully disclaimed.}---
[Homeland Security means private firearms not lazy obstructive guards]
[Health Reform means abolishing FDR's insurance tax exemption]
[To stop SPAM, Charge net-postage] [Abolish 16th (Inc Tx) Amendment]
------------------------------
Date: Fri, 15 Oct 2004 14:59:41 -0500
From: Michael Coleman 0wnRy3zgJosv6 <mkc@stowers-institute.org>
Subject: Re: python for perl programmers?
Message-Id: <85fz4f3g7m.fsf@stowers-institute.org>
crichmon@filc8046.fm.intel.com (Chris Richmond - MD6-FDC ~) writes:
> I've used perl on Unix forever and totally hate the idea
Does sound pretty unpleasant. :-)
> What I'm looking for is a some sort of a Learning python for perl
> programmers.
Speaking as a former Perl programmer, I think you'll proceed fastest
and get the most out of your time if you just empty your mind of Perl
and approach it openly. Beazley's book "Python Essential Reference"
used to be a great way to force-feed yourself Python in the shortest
amount of time; I haven't looked at the latest edition, though.
Mike
------------------------------
Date: Fri, 15 Oct 2004 19:20:26 +0100
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Top posting (was Re: Concatenating an array into one string?)
Message-Id: <a0h542-1r4.ln1@osiris.mauzo.dyndns.org>
Quoth Helgi Briem <HelgiBriem_1@hotmail.com>:
> On 14 Oct 2004 21:46:10 GMT, Abigail <abigail@abigail.nl> wrote:
>
> >As for topposters, most of themI throw in my killfile, one the
> >first encounter of a toppost. And noone gets
> >out of the killfile once in there.
>
> Noone? Who's "noone"?
The transformation of compound nouns from two words to a hyphenated
compound to a single word as they become more naturalised is a perfectly
well established trait in English. Take 'nobody': it was 'no body'
in the 14th century, 'no-body' in the 18th, and 'nobody' in the 19th
[OED].
People who try to restrict the natural evolution of languages through
ignorance really get on my nerves :).
Ben
--
We do not stop playing because we grow old;
we grow old because we stop playing.
ben@morrow.me.uk
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 V10 Issue 7258
***************************************