[10354] in Perl-Users-Digest
Perl-Users Digest, Issue: 3947 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Oct 11 15:07:20 1998
Date: Sun, 11 Oct 98 12:00:22 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sun, 11 Oct 1998 Volume: 8 Number: 3947
Today's topics:
Re: Assigning a value to a var (Ronald J Kimball)
Re: comp.lang.perl.win32?? (Paul Murray)
Re: Finding the basedir <jhoglund@mirage.skypoint.net>
Re: Here we go a mongering.... pfeilgm@technomadic.org
Re: How to lauch search on another machine? <jason.holland@dial.pipex.com>
I'm looking for someone who wants to write a complete p (PsIoNnEkE)
Install on WINNT stops immediately <denniscook@erols.com>
Re: Name from IP <jason.holland@dial.pipex.com>
Re: Need IP Address Sort Subroutine <williams@clark.net>
Re: NEEDED: A good perl programer to... rich@ffmail.com
Re: Newbie: using strict with filehandles <psdspss@execpc.com>
Re: ODBC access to Micro$oft SQL server <jhi@alpha.hut.fi>
Re: Perl advice (Ronald J Kimball)
Re: read subdirectories <jhoglund@mirage.skypoint.net>
Re: Return Code <psdspss@execpc.com>
Re: Return Code <dgris@perrin.dimensional.com>
sorting hack <xah@best.com>
Re: sorting hack <xah@best.com>
Re: What do you need to run perl? <jason.holland@dial.pipex.com>
Re: Why it doesn't work under UNIX?????? <aperrin@mcmahon.qal.berkeley.edu>
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 11 Oct 1998 14:41:48 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: Assigning a value to a var
Message-Id: <1dgqmpw.1wlek861k46aw8N@bos-ip-1-49.ziplink.net>
Mark Priatel <mpriatel@chat.carleton.ca> wrote:
> Ok, a minute after this post I took a quick look through the perl
> manual...
Next time, look through the manual first.
> Is this a safe/common way to assign data?
>
> $name = <stdin>;
STDIN should be capitalized.
This is the more common way:
$name = <>;
because STDIN is the default filehandle for input.
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: 8 Oct 1998 11:56:43 GMT
From: murray-paul@usa.net (Paul Murray)
Subject: Re: comp.lang.perl.win32??
Message-Id: <slrn71pa3r.ehm.murray-paul@unix3.netaxs.com>
On 6 Oct 1998 23:24:32 GMT, Craig Berry <cberry@cinenet.net> wrote:
>thom_co@my-dejanews.com wrote:
>: Has there been any discussion of creating an additional newsgroup for
>: discusssion of win32 related perl issues?
>:
>: There are several perl issues that would be of interest only to those doing
>: win32 perl programming and not to the rest of the perl community.
>Examples?
o Using Win32 GUI modules, Win32 Registry modules, umm most things
called Win32:: :)
o Connecting to Access databases/Excell spreadsheets/etc...
o Peculiarities of perl under win32 (or win32 under perl, depending on
your perspective)
o Differences between available ports, utilities only available under
Win32, such as perl2exe.
>And why win32 as opposed to any other particular architecture or OS?
o Most unices can be considered essentially homogeneous, Win32 is a
very different environment. This would also apply to Macs, but...
o Userbase. There are a lot of Win32 perl users out there, more than
any other non-unix port.
o Cluelessness. It seems fair to say that the average Win32 perl
programmer is less experienced than the average unix perl programmer,
thus the level of questions asked is lower. Currently this causes...
o Attitude problem of current newsgroup towards Win32, probably caused
by abovementioned cluelessness getting all Win32 programmers and
questions tarred with the same brush. Questions tend to get blown off
with 'install a real OS' type 'help'
-Paul Murray
Example 'help':
=>Did anyone write a script that shuts down all services on a Windows NT
=>machine? Any hints will be appreciated.
=<advocate>
=Step 1. Reboot
=Step 2. Install Linux
=Free software that works better than the for-pay software.
=Who'da thunk it?
=</advocate>
------------------------------
Date: 11 Oct 1998 18:29:48 GMT
From: Jamie Hoglund <jhoglund@mirage.skypoint.net>
Subject: Re: Finding the basedir
Message-Id: <6vqtes$k90$2@shadow.skypoint.net>
Rikard Sj?str?m <rikard.sjostrom@swipnet.se> wrote:
: Any suggestions how I should find the real basepath to my
: homedirectory?
The HOME directory should be accessable to the getpwuid() call, but
there is the chance that you don't have an actual account on the machine
that is running the web server. (It's more than likely running on a
machine that isn't your shell access machine)
If it's the DOCUMENT_ROOT you want, just look at the environment
variables.
Jamie
------------------------------
Date: 11 Oct 1998 16:16:35 GMT
From: pfeilgm@technomadic.org
Subject: Re: Here we go a mongering....
Message-Id: <6vqll3$nri$1@lark.jmu.edu>
Elaine -HappyFunBall- Ashton wrote:
> The boston.pm is having a gathering tomorrow ~6pm EST. Those unable to
> join us in our search for better beer and finer scotch should join us on
> #mongering on EFnet sometime thereafter. Should we get the quickcam
> going we'll post it on the channel.
It looks like I'm going to be spending a few days around Thanksgiving
in Boston. I have some free time on that Friday, and I was wondering
if maybe a few mongers may want to get together for dinner or
something. It's rare that I'm in an area with many PERL people, so I
like to take advantage of the opportunity.
--
Greg Pfeil --- Software Engineer --- (pfeilgm@|http://)technomadic.org
"Support Letterbox or die." --John Capriotti
------------------------------
Date: Sun, 11 Oct 1998 17:35:20 +0000
From: Jason Holland <jason.holland@dial.pipex.com>
To: "Lily Y. Fu" <lily@tigr.org>
Subject: Re: How to lauch search on another machine?
Message-Id: <3620EC58.F7B2279A@dial.pipex.com>
Lily Y. Fu wrote:
>
> Hi,
>
> We have some cgi scripts in PERL launched from a webserver
> quite computationally intensive,
> if the search is performed on the same machine as the
> webserver host, it will put a heavy load on the webserver.
> Aslo, the search takes so long that the browser would
> time out before it gets any result back from the search.
>
> I have two questions:
>
> 1. We have another machine (LINUX) is good at computation,
> Is there any way to farm the searches out to a delicated
> computation machine from the webserver host
> and send the result back?
>
> 2. If the search takes long time to finish, how
> can I make the browser not to time out?
>
> #============== Start time consuming search =========
> open(PROG,"/usr/local/bin/Search inputfile datafile |")
> || &Pexit_html("Could not open pipe to Search - misconfiguration
> somehere");
>
> $res = new Results;
> $res->parse(\*PROG);
>
> #============== Want the above to be done at another machine ===
>
> Thanks for any input and help.
> --
> Lily Fu
> The Institute for Genomic Research
> Voice Mail: (301) 838-3557
> Email: lily@tigr.org
Hello Lily,
I read this because it looked interesting, I've also written one or two
projects that had similar requirements.
Just a couple of ideas...
You could have a custom client/server interaction between the main Perl
script and searching Perl script on the search machine.
Have you tried multi-threading, using either threads in Perl 5.005 or
process level threads? I use this where it is logically possible to
partition an application's processing tasks, for isntance performing a
number of different calcs on the same data.
I'm not sure how to get the browser to stop timing out, I had the same
problem my self. If the search takes a REALLY long time you may find it
easier to fork off the search script, and return confirmation to the
user. The search results being delivered by e-mail.
Just some thoughts...Bye!
--
sub jasonHolland {
my %hash = ( website =>
'http://dspace.dial.pipex.com/jason.holland/',
email => 'jason.holland@dial.pipex.com' );
}
------------------------------
Date: Sun, 11 Oct 1998 18:58:05 GMT
From: bdispa@bigfoot.com (PsIoNnEkE)
Subject: I'm looking for someone who wants to write a complete perl-script (for free)
Message-Id: <3621e50b.23824482@news.uunet.be>
Hi !
I'm looking for one (or a few) persons who want to write a complete
perl-script for my new web-project. The project ain't the one you know
from everybody, no, it's very professional.
What I need:
I need 2 or 3 scripts that use the same resources. It's all for the
same purpose: voting.
Script 1: for the visitors.
They can submit URL's (through the script) and vote on other URL's.
Script 2: for the jury (must have password protection)
The jury must login into the script with a login and passwd, and then
pick a submitted URL out of the file with URL's (see: script 1) and
give points to them.
Script 3: for the supervisor (also with passwd protection)
The supervisor needs to reset everything, or just one thing. He also
needs to know the results: 50% from script 1, the other 50% from
script 2.
More information and more details are available at my e-mail adres
(bdispa@bigfoot.com)... (Dutch / English)
Do you want to help me ? Mail me ASAP. The deadline is January 1st.
Tnx...
------------------------------
Date: Sun, 11 Oct 1998 14:01:29 -0700
From: Dennis Cook <denniscook@erols.com>
Subject: Install on WINNT stops immediately
Message-Id: <36211C4C.5DDB@erols.com>
I'm a (non-power) perl user at work and, having been thoroughly won
over, want to install at home to handle some file manipulation, but have
run into a snag.
I have WINNT4.0 on pentiumII w/plenty memory & hd.
1) I ownloaded:
ftp.activeware.com/Perl-Win/ntperl/perl5.001/CurrentBuild/110-i86.zip.
2) I moved that file into c:\program files\perl5, and unzipped it using
SuperZip 1.0. which appears to have worked ok.
3) Following the readme and install files, I opened a command prompt
window, cd to c:\program files\perl5 and typed in 'install'. I
immediately got the message:
'Can't locate NT.ph in @INC (did you run h2ph?) at install.bat line 35.'
I don't know what it means by h2ph, and the file NT.PH (upper/lower case
doesn't make any difference, I tried it) does exist in the directory.
I sure would appreciate if anyone can get me straightened out.
--
Thanks very much,
Dennis Cook
------------------------------
Date: Sun, 11 Oct 1998 17:18:36 +0000
From: Jason Holland <jason.holland@dial.pipex.com>
To: Christian Koch <christian.koch@fuzzy-online.de>
Subject: Re: Name from IP
Message-Id: <3620E86C.94EF6EBF@dial.pipex.com>
Christian Koch wrote:
>
> How can I get the server- or domain-name of a IP with a perl-script or an
> executable file??
>
> Christian
Try something like this:
my $address = "123.123.123.123"; # Example address
my ( $a, $b, $c, $d ) = split( /\./, $address ); # Split into
discrete values
my $addr = pack( "C4", $a, $b, $c, $d ); # Pack into four
byte binary format
my $hostname = gethostbyaddr( $addr ); # Get hostname, more
data available with this call
Look up gethostbyaddr() for more info.
Bye!
--
sub jasonHolland {
my %hash = ( website =>
'http://dspace.dial.pipex.com/jason.holland/',
email => 'jason.holland@dial.pipex.com' );
}
------------------------------
Date: Sun, 11 Oct 1998 13:38:39 -0500
From: "Joe Williams" <williams@clark.net>
Subject: Re: Need IP Address Sort Subroutine
Message-Id: <6vqtvg$75q$1@news.onramp.net>
The info below in a partial summary of the ways suggested to sort an IP
number. It may be useful to some one new to the problem.
If the comments are bothersome use @code_lines = grep !/^#/, @all_lines to
eliminate them.
# I originally posed the question of how to sort and array of strings by the
# IP address contained in each string.
# There are several issues: how to pull the IP address
# out of the string, how to convert it to sortable form, and then how to
# sort the array. There were a lot of answers, some of which I probably
missed
# while traveling. The examples below concern only the conversion problem.
# It helps to understand that an IP address in the dotted quad form is a
# 32 bit number which has been broken into four 8 bit parts and translated
# into a digital number: 10.45.126.10. To sort on it, it has to be
# reconstructed as a number or structure which has all the information
# contained in the original address, including the position of the quads.
# If you run the first example below,
# it will print out the IP number converted to 199077210067.
# A numerical sort on this as a number works, although the number is not
# really the IP address. It works because the info in the postion of the
quads
# is retained.
print "\n";
print "Results of sprintf approach: "; print sprintf("%.3d%.3d%.3d%.3d",
"199.77.210.67" =~ /(\d+)/g);
print "\n";
# This one takes an approach that I don't understand. It uses a subroutine
# to convert the IP address to 199 77 210 67 (using the split function)
# which is assigned to an anonymous array used as the argument to the pack
# function. Pack's "C4" takes the anonymous four element string and using
# the template "C4", converts each number (the 4) to an unsigned binary
# character (the C) and packs the four numbers into a "binary structure"
# (the exact form of which is what I don't understand). This binary
# structure is then sorted as a string. This works.
# I can't print the structure
# without unpacking it first, which the example does.
$temp = get_ipa("199.77.210.67");
print "\n";
print "Unpacked packed approach: "; print unpack("C4", $temp);print
"\n";print "\n";
sub get_ipa{
return udef unless $_[0] =~ /([\d.]+)/;
return pack("C4",split(/\./,$1));
}
# Still another approach uses the inet_aton function which is part of the
standard
# distribution libary. However, when I tried it, the function logs into the
# network, probably because it can take "somehost.net" as well as the IP
address,
# and it is looking for a DNS. So, that approach doesn't work too well for
my
# purposes. A really good conversion routine would exclude bogus addresses,
# such as 0.0.0.0, and be error trapped. inet_aton presumably does all this,
# and is efficient as well.
# Does anyone know where the code for this routine actually resides?
# No elegance in the final example, but it converts the actual IP address to
a decimal.
print "Actual IP Address as a decimal: ";print
dotted_to_int("199.77.210.67");
print "\n";
sub dotted_to_int
{
return undef if $_[0] =~ /[^0-9.]/; # undef unless IP address composition
right
my @a = split /\./, $_[0]; # Each octet is in an array element of @a
# Cycles from 0 to 3--the four octets. The .. operator expands $#a
$n = 0;
for ( 0..($#a) ) # $#a = number of array elements.
{
return undef unless (-1 <= $a[$_] && $a[$_] < 256); # Checks quads > -1
< 256
$n = $n + ( $a[$_] * (256**(3-$_)) ) ; # converts each octet to decimal &
adds them
}
return $n;
}
------------------------------
Date: Sun, 11 Oct 98 16:59:31 GMT
From: rich@ffmail.com
Subject: Re: NEEDED: A good perl programer to...
Message-Id: <6vqnt2$9r7$1@birch.prod.itd.earthlink.net>
I absolutely must applaude your comments mike. I am new to the programming
world but came into this newsgroup thinking your concept was what the net
and newsgroups were really all about.
Thanks Mike.
------------------------------
Date: Sun, 11 Oct 1998 12:47:23 -0500
From: Deva Seetharam <psdspss@execpc.com>
Subject: Re: Newbie: using strict with filehandles
Message-Id: <6vqqam$88r@newsops.execpc.com>
In perl reference is similar to c pointers.
For example
#/usr/bin/perl -w
$a = 2;
print "a is $a\n"; #prints 2
$ra = \$a; #Make $ra point to 2.
$$ra++;
print "a is $a\n"; #prints 3.
--------
In your code, u have written
my $fh = "fh00";
If you unintentionally write
$$fh, although there is no reference like that, perl will try to resolve
it as
$fh00. (substituting fh00 for $fh).
pragma strict stops you from doing such a thing.
Thats why you get the error message.
Read Perl FAQ at
http://www.perl.com/CPAN-local/doc/FAQs/FAQ/PerlFAQ.html
Hope that helps,
Deva
George Defenbaugh wrote:
> I'm teaching myself Perl by working through the examples in the ORA
> Learning Perl books, using Build 502 of ActiveState on Win32. On
> Exercise 10-1, I can't get the syntax right for using strict with
> filehandles. For example, this code works only when the use statement
> is commented out.
>
> #use strict;
> my $fn;
> my $fh = "fh00";
> $fn = <STDIN>;
> open($fh, $fn) || die "Open: $!";
> while (<$fh>) {
> print "$fn:$_";
> }
>
> I'd appreciate a hint on the answer or where to find it. I have ORA's
> Programming Perl and Cookbook texts, if the answer is in there but
> I've just missed it.
------------------------------
Date: 11 Oct 1998 18:55:52 +0300
From: Jarkko Hietaniemi <jhi@alpha.hut.fi>
Subject: Re: ODBC access to Micro$oft SQL server
Message-Id: <oeeiuhrytx3.fsf@alpha.hut.fi>
Please buy a wider monitor.
I would start looking at
http://www.hermetica.com/technologia/DBI/
Lonnie Watson <harlock1@home.com> writes:
: I
: currently
: have a
: need to
: connect
: DBI and
: DBD
: modules in
: Perl to a
: Microsoft
: SQL server
: running on
: an NT
: machine
: also in
: the
: network. I
: am running
: Red Hat
: 5.1 with
: perl 5.04
: ( I think
: its .04 ).
: At any
: rate I am
: looking
: for anyone
: who can
: tell me
: what is
: also
: necessary
: on the
: Linux side
: for this
: to happen.
: I think I
: need to
: use the
: iODBC
: driver. I
: have taken
: that
: product
: and
: compiled
: it into
: the
: system but
: when the
: DBD module
: goes
: throuh its
: tests it
: fails to
: connect to
: the sql
: server. On
: the Sql
: side I see
: no
: evidence
: that the
: connection
: attempt
: was even
: made. Not
: really
: sure where
: to turn
: here...
:
: Has anyone
: out there
: in Perl
: land
: achieved
: this
: before?
--
$jhi++; # http://www.iki.fi/~jhi/
# There is this special biologist word we use for 'stable'.
# It is 'dead'. -- Jack Cohen
------------------------------
Date: Sun, 11 Oct 1998 14:41:49 -0400
From: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: Perl advice
Message-Id: <1dgqn2g.3nwimegcvwxsN@bos-ip-1-49.ziplink.net>
Jeff Hunter <jhunter@igg-tx.net> wrote:
> I've been asked to replace a binary program (no sorce code avail.) that
> no longer does what we need it to. I'd like to use perl, but this may be
> too complex a problem...
> [problem description]
Where's the complex part?
> Is it possible to read the input file into a hash array (without
> knowing how many groups there are total, or how many hosts are in each
> group) and then pull the data out of the array to
> complete these files? Any advice on how efficient this will be and how
> to utilize a hash in this way would be appreciated.
Yes, that is possible. Since Perl grows hashes as necessary, you don't
need to know ahead of time how big the hash will be. You can use
references to create a hash of lists, or a hash of hashes, or a hash of
lists of hashes, or whatever else you need. Any structure you can put
data into you can get data out of.
Perl is good at manipulating strings. If you write it properly, I think
your solution will be quite efficient.
What will the keys for your hash be?
The group names.
What will the values for your hash be?
Perhaps the line of input. Maybe a ref to an array of the fields.
Or a hash, with field names as keys and field contents as values.
That really depends on what you want to do.
--
_ / ' _ / - aka - rjk@coos.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: 11 Oct 1998 18:16:57 GMT
From: Jamie Hoglund <jhoglund@mirage.skypoint.net>
Subject: Re: read subdirectories
Message-Id: <6vqsmp$k90$1@shadow.skypoint.net>
John Porter <jdporter@min.net> wrote:
: Pete Ratzlaff wrote:
:>
:> Here's one I wrote up in a hurry which recursively prints all
:> subdirectories of a given directory. Modify to suit your own needs:
: I sure do wonder what people have against using standard, robust,
: portable modules like File::Find.
Not all systems actually have the standard perl modules installed.
I use File::Find, and like it a lot, but I might like to understand
how to recursively read directories by hand, if nothing else just for the
excercise.
The trouble I always stumble on are symbolic links, short of ignoring
them, it's hard to cd to the next level, and then cd back up without using
.. (Kind of like the way midnight commander does it)
Jamie
------------------------------
Date: Sun, 11 Oct 1998 12:19:32 -0500
From: Deva Seetharam <psdspss@execpc.com>
Subject: Re: Return Code
Message-Id: <6vqomf$88u@newsops.execpc.com>
You invoke the system commands with system functions.
Return value of system function is return value of your system call.
system("ls") = = 0.
And also look at perl faq available at
http://www.perl.com/CPAN-local/doc/FAQs/FAQ/PerlFAQ.html
Hope that helps.
Deva
Simeone wrote:
> Hi! Just a beginner's question for you:
>
> I've got to execute some system commands, like useradd, userdel, chage, etc.
> What can I do, if I want to run them and catch their return codes?
>
> Thank you!
------------------------------
Date: Sun, 11 Oct 1998 17:36:44 GMT
From: Daniel Grisinger <dgris@perrin.dimensional.com>
Subject: Re: Return Code
Message-Id: <m3btnjqa6n.fsf@perrin.dimensional.com>
Deva Seetharam <psdspss@execpc.com> writes:
> You invoke the system commands with system functions.
> Return value of system function is return value of your system call.
> system("ls") = = 0.
I don't think so.
The return value from system is the exit status of the
program as returned by wait. You need to divide by
256 to come up with the actual exit status.
perldoc -f system
dgris
--
Daniel Grisinger dgris@perrin.dimensional.com
`By about halfway through I was beginning to guess the
ending, but it still kind of surprised me.'
David Hatunen, talking about the movie Titanic
------------------------------
Date: Sun, 11 Oct 1998 09:28:31 +0000
From: "Xah" <xah@best.com>
Subject: sorting hack
Message-Id: <6vqlr2$aga$1@nntp2.ba.best.com>
I have an array of arrays of the form [[a1,a2,...],[b1,b2,...],...]. I want
to sort them first by their digits starting from the left, then by their
length. For example, here's a sorted result
[[0], [1], [1, 0], [1, 1], [1, 1, 0], [1, 1, 1], [1, 1, 2], [1, 2], [1, 2,
0], [1, 2, 1], [1, 2, 2], [2], [2, 0], [2, 1], [2, 1, 0], [2, 1, 1], [2, 1,
2], [2, 2], [2, 2, 0], [2, 2, 1], [2, 2, 2]]
[1,1,2] comes before [1,2] because the second digit of first is smaller.
[1, 2] come before [1, 2, 0] because even their index comparison is neutral,
but the first has shorter length.
How would one best implement this in Perl? I couldn't figure out a way to
avoid a loop in the sort comparison subroutine. (I'm interested in speed
here.) This will be a function. The argument is not known until runtime.
Xah, xah@best.com
http://www.best.com/~xah/PageTwo_dir/more.html
Mountain View, CA, USA
------------------------------
Date: Sun, 11 Oct 1998 10:41:06 +0000
From: "Xah" <xah@best.com>
Subject: Re: sorting hack
Message-Id: <6vqq35$i19$1@nntp2.ba.best.com>
In article <6vqlr2$aga$1@nntp2.ba.best.com> , "Xah" <xah@best.com> wrote:
>
>I have an array of arrays of the form [[a1,a2,...],[b1,b2,...],...]. I want
>to sort them first by their digits starting from the left, then by their
>length. For example, here's a sorted result
>[[0], [1], [1, 0], [1, 1], [1, 1, 0], [1, 1, 1], [1, 1, 2], [1, 2], [1, 2,
>0], [1, 2, 1], [1, 2, 2], [2], [2, 0], [2, 1], [2, 1, 0], [2, 1, 1], [2, 1,
>2], [2, 2], [2, 2, 0], [2, 2, 1], [2, 2, 2]]
>
>[1,1,2] comes before [1,2] because the second digit of first is smaller.
>[1, 2] come before [1, 2, 0] because even their index comparison is neutral,
>but the first has shorter length.
>
>How would one best implement this in Perl? I couldn't figure out a way to
>avoid a loop in the sort comparison subroutine. (I'm interested in speed
>here.) This will be a function. The argument is not known until runtime.
>
> Xah, xah@best.com
> http://www.best.com/~xah/PageTwo_dir/more.html
> Mountain View, CA, USA
Here's the way I have it currently.
#indexOrdering([a1,a2,...],[b1,b2,...]) returns -1, 0, or 1 by comparing the
number sequence in each array reference from left to right. If both begins
with the same sequence, then it returns 0. The length of the arrays has no
effect. Example: print "@{[indexOrdering([2,2],[2,3,3])]}";
sub indexOrdering {
my @array1 = @{$_[0]};
my @array2 = @{$_[1]};
my $minLength;
if (scalar @array1 < scalar @array2) {$minLength = scalar @array1}
else {$minLength = scalar @array2};
for my $i (0..$minLength -1) {
if ($array1[$i] <=> $array2[$i]) {return $array1[$i] <=> $array2[$i];}
};
return 0;
};
#_indexSetSortFullArguments([index1, index2,...], sortByIndexFirstQ,
indexAscendingQ, lengthAscendingQ)
sub _indexSetSortFullArguments {
my @indexList = @{$_[0]};
my $sortByIndexFirstQ = $_[1];
my ($indexAscendingQ, $lengthAscendingQ) = ($_[2],$_[3]);
if ($sortByIndexFirstQ) {
if ($indexAscendingQ) {
if ($lengthAscendingQ) {@indexList = sort {indexOrdering($a,$b) || scalar
@{$a} <=> scalar @{$b} } @indexList;}
else {@indexList = sort {indexOrdering($a,$b) || scalar @{$b} <=> scalar
@{$a} } @indexList;}
}
else {
if ($lengthAscendingQ) {@indexList = sort {indexOrdering($b,$a) || scalar
@{$a} <=> scalar @{$b} } @indexList;}
else {@indexList = sort {indexOrdering($b,$a) || scalar @{$b} <=> scalar
@{$a} } @indexList;}
};
}
else {
if ($indexAscendingQ) {
if ($lengthAscendingQ) {@indexList = sort {scalar @{$a} <=> scalar @{$b}
|| "@{$a}" cmp "@{$b}"} @indexList;}
else {@indexList = sort {scalar @{$b} <=> scalar @{$a} || "@{$a}" cmp
"@{$b}"} @indexList;}
}
else {
if ($lengthAscendingQ) {@indexList = sort {scalar @{$a} <=> scalar @{$b}
|| "@{$b}" cmp "@{$a}" } @indexList;}
else {@indexList = sort { scalar @{$b} <=> scalar @{$a} || "@{$b}" cmp
"@{$a}" } @indexList;}
};
};
return \@indexList;
};
#-----------------------------
#testing
use Data::Dumper;
print Dumper(_indexSetSortFullArguments([[0], [1, 0], [1, 1, 0], [1, 1, 1],
[1, 1, 2], [1, 1], [1, 2, 0], [1, 2, 1], [1, 2, 2], [1, 2], [1], [2, 0], [2,
1, 0], [2, 1, 1], [2, 1, 2], [2, 1], [2, 2, 0], [2, 2, 1], [2, 2, 2], [2,
2], [2]],1,1,1) );
#-----------------------------
# sample return values:
#(0,0,0)
#[[2,2,2],[2,2,1],[2,2,'0'],[2,1,2],[2,1,1],[2,1,'0'],[1,2,2],[1,2,1],[1,2,'
0'],[1,1,2],[1,1,1],[1,1,'0'],[2,2],[2,1],[2,'0'],[1,2],[1,1],[1,'0'],[2],[1
],['0']];
#(0,0,1)
#[[2],[1],['0'],[2,2],[2,1],[2,'0'],[1,2],[1,1],[1,'0'],[2,2,2],[2,2,1],[2,2
,'0'],[2,1,2],[2,1,1],[2,1,'0'],[1,2,2],[1,2,1],[1,2,'0'],[1,1,2],[1,1,1],[1
,1,'0']];
#(0,1,0)
#[[1,1,'0'],[1,1,1],[1,1,2],[1,2,'0'],[1,2,1],[1,2,2],[2,1,'0'],[2,1,1],[2,1
,2],[2,2,'0'],[2,2,1],[2,2,2],[1,'0'],[1,1],[1,2],[2,'0'],[2,1],[2,2],['0'],
[1],[2]];
#(0,1,1)
#[['0'],[1],[2],[1,'0'],[1,1],[1,2],[2,'0'],[2,1],[2,2],[1,1,'0'],[1,1,1],[1
,1,2],[1,2,'0'],[1,2,1],[1,2,2],[2,1,'0'],[2,1,1],[2,1,2],[2,2,'0'],[2,2,1],
[2,2,2]];
#(1,0,0)
#[[2,2,2],[2,2,1],[2,2,'0'],[2,2],[2,1,2],[2,1,1],[2,1,'0'],[2,1],[2,'0'],[2
],[1,2,2],[1,2,1],[1,2,'0'],[1,2],[1,1,2],[1,1,1],[1,1,'0'],[1,1],[1,'0'],[1
],['0']];
#(1,0,1)
#[[2],[2,2],[2,2,2],[2,2,1],[2,2,'0'],[2,1],[2,1,2],[2,1,1],[2,1,'0'],[2,'0'
],[1],[1,2],[1,2,2],[1,2,1],[1,2,'0'],[1,1],[1,1,2],[1,1,1],[1,1,'0'],[1,'0'
],['0']];
#(1,1,0)
#[['0'],[1,'0'],[1,1,'0'],[1,1,1],[1,1,2],[1,1],[1,2,'0'],[1,2,1],[1,2,2],[1
,2],[1],[2,'0'],[2,1,'0'],[2,1,1],[2,1,2],[2,1],[2,2,'0'],[2,2,1],[2,2,2],[2
,2],[2]];
#(1,1,1)
#[['0'],[1],[1,'0'],[1,1],[1,1,'0'],[1,1,1],[1,1,2],[1,2],[1,2,'0'],[1,2,1],
[1,2,2],[2],[2,'0'],[2,1],[2,1,'0'],[2,1,1],[2,1,2],[2,2],[2,2,'0'],[2,2,1],
[2,2,2]];
PS why doe Data::Dump write 0 as '0'?
Xah, xah@best.com
http://www.best.com/~xah/PageTwo_dir/more.html
Mountain View, CA, USA
------------------------------
Date: Sun, 11 Oct 1998 17:03:25 +0000
From: Jason Holland <jason.holland@dial.pipex.com>
Subject: Re: What do you need to run perl?
Message-Id: <3620E4DD.2662BD3F@dial.pipex.com>
John Doe wrote:
>
> I would like to distribute perl scripts on a CD to machines that do not
> always have it installed. Can most of perl be kept on the CD and only a
> small working directory be maintained in the machine running it? Is it
> necessary to require a full installation in the machine running the
> scripts?
>
> chuck.meyers@lmco.com
What OS are you using? I use Perl on Macs, Windows and UNIX, on
Macintosh you could quite easily produce a standalone Perl CD, however I
believe that you may have more trouble under a UNIX or Windows system.
On Macintosh simply make a CD with the Perl distribution installed on
it, plus your own stuff.
Under Windows you could probably do the same, however the Windows Perl
installer fixes the Registry for you.
Under UNIX, you may be able to create a CD ISO filesystem under
/usr/local or somewhere, build Perl there and then burn a CD of it.
However this would of course probably only work under that specific type
of UNIX system and configuration. I don't have any experience of burning
CD's under UNIX though, I expect that there are a number of pitfalls if
you wish to create disks with executables on them.
Just some ideas...
--
sub jasonHolland {
my %hash = ( website =>
'http://dspace.dial.pipex.com/jason.holland/',
email => 'jason.holland@dial.pipex.com' );
}
------------------------------
Date: Sun, 11 Oct 1998 10:36:11 -0700
From: Andrew Perrin <aperrin@mcmahon.qal.berkeley.edu>
Subject: Re: Why it doesn't work under UNIX??????
Message-Id: <3620EC8B.AF1FF9C2@mcmahon.qal.berkeley.edu>
I deeply apologize for my incorrect and snide answer to the original poster.
Andy
I R A Aggie wrote:
> In article <361FB514.F06B8911@mcmahon.qal.berkeley.edu>, Andrew Perrin
> <aperrin@mcmahon.qal.berkeley.edu> wrote:
>
> + Why would it? These lines make no sense at all to me:
> + > @txt = <*.txt>;
> + > @zip = <*.zip>;
> +
> + you're asking perl to take the lines in a filehandle called *.zip
> (which, by the
> + way, could add lots of troubles since * also signifies a typeglob)
>
> Your first interpretation is incorrect, while your second thought touches
> upon the correct answer:
>
> <*.txt> is a typeglob. Exhibit A:
>
> % touch a.txt b.txt c.txt
> % touch a.zip b.zip c.zip
>
> % perl
> @txt = <*.txt>;
> @zip = <*.zip>;
> foreach $txt (@txt) {
> print "$txt\n";
> }
> foreach $zip (@zip) {
> print "$zip\n";
> }
>
> Results:
>
> a.txt
> b.txt
> c.txt
> a.zip
> b.zip
> c.zip
>
> Oh, well, it happens... :)
>
> James
--
-------------------------------------------------------------
Andrew J. Perrin - NT/Unix/Access Consulting - (650)938-4740
aperrin@mcmahon.qal.berkeley.edu (Remove the Junk Mail King)
http://www.geocities.com/SiliconValley/Grid/7544/
-------------------------------------------------------------
------------------------------
Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
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 3947
**************************************