[13186] in Perl-Users-Digest
Perl-Users Digest, Issue: 596 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Aug 20 00:07:26 1999
Date: Thu, 19 Aug 1999 21:05:08 -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 Thu, 19 Aug 1999 Volume: 9 Number: 596
Today's topics:
Re: A prime numbers program. (Abigail)
Re: Adding up a Data Variable Completely Lost perl sc <Ezjy@execpc.com>
Re: Can I use regx with eof()? <kistler@fnmail.com>
Re: directory reading (Martien Verbruggen)
DWIM redux (Was: Why use Perl when we've got Python?!) <kj0@mailcity.com>
Expect.pm uc() (Quinn Wilson)
exponentiation please explain what it means <bzhaainc@erols.com>
Re: exponentiation please explain what it means (Sam Holden)
Re: GMT not local server time? (Abigail)
Re: HARASSMENT -- Monthly Autoemail (Ronald J Kimball)
Re: hey everybody. can you help me? (Martien Verbruggen)
Re: How Test If Function Exists? (elephant)
Re: How to get length of multidimensional array element (Abigail)
I'm trying pingecho problem <toosmuth@earthlink.net>
Re: Language survey (Abigail)
Re: module suggestion- Net::SNTP <ljp@209.204.251.8>
newbie CGI question re CGI.pm (either Jana or John)
Re: perl-DBI problem (Martien Verbruggen)
please explain <ljp@209.204.251.8>
Re: pushing an anonymous hash slice (Abigail)
Re: Python for Perl users: random thoughts (Sam Holden)
Re: Python for Perl users: random thoughts <tchrist@mox.perl.com>
Re: Simple, dumb newbe question... how do I... <kistler@fnmail.com>
Re: Simple, dumb newbe question... how do I... <rwilliamson@uno.gers.com>
TURKEY EARTHQUAKE. <ismet@technoworks.net>
Re: Uploading? Please help! <cyberjeff@sprintmail.com>
Re: What editors are folks using for PerlScript develop <llornkcor@llornkcor.com>
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 19 Aug 1999 21:53:36 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: A prime numbers program.
Message-Id: <slrn7rpgra.ath.abigail@alexandra.delanet.com>
Benjamin Franz (snowhare@long-lake.nihongo.org) wrote on MMCLXXIX
September MCMXCIII in <URL:news:FYHu3.565$IZ4.34337@typhoon01.swbell.net>:
||
|| No. It is correct. Think about it - How can a number have *both*
|| divisors larger than the square root of the number? At least
|| one divisor will be smaller than that - and so there is no
|| point in checking larger divisors than the square root of
|| the number.
Nitpick: if I square a prime, the resulting number will not have any
divisor smaller than the square root of the number.
Abigail
--
package Just_another_Perl_Hacker; sub print {($_=$_[0])=~ s/_/ /g;
print } sub __PACKAGE__ { &
print ( __PACKAGE__)} &
__PACKAGE__
( )
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Thu, 19 Aug 1999 21:53:43 -0500
From: "E-Z Auction" <Ezjy@execpc.com>
Subject: Re: Adding up a Data Variable Completely Lost perl script
Message-Id: <7pig1u$311@newsops.execpc.com>
Michel Dalle <michel.dalle@usa.net> wrote in message
news:7ph8qt$7f8$1@news.mch.sbs.de...
> In article <7pfbhb$78f@newsops.execpc.com>, "E-Z Auction"
<Ezjy@execpc.com> wrote:
> >Hi,
> > I am trying to add up the last field in a data file, and then cause
> >another event to occur when it reaches a limit set in the data file. any
> >tips, examples, information of a helpful manner are welcome, and
encouraged.
> >
> >the data is arraigned in this manner:
> >
> >###########################
> >field1
> >field 2
> >field 3
> >field 4
> >
> >data1[]data2[]data3[]data4[]data5 # line 1
> >data1[]data2[]data3[]data4[]data5 # line2
> >data1[]data2[]data3[]data4[]data5 # line3
> >
> >#############
> >#line is not actually in the data file just put it there for explanation
> >purposes
> >
> >field 4 will be a number
> >data 5 will be a number
> >
> >What I need to do is starting with the most recent line (in this example
it
> >would be line three) take the data5 variable and compare it against field
4.
> >If data5 is less than field 4 then I need it to go to the line above it
(in
> >this example it would be line two) and add that lines data5 to the other
> >(line3 again) data 5 and compare again against field 4. and continue on
up
> >until field4 is met or exceeded
> >
> >
> >when data 5 meets the amount then I need to increase another variable
thats
> >in the script but not in the data (this part I figured out already but
for
> >the sake of this I will call it $inc
> >
> >Heres the really tricky part lets say
> >Line3 data5 =2
> >Line2 data5 =4
> >field4 = 4
> >
> >Ok,
> > reads line 3 data5 gets amount of 2 compares against field 4 value is
not
> >met, goes back and reads line 2 data 5 ads that value(4) with line3
value(2)
> >making the total 6 compares against field4. oops amount is higher than
what
> >it is suppose to be. Line 3 we want to leave alone because it is most
> >current. I want to decrease the value of line 2 data5 to the amount that
> >makes line 3 and line 2 data 5 fields equal to field 4 in this case line2
> >data 5 would become 2 (I would have it make a new data field but that
will
> >mess up the next time this is run) oy once again I will need to increase
the
> >other variable $inc.
> >
> >
> >Tia,
> >
> >Michael Bruce
>
> Here's a dirty hack that does what you want :
>
> #!/usr/local/bin/perl -w
> @fields = ();
> @data = ();
> while (<DATA>) {
> chomp;
> if (1 .. /^$/) {
> push(@fields, $_);
> }
> else {
> push(@data, [ split(/\[\]/) ]);
> }
> }
> print "Original data (reversed) :\n";
> foreach $record (reverse @data) {
> print join('-',@$record),"\n";
> }
> $sum = 0;
> $inc = 0;
> foreach $record (reverse @data) {
> $sum += $$record[4];
> if ($sum >= $fields[3]) {
> $$record[4] -= $sum - $fields[3];
> $inc++;
> last;
> }
> }
> print "New data (reversed) :\n";
> foreach $record (reverse @data) {
> print join('-',@$record),"\n";
> }
> exit;
> __DATA__
> field1
> field 2
> field 3
> 4
>
> data11[]data21[]data31[]data41[]1
> data12[]data22[]data32[]data42[]4
> data13[]data23[]data33[]data43[]2
>
> Output :
>
> Original data (reversed) :
> data13-data23-data33-data43-2
> data12-data22-data32-data42-4
> data11-data21-data31-data41-1
> New data (reversed) :
> data13-data23-data33-data43-2
> data12-data22-data32-data42-2
> data11-data21-data31-data41-1
>
> Don't try this on huge files, because we gobble up the
> whole thing in memory before starting to calculate the
> running total.
> And don't use this at school, because the style is so
> ugly you'll get bad scores :-)
>
> I still think this is the wrong way to handle your problem,
> though. Changing the data set for the next run seems to
> be pretty weird !?!
>
> Michel.
Hi,
Thanks, I will see how this works, By the way no its not for school so
Pretty doesn't matter. Just that it works. You have restored my Sanity.
Mike
------------------------------
Date: Fri, 20 Aug 1999 04:25:19 +0200
From: Per Kistler <kistler@fnmail.com>
Subject: Re: Can I use regx with eof()?
Message-Id: <37BCBC8F.E6B8A0FC@fnmail.com>
Hi Vinny
And one cannot just have something simple, like:
...
$mem = $/; undef $/;
$data = <INPUT>;
$/ = $mem;
@elements = split(/\belement\b/s,$data);
Is eof() really needed?
Cheers, Per.
Vincent Murphy wrote:
> I want to grab everthing from element to the begining of the next element.
> The element is both the begin pattern and the end pattern. The element
> name and branch could span multiple lines. OK, so far so good. Now the
> last element is the tricky one. I can't get it to figure out how to get
> /element/ .. eof() within this regx.
--
Per Kistler kistler@fnmail.com / kistler@gmx.net
------------------------------------------------------------
------------------------------
Date: Fri, 20 Aug 1999 02:24:21 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: directory reading
Message-Id: <p%2v3.165$873.6312@nsw.nnrp.telstra.net>
In article <37BC8863.96CE4A05@cisco.com>,
Makarand Kulkarni <makkulka@cisco.com> writes:
> [ Heather Wiley wrote:
>
>> can I do this in one step?
>
> Yes. Make it a side effect of using map.
> map { $hash {$directory. $_} = -s $_ }grep(!/^\./,readdir(ZIPDIR));
Or if you don't like map in a void context, and side effects which are
not immediately clear:
my %files = map { ("$directory/$_", -s $_) } grep { !/^\./ } readdir DIR;
Martien
--
Martien Verbruggen |
Interactive Media Division | For heaven's sake, don't TRY to be
Commercial Dynamics Pty. Ltd. | cynical. It's perfectly easy to be
NSW, Australia | cynical.
------------------------------
Date: 20 Aug 1999 04:00:21 GMT
From: kj0 <kj0@mailcity.com>
Subject: DWIM redux (Was: Why use Perl when we've got Python?!)
Message-Id: <7pijsl$t3k$1@news.panix.com>
In <37b30253@cs.colorado.edu> Tom Christiansen <tchrist@mox.perl.com> writes:
>Another principle underlying much of Perl is that "things that
>act different should look different". This allows you to write
>programs in Perl that are *easier* to read, because different things
>don't look like each other. Python tends to obscure this.
>For example, that's one reason why when you want numeric ordering you
>use "==", but when you want lexical ordering you use an operator that
>looks completely different: "eq". Likewise, because an array and a hash
>are, despite their interconvertibility, fundamentally different things,
>they *look* different.
This runs counter to the whole DWIM thing... There's nothing DWIM about:
DB<1> print "dog" == "cat"
1
Conversely, one could argue that integer and float arithmetic is a
different beasts, so that it is proper that they should look
different:
3/4 vs. float(3)/float(4)
DWIM implies that the language will deal with multiple interpretations
whereas "things that act different should look different" leaves the
resolution of these possible interpretations to the programmer;
i.e. these two principles tug in opposite directions.
KJ
------------------------------
Date: Fri, 20 Aug 1999 02:39:44 GMT
From: qwilson@eatmespambot.midworld.org (Quinn Wilson)
Subject: Expect.pm uc()
Message-Id: <37bcb8bc.74972850@news.mbnet.mb.ca>
This problem sounds easy and maybe it is but...
I wrote a bit of script to pasthrough a password to an application
that wants to use it's own security
I've written it using Expect.pm
#!/usr/bin/perl
use Expect;
my $login = $ENV{'LOGNAME'}'; # get login id
my $command = Expect->spawn("$program") or
die "Can\'t find program\n";
# hide STDOUT
$command->log_stdout(0);
unless ($command->expect(10, "PASSWORD:")){
#timeout
}
print $command "password";
# unhide STDOUT
$command->log_stdout(1);
# attach stdin to program
$command->interact();
# close and exit
$command->hard_close();
So now, the way I understand it after $command->interact(); is called
my perl script is siiting reading STDIN and writing it to the handle
"$command" while it waits for an EOF from the program I spawned.
What I want to do is intercept input to the program I've
spawned and run it through uc()
Anyone have any thoughts on how?
------------------------------
Date: Thu, 19 Aug 1999 23:19:47 -0400
From: "Ben Horowitz" <bzhaainc@erols.com>
Subject: exponentiation please explain what it means
Message-Id: <7pihko$m5r$1@autumn.news.rcn.net>
and whats the diffrence between chop ,and chop,and when do you use 1
punctuation mark and 2,thanks
------------------------------
Date: 20 Aug 1999 03:30:49 GMT
From: sholden@staff.cs.usyd.edu.au (Sam Holden)
Subject: Re: exponentiation please explain what it means
Message-Id: <slrn7rpj0a.k4f.sholden@staff.cs.usyd.edu.au>
On Thu, 19 Aug 1999 23:19:47 -0400, Ben Horowitz <bzhaainc@erols.com> wrote:
>and whats the diffrence between chop ,and chop,and when do you use 1
>punctuation mark and 2,thanks
Chop is a type of meat as in lamb chop.
Chop is something that you do to a tree.
If you mean something else like maybe chop and chomp then you could
try reading the documentation that comes with perl and which is available
on the web at www.perl.com
--
Sam
Perl was designed to be a mess (though in the nicest of possible ways).
--Larry Wall
------------------------------
Date: 19 Aug 1999 21:55:49 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: GMT not local server time?
Message-Id: <slrn7rpgvg.ath.abigail@alexandra.delanet.com>
Pelican Brief (pelibriefNOptSPAM@aol.com) wrote on MMCLXXVIII September
MCMXCIII in <URL:news:0221c012.f79269f1@usw-ex0108-057.remarq.com>:
..
.. Is there any easy way to display the time in GMT with perl
.. instead of the standard local server time (which is
.. currntly EDT...)?
If it's not in the manual, there isn't a way to do it.
Abigail
--
Note that GMT has been dead since the early 70s or so.
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Thu, 19 Aug 1999 23:23:51 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: HARASSMENT -- Monthly Autoemail
Message-Id: <1dwt08y.1g8rixr1mhtbk0N@p250.block2.tc3.state.ma.tiac.com>
Tom Christiansen <tchrist@mox.perl.com> wrote:
> I should put the modules, programs, and datafiles that I use for all
> this up again so that everyone can play. Peer pressure works.
You know what makes me most sick about this, Tom?
We all know that you can easily configure your mailer to ignore any such
posts that someone sends to you in the same manner that you are using to
harass others.
Not only are you being immature, but you have complete impunity to do
so. I think that makes you a spoiled brat.
--
_ / ' _ / - aka -
( /)//)//)(//)/( Ronald J Kimball rjk@linguist.dartmouth.edu
/ http://www.tiac.net/users/chipmunk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Fri, 20 Aug 1999 02:09:43 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: hey everybody. can you help me?
Message-Id: <HN2v3.153$873.6312@nsw.nnrp.telstra.net>
In article <37bc41e7.0@news.barak.net.il>,
"adam" <adam1@barak-online.net> writes:
> Do you know any Windows software that i design my script (not
> coding it but "editing" it (like i don't really write the html
> script when i work with FrontPage... ) ?
(As if FrontPage writes HTML...)
Possible translation of gibberish:
adam is looking for an IDE for Perl.
is that what you meant to say?
A search for IDE on www.perl.com will probably give you some pointers.
One fo 'integrated development environment' gives you some more
specific links.
Martien
--
Martien Verbruggen |
Interactive Media Division | You can't have everything, where would
Commercial Dynamics Pty. Ltd. | you put it?
NSW, Australia |
------------------------------
Date: Fri, 20 Aug 1999 12:13:39 +1000
From: elephant@squirrelgroup.com (elephant)
Subject: Re: How Test If Function Exists?
Message-Id: <MPG.122764db400139c4989c64@news-server>
Tom Christiansen writes ..
>In comp.lang.perl.misc,
> elephant@squirrelgroup.com (elephant) writes:
>:thank you for telling me this .. something else that ActiveState have
>:left me in the dark about it would seem (5.005_03 build 519)
>
>In that version, it's in the docs, but not in the warnings until
>the developers' version.
I see .. thanks
--
jason - elephant@squirrelgroup.com -
------------------------------
Date: 19 Aug 1999 21:57:58 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: How to get length of multidimensional array element
Message-Id: <slrn7rph3h.ath.abigail@alexandra.delanet.com>
Greg Shalette (gshalet@panix.com) wrote on MMCLXXIX September MCMXCIII in
<URL:news:7pfl12$c2q$1@panix3.panix.com>:
// How does one get the length of one element of a multidimensional array?
length $foo [3] -> [4] -> [16] -> [0];
// $#ComData[2] doesn't work for getting the length of the 3rd element of
// the array ComData.
That's not the length, that's the index of the last element.
$#{$ComData [2]}
is what you are looking for.
Abigail
--
split // => '"';
${"@_"} = "/"; split // => eval join "+" => 1 .. 7;
*{"@_"} = sub {foreach (sort keys %_) {print "$_ $_{$_} "}};
%{"@_"} = %_ = (Just => another => Perl => Hacker); &{%{%_}};
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Thu, 19 Aug 1999 20:45:17 -0700
From: "Toosmooth" <toosmuth@earthlink.net>
Subject: I'm trying pingecho problem
Message-Id: <7pij2p$dgd$1@ash.prod.itd.earthlink.net>
I'm trying to write this perl script that using pingecho to very my server
is up before connecting to it.
Below is the syntax that I'm using
use Net::Ping;
print "badass is alive\n" if pingecho(badass, 10) ;
I receive the following output
The Unsupported function alarm function is unimplemented at
C:/Perl/lib/Net/Ping.pm line 309.
I would appreciate any help that anyone can provide.
Thanks,
Matt
------------------------------
Date: 19 Aug 1999 22:01:04 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Language survey
Message-Id: <slrn7rph99.ath.abigail@alexandra.delanet.com>
David Cassell (cassell@mail.cor.epa.gov) wrote on MMCLXXVII September
MCMXCIII in <URL:news:37B9D28C.41C7CEAB@mail.cor.epa.gov>:
--
-- The thing I found the most interesting is that, while the
-- short-sighted authors of the quiz relegated Perl to the
-- procedural-language category only, the number of votes for
-- use of OO-language (as opposed to procedural) is far larger
-- than the sum of the votes for what they consider OO. In
-- fact, a quick check of the tallies indicates that a lot
-- of the Perl-voters had to have marked OO instead of procedural.
-- In the words of Randal, "heh".
Which let me quickly lead to the conclusion the survey is utterly bogus.
Abigail
--
sub _'_{$_'_=~s/$a/$_/}map{$$_=$Z++}Y,a..z,A..X;*{($_::_=sprintf+q=%X==>"$A$Y".
"$b$r$T$u")=~s~0~O~g;map+_::_,U=>T=>L=>$Z;$_::_}=*_;sub _{print+/.*::(.*)/s}
*_'_=*{chr($b*$e)};*__=*{chr(1<<$e)};
_::_(r(e(k(c(a(H(__(l(r(e(P(__(r(e(h(t(o(n(a(__(t(us(J())))))))))))))))))))))))
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: 17 Aug 1999 08:42:20 -0600
From: ljp <ljp@209.204.251.8>
Subject: Re: module suggestion- Net::SNTP
Message-Id: <wkpv0mzcxf.fsf@209.204.251.8>
ahh-- ya... thanks- I'll check it out-
------------------------------
Date: Fri, 20 Aug 1999 03:02:41 GMT
From: quikscor@ix.netcom.com (either Jana or John)
Subject: newbie CGI question re CGI.pm
Message-Id: <37bcc218.63184824@nntp.ix.netcom.com>
I just got my new web hosting account that allows me a cgi-bin --
great!
Now I'm trying to run a tiny program I largely copied out of the llama
book and I'm getting the following error:
Premature end of script headers:
/home/users/u/me/public_html/cgi-bin/echo.cgi
It looks to me like the message is saying the headers are wrong. The
CGI.pm module is supposed to take care of that, right? Maybe this
server doesn't have the module installed......(?) Here's the
code. The script is receiving input from a text field in an HTML
form. The script should just echo back what was input.
#!/user/bin/perl -w
use CGI qw(:standard);
my $echoline = param("anecho");
print header, start_html("Yes, there is an echo!"), h1("You typed");
if ($echoline) {
print q($echoline);
} else {
print q("You didn't type anything.");
}
print end_html();
The print end_html is not in the example. The example ends with a
form and has end_form, hr; instead at the end.
The body of the HTML is as follows:
<BODY>
<H3>Type something here.</H3>
<FORM action="http://www.domain.com/~me/cgi-bin/echo.cgi"
method="post">
<INPUT type="text" name="anecho" size="40">
<INPUT type="submit">
</FORM>
</BODY>
any help appreciated
- j
------------------------------
Date: Fri, 20 Aug 1999 02:31:33 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: perl-DBI problem
Message-Id: <963v3.170$873.6312@nsw.nnrp.telstra.net>
In article <7phgcu$7p3$1@nnrp1.deja.com>,
warmongr <brazell@bmh.com> writes:
> Can't load '/usr/lib/perl5/5.00503/i386-linux/auto/DBI/DBI.so' for
> module DBI: /usr/lib/perl5/5.00503/i386-linux/auto/DBI/DBI.so: undefined
> symbol: dirty at /usr/lib/perl5/5.00503/i386-linux/DynaLoader.pm line
> 169.
> I previously had DBI up and running on a RH5.2 using
> perl-5_004m4-1_i386.rpm.
> RH 6.0 ships with perl-5_00503-4_i386.rpm. The default directory under
perl 5.004_04 and perl 5.005_0x are not binary compatible. That's why
they look in a different spot for many things. The easiest way to get
your module back is to recompile and install it. If you have many
modules you want back, you could have a look at the autobundle feature
in the CPAN module.
Martien
--
Martien Verbruggen |
Interactive Media Division | Begin at the beginning and go on till
Commercial Dynamics Pty. Ltd. | you come to the end; then stop.
NSW, Australia |
------------------------------
Date: 17 Aug 1999 21:33:20 -0600
From: ljp <ljp@209.204.251.8>
Subject: please explain
Message-Id: <3dxhoj9b.fsf@wind.localdomain>
why this-
my $pattern1='<IMG ALIGN="bottom" BORDER=0 HEIGHT=9 HSPACE=3 SRC="image.bmp">';
my $pattern2=' ';
@$data = grep {s/$pattern1/$pattern2/} @$data;
replaces <IMG ALIGN=\"bottom\" BORDER=0 HEIGHT=9 HSPACE=3
SRC="image.bmp"> and everything preceding the first match, but
correctly substitutes after the first match? I thought
pattern substitution was supposed to match the exact pattern specified
in $pattern1?
------------------------------
Date: 19 Aug 1999 21:43:19 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: pushing an anonymous hash slice
Message-Id: <slrn7rpg81.ath.abigail@alexandra.delanet.com>
Greg Bacon (gbacon@itsc.uah.edu) wrote on MMCLXXVIII September MCMXCIII
in <URL:news:7pfa9t$nj0$1@info2.uah.edu>:
\\
\\ I disagree. The real question when it comes to interleaving is "how
\\ should I interleave the objects?". Do I take three of one and two of
\\ the other? I'm still waiting for mjd (or Abigail?) to chime in with a
\\ way to interleave an aribitrary number of arrays by arbitrary rules. :-)
#!/opt/perl/bin/perl -w
use strict;
sub interleave (&@) {
my $code = shift;
# Make a copy of the lists, as we destruct them.
my @arrays = map {[@$_]} @_;
my @result = ();
my $l = 0;
foreach my $arr (@arrays) {$l += @$arr;}
while ($l) {
my @r = $code -> (map {@$_ ? \($_ -> [0]) : undef} @arrays);
return @result unless @r;
foreach my $r (@r) {
die "$r is not a non-negative integer\n" if $r =~ /\D/;
die "$r is out of range\n" if $r >= @arrays;
die "list is exhausted\n" unless @{$arrays [$r]};
push @result => shift @{$arrays [$r]};
$l --;
}
}
@result;
}
# Find the index of the minimum of a list of values; undefs don't count.
sub mini {
my $r = -1;
my $min = 0x7fffffff;
for (my $i = 0; $i < @_; $i ++) {
next unless defined $_ [$i];
$min = ${$_ [$r = $i]} if ${$_ [$i]} < $min;
}
$r;
}
# Merge sorted lists:
my @a = interleave {mini @_} [0, 3, 5, 9],
[1, 2, 2, 3, 3, 8],
[10],
[],
[4, 8, 9];
print "@a\n";
# Zip lists, truncate when one is exhausted.
my @b = interleave {return if grep {!defined} @_; 0 .. $#_}
['a', 'd', 'g', 'j', 'l',],
['b', 'e', 'h', 'k',],
['c', 'f', 'i',];
print "@b\n";
# Zip lists, with no truncation.
my @c = interleave {map {defined $_ [$_] ? $_ : ()} 0 .. $#_}
['a', 'd', 'g', 'j', 'l',],
['b', 'e', 'h', 'k',],
['c', 'f', 'i',];
print "@c\n";
__END__
Abigail
--
perl -we 'print q{print q{print q{print q{print q{print q{print q{print q{print
qq{Just Another Perl Hacker\n}}}}}}}}}' |\
perl -w | perl -w | perl -w | perl -w | perl -w | perl -w | perl -w | perl -w
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: 20 Aug 1999 03:15:42 GMT
From: sholden@staff.cs.usyd.edu.au (Sam Holden)
Subject: Re: Python for Perl users: random thoughts
Message-Id: <slrn7rpi3u.irp.sholden@staff.cs.usyd.edu.au>
On 19 Aug 1999 20:23:25 -0500, Abigail <abigail@delanet.com> wrote:
>Tom Christiansen (tchrist@mox.perl.com) wrote on MMCLXXIX September
>MCMXCIII in <URL:news:37bc1062@cs.colorado.edu>:
<snip>
>
>__ You can't cut and paste these examples because of the issue
>__ of white space significance. :-(
>
>I don't understand. Does your X-server eat leading whitespace or so?
>Or do you use plain vi, and have ":set autoindent" switched on?
The following code is illegal python :
print "fred"
The following is legal python :
print "fred"
That is darn annoying when cutting and pasting code from an email or a
web page to see what it does, or to test if it works.
Sure all you have to do it type :
if 1:
and then paste the code, but that is tedious...
--
Sam
Perl is the Cliff Notes of Unix.
--Larry Wall
------------------------------
Date: 19 Aug 1999 21:29:52 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Python for Perl users: random thoughts
Message-Id: <37bccbb0@cs.colorado.edu>
[courtesy cc of this posting mailed to cited author]
In comp.lang.perl.misc,
sholden@cs.usyd.edu.au writes:
:Perl is the Cliff Notes of Unix.
: --Larry Wall
That was me. Larry just borrowed it. :-)
--tom
--
"That's okay. Anyone whose opinion he cares about already knows that
he doesn't care about their opinion."
--Larry Wall
------------------------------
Date: Fri, 20 Aug 1999 04:33:34 +0200
From: Per Kistler <kistler@fnmail.com>
Subject: Re: Simple, dumb newbe question... how do I...
Message-Id: <37BCBE7E.F8615434@fnmail.com>
Hi Rusty
One may need a little more information:
Do you want to source fetchParamter.pl into the present
script, like with "require" or "use" commands?
You seem to mix function calls with filenames. Do you want
to run fetchParameter.pl with the commandline argument
MYPARAMETER and get the output into the some variable?
That would just be:
$result = qx(/path/path/file.pl arg1 arg2); # backticks work as well
Cheers, Per.
Rusty Williamson wrote:
> my $MYPARAMETER=`fetchParameter(MYPARAMETER)`;
>
> But fetchParameter.pl can live wherever the software might be installed so?
>
> my $installDirectory=getInstallDir();
> # then maybe...
> my $command=$installDirectory . "/bin/fetchParameter(MYPARAMETER)";
>
> But now how do I run it?
>
> my $MYPARAMETER=`$command`;
>
> This does not work. Using eval sounds right but referencing eval doesn't
> show me and?
>
> my $MYPARAMETER=eval"`$command`";
>
> ...doesn't work. :-(
>
> Thanks!
> Rusty Williamson
--
Per Kistler kistler@fnmail.com / kistler@gmx.net
------------------------------------------------------------
------------------------------
Date: Thu, 19 Aug 1999 20:23:57 -0700
From: "Rusty Williamson" <rwilliamson@uno.gers.com>
Subject: Re: Simple, dumb newbe question... how do I...
Message-Id: <AS3v3.38$0j5.3225@news.connectnet.com>
Per-
I hate it when my brain goes into stupid mode! It should have read:
my $MYPARAMETER=`fetchParameter.pl MYPARAMETER`;
fetchParameter.pl is a PERL script which returns the parameter value and I
so I need to retry everything. Perhaps is $command holds the command
pathname and it's argument that
my $MYPARAMETER=`$command`;
may work. But maybe not. I've ran into other problems which must be
resolved befor I can try it again. If you know the answer let me know!
Thanks for replying!
Rusty Williamson
Per Kistler wrote in message <37BCBE7E.F8615434@fnmail.com>...
>Hi Rusty
>
>One may need a little more information:
>
>Do you want to source fetchParamter.pl into the present
>script, like with "require" or "use" commands?
>
>You seem to mix function calls with filenames. Do you want
>to run fetchParameter.pl with the commandline argument
>MYPARAMETER and get the output into the some variable?
>That would just be:
>$result = qx(/path/path/file.pl arg1 arg2); # backticks work as well
>
>Cheers, Per.
>
------------------------------
Date: Fri, 20 Aug 1999 11:48:39 +0800
From: "Ismet Dere" <ismet@technoworks.net>
Subject: TURKEY EARTHQUAKE.
Message-Id: <7piili$hut$1@news.hk.linkage.net>
Hello All!
I know that this message is out of subject, I sincerely apologize.
.....Please help the earthquake victims in Turkey,
they desperately need our help, let's help them,
any way we can, any way at all...
please circulate this message if you can.
Thank you all!
Ismet Dere
------------------
if you wish to send some money,
Riggs Bank NA
Embassy Banking Division
Washington, D.C.
Turkish Embassy Earthquake Victims Relief Fund
ABA No. 054000030
ACCT No. 17300827
------------------------------
Date: Tue, 17 Aug 1999 09:50:36 -0400
From: Jeff Thies <cyberjeff@sprintmail.com>
Subject: Re: Uploading? Please help!
Message-Id: <37B968AC.A512812A@sprintmail.com>
> I need some help. I want to add an upload feature to my new database script.
CGI.pm will do this with ease. Check the documentation that comes with
this ubiquitous module for examples.
Jeff
------------------------------
Date: Tue, 17 Aug 1999 13:06:23 -0600
From: ljp <llornkcor@llornkcor.com>
Subject: Re: What editors are folks using for PerlScript development?
Message-Id: <37B9B2AF.3E82622C@llornkcor.com>
I use emacs for development in several languages on windows and linux.
Ken Snyder wrote:
>
> What editors are folks using for PerlScript development under Windows? I
> have had some success with Homesite but would like to use Visual Interdev.
> Is there anyway to get Interdev to parse Perl? Is there a better editor I
> should use instead?
>
> ken
------------------------------
Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 1 Jul 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.
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" from
almanac@ruby.oce.orst.edu. The real FAQ, as it appeared last in the
newsgroup, can be retrieved with the request "send perl-users FAQ" from
almanac@ruby.oce.orst.edu. 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" from
almanac@ruby.oce.orst.edu.
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 596
*************************************