[6692] in Perl-Users-Digest
Perl-Users Digest, Issue: 317 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Apr 16 16:17:55 1997
Date: Wed, 16 Apr 97 13:00:21 -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 Wed, 16 Apr 1997 Volume: 8 Number: 317
Today's topics:
Re: "-lna0F<" VS #! -lna0F< (ash)
Re: "Dummies" book any good? (Abigail)
Re: "Dummies" book any good? <rra@stanford.edu>
Re: A simple substitution (Abigail)
Re: Adding all possible combinations of list (Mike Stok)
auto refreshing form (Ed Young)
Re: auto refreshing form (A. Deckers)
Re: Camel Book example Question <seay@absyss.fr>
CGI scripts <hydrogen@netcom.ca>
Re: DNS reverse lookup - gethostbyaddr() <dbe@wgn.net>
Re: Kudos to Tom Christiansen and problems with OO <dbenhur@egames.com>
Passwords <scsREMOVE@huron.net>
Perl Shell instead of C Shell <dsonak@us.oracle.com>
Re: Perl Shell instead of C Shell (A. Deckers)
Prob with FAQ answer? Eliminating duplicates <melissa@vorlon.mit.edu>
Re: Q: How to make a dirhandle local to a subroutine? (Mike Stok)
Re: Q: Uniq'ing a list (Bill)
Re: Reply to Ousterhout's reply (was Re: Ousterhout and (Hume Smith)
Re: Running as root ()
Strings as a uniform representation & tcl <shivers@lambda.ai.mit.edu>
Re: system(); problem <bartolonem@med.ge.com>
Re: Two Perl Language Questions (Ilya Zakharevich)
Re: Unix and ease of use (WAS: Who makes more ...) (Abigail)
Re: WANTED: perl guru ;-) (Ralph Forsythe)
Re: Why doesn't until(<FILE> =~ /^\D/) { work? (John Klassa)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 16 Apr 1997 19:26:04 GMT
From: searlea@aston.ac.uk (ash)
Subject: Re: "-lna0F<" VS #! -lna0F<
Message-Id: <5j394c$bi9$1@whatsit.aston.ac.uk>
<everything snipped>
I've pinned down the problem to just the -l switch
(I checked the perl-bugs list at a CPAN mirror, but couldn't find any
mention of it - but I may not have been too thorough)
What's wrong with using the -l and -0 switch in a #!'d program?
The man pages state $\ is set to the value of $/ at the time the
switch is processed. So, surely the second example (t2) should produce
the same output as the first (ie. a new-line after printing something).
I take it the "Bad free() ignored." message is an internal error?
(I've never seen the perl source code)
Is it a bug?
(host)% t1; cat t1
something
#!/usr/local/bin/perl -lw
print "something";
(host)% t2 ; cat t2
Bad free() ignored.
something#!/usr/local/bin/perl -lw0
print "something";
(host)% t3 ; cat t3
something#!/usr/local/bin/perl -w0
print "something";
(host)%
------------------------------
Date: Wed, 16 Apr 1997 18:08:05 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: "Dummies" book any good?
Message-Id: <E8qt1H.200@nonexistent.com>
On Wed, 16 Apr 1997 10:51:40 GMT, Jonathan Peterson wrote in
comp.lang.perl.misc <URL: news:3354ab99.3478663@news.sonnet.co.uk>:
++
++ Explaining to a real beginner that:
++
++ if ($a == 1) {
++ print ("Whee!");
++ }
++
++ is the same as
++
++ $a || print ("Whee!");
++
++ is not something that you can do in a few sentences. More like a few
++ chapters.
Ok, then what do you do if the beginner set $a to 2 and complains it
prints "Whee" in the second case and not in the first?
Abigail
------------------------------
Date: 16 Apr 1997 12:17:36 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: "Dummies" book any good?
Message-Id: <qum3esqn5f3.fsf@cyclone.stanford.edu>
Jonathan Peterson <jon@amxdigital.com> writes:
> Knowing this makes it MUCH easier to learn how to use Perl's list
> handling functions and regexps, because you feel so much more confident
> with the rest of it. For a real, genuine, absolutely never programmed
> before not even Dos batch files or Word macros person, I think you
> really need to start with stuff like what a variable is, and spend a
> long time on it.
Agreed.
> If you have never programmed anything before, I think Perl is not an
> ideal starting place. This is NOT because Perl is inherently difficult
> (as many people think...), but because Perl is inherently clever, and
> writers of books are so eager to show the cleverness, they take the
> simple things as read.
Also agreed. Another point is that Perl is a very *full* language, and as
much as it is possible to write code only using a small portion of its
capabilities, I still think it's better for an absolute beginner at
programming to start with an extremely limited language so that they can
feel like they understand the entire thing.
This is why, even though it's not in vogue any more, I still very much
like basic, pointer-less Pascal as a teaching language. It teaches you
block constructs, variables, functions, parameter passing, and the like,
and does it in a very structured framework. While I'd hate to write
production code in that structured of a framework, since it would prevent
me from easily getting my job done, I think it's a good environment to
learn in since it *does* protect the programmer from themselves.
A lot of people don't like Pascal as a teaching language because it's not
a language that's actually *used*, but once you've picked up one
programming language all the subsequent ones are really fairly easy.
Perl, in particular, is *far* easier to learn as a third or fourth
language in my opinion, since once you've seen how several very different
languages do things, you can see how Perl lets you use all of those
paradigms at once. I'm very glad I knew both C and LISP before learning
Perl, since I can use both paradigms in my scripts at once.
A final note on this: If someone's an absolute rank beginner at
programming, unless they have an intuitive feel for structured design and
immediately grasp the concept of an if/then/else block the first time it's
explained to them (you'd be surprised at the number of people who don't),
I'd strongly recommend they find a local community college and take their
basic programming course rather than try to learn from a book. It'll be a
lot less frustrating and a lot more productive, and probably make them a
better programmer in the long run.
--
Russ Allbery (rra@stanford.edu) <URL:http://www.eyrie.org/~eagle/>
------------------------------
Date: Wed, 16 Apr 1997 18:05:19 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: A simple substitution
Message-Id: <E8qswv.1vt@nonexistent.com>
On 16 Apr 1997 05:29:03 GMT, Tom Christiansen wrote in
comp.lang.perl.misc <URL: news:5j1o2v$b3k$1@csnews.cs.colorado.edu>:
++ [courtesy cc of this posting sent to cited author via email]
++
++ In comp.lang.perl.misc, abigail@fnx.com writes:
++ :What's wrong with "tr/a-z\xe0-\xf6\xf8-\xfe/A-Z\xc0-\xd6\xd8-\xde/;"?
++
++ People don't know about it, and I bet you're assuming ISO 8859-1.
++ What about other locales?
I was assuming iso 8859-1. You are right that people don't know about
it, but do they know about how to set their locales? (I didn't until I
got this message).
++ :Well... that doesn't work on my computer. \w doesn't seem to recognize
++ :letters in the upper half of the character set. (Nor does \u uppercase
++ :those letters, or does \b treat them as letters.)
++
++ Your locale may not be set. Is $ENV{LC_CTYPE} set to "iso_8859_1"
++ or anything at all?
It wasn't set. The locale doesn't seem to be set by default on Solaris.
Abigail
------------------------------
Date: 16 Apr 1997 18:22:40 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Adding all possible combinations of list
Message-Id: <5j35dg$elb@news-central.tiac.net>
In article <5j2uki$hb0$1@shadow.skypoint.net>,
Susan Starr <sstarr@skypoint.com> wrote:
>I'm wondering if anyone knows of an elegant solution to my problem.
>
>I need to take a list of numbers and identify the values in the list
>that add up to 0. For example, if I had the following list:
>-5.00
>-2.50
>+3.00
>+7.50
>+2.20
#!/usr/local/bin/perl -w
@list = qw/-5.00 -2.50 +3.00 +7.50 +2.20/;
$limit = 1 << @list;
for ($counter = 1; $counter < $limit; $counter++) {
$sum = 0;
@indices = ();
@bits = reverse split //, unpack 'B32', pack 'N', $counter;
for ($index = 0; $index < @list; $index++) {
next unless $bits[$index];
$sum += $list[$index];
push @indices, $index;
}
if (abs ($sum) < 0.001) {
print "@list[@indices]\n";
}
}
__END__
might be one way to do it provided you're using < 30 element lists. Watch
out for floating point representation errors too if you're doing a non
integer exact comparison - I used 0.001 as an epsilon as an example, the
real value may vary depending on your data.
The reason for looking out for the length of the list is that the bitfield
is 32 bits long...
Hope this helps,
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com | Pencom Systems Administration (work)
------------------------------
Date: Wed, 16 Apr 1997 13:24:11 -0600
From: eyoung@ncsa.uiuc.edu (Ed Young)
Subject: auto refreshing form
Message-Id: <eyoung-1604971324110001@bopc3.ncsa.uiuc.edu>
I have an html form for a semi chat/guestbook. After you submit to the
form, the information is placed on the same page. Problem is in order to
see the updated form the end user has to reload/refresh their browser. How
can I code the page so that when they hit the submit button...it adds to
the page and then automaticly reloads the page. Thanks!
------------------------------
Date: 16 Apr 1997 18:31:41 GMT
From: Alain.Deckers@man.ac.uk (A. Deckers)
Subject: Re: auto refreshing form
Message-Id: <slrn5la6oe.hnh.Alain.Deckers@nessie.mcc.ac.uk>
In comp.lang.perl.misc,
eyoung@ncsa.uiuc.edu wrote:
>I have an html form for a semi chat/guestbook. After you submit to the
>form, the information is placed on the same page. Problem is in order to
>see the updated form the end user has to reload/refresh their browser. How
>can I code the page so that when they hit the submit button...it adds to
>the page and then automaticly reloads the page. Thanks!
This question isn't Perl-related. You'll have more luck if you post it in
a relevant newsgroup. Try one in the comp.infosystems.www.* hierarchy.
HTH,
--
Alain.Deckers@man.ac.uk <URL:http://www.man.ac.uk/%7Embzalgd/>
Perl information: <URL:http://www.perl.com/perl/>
Perl FAQ: <URL:http://www.perl.com/perl/faq/>
Perl archive: <URL:http://www.perl.com/CPAN/>
>>>>>>>>>>>>> NB: comp.lang.perl.misc is NOT a CGI group <<<<<<<<<<<<<<
------------------------------
Date: Wed, 16 Apr 1997 20:05:10 +0100
From: Douglas Seay <seay@absyss.fr>
To: ppitton.quada@t-online.de
Subject: Re: Camel Book example Question
Message-Id: <335522E6.7A46@absyss.fr>
[posted and mailed]
P. Pitton wrote:
>
> I have a question concerning an example in the Camel-Book, page 226
> named "printing lines after a designated matching line".
Note that it is poor form to give a page number from the first Camel
without saying so. Nowdays Camel II is the default.
> There is the procedure:
> perl -ne 4print if (/REGEX/ ? ($c=LINES) : (--$c > 0))4 FILES
-n says to put all the code in a loop with one iteration per line of
input putting the current line into the $_ variable
-e says to take the next word as a line of text (it will be inside the
loop from the -n)
print defaults to the variable $_ (which you may remember has one line
of input)
/REGEX/ is the same as $_ =~ m/REGEX/ and will return true if and only
if the current line of input matches the given regular expression
the x ? y : z is straight from C. if x is true (defined, not 0 nor '')
then evaluate y else z.
FILES at the end is the list of file names to use for input.
> Could anyone who understands this explain it in detail to me ?
> I don4t understand the inside of the parentheses, the ? and : look so
> strange to me.
?: is described on p91 of the original Camel.
Which parens? There is a pair after the if because there is always
parens after an if. There are also parens surrounding the two action
clauses of the ?: They are there mostly for legibility.
The way this if works is $c is initialized to 0 (like all variables).
the /REGEX/ will fail, $c will go negative and nothing will be printed.
If the /REGEX/ matches, $c will be assigned some value for the number of
lines that you would like printed. the "($c=LINES)" bit will return
LINES, so as long as LINES is non-0, the current line will be printed.
Each iteration afterwards $c is decremented and the line is printed.
Finally $c will go below 0 and nothing will be printed until the next
match of /REGEX/. If $c is greater than 0 (lines are being printed) and
there is a second match of /REGEX/, $c is reset to LINES, so that many
lines after the last match will be printed.
> Thanks for any help in advance,
Hope this helped.
- doug
------------------------------
Date: Wed, 16 Apr 1997 15:21:19 +0000
From: Luis Cardoso <hydrogen@netcom.ca>
Subject: CGI scripts
Message-Id: <3354EE5C.45B6@netcom.ca>
Hi!
Does anyone know of an ISP that is friendly or open to the idea of
allowing space on their servers for testing CGI's for non-commercial
use. I'm learning perlI and would like to be able to test my CGI
scripts. Preferably this ISP would charge nothing or very little for
this service if I was to use them as my service provider. I live in the
Toronto, Ontario area.
Thanks
Luis
------------------------------
Date: Wed, 16 Apr 1997 09:33:38 -0700
From: "$Bill Luebkert" <dbe@wgn.net>
To: Roland <roland@virtual.ch>
Subject: Re: DNS reverse lookup - gethostbyaddr()
Message-Id: <3354FF61.5D0B@wgn.net>
Roland wrote:
>
> I'am trying desperatly to convert a IP-Address to the corresponding
> hostname with a perl-script...
> All my experiments with gethostbyaddr() just returning a empty string
> and I cannot find any examples of how to do, where can I find some
> information about ?
Assuming an address in $addr of the form "1.2.3.4":
@dotted_addr = split (/\./, $addr);
$packed_addr = pack ("C4", @dotted_addr);
$host = gethostbyaddr ($packed_addr, 2);
CC: Roland <roland@virtual.ch>
--
,-/- __ _ _ $Bill Luebkert
(_/ / ) // // DBE Collectibles
/ ) /--< o // // http://www.wgn.net/~dbe/
-/-' /___/_<_</_</_ Email: dbe@wgn.net
------------------------------
Date: Wed, 16 Apr 1997 11:02:35 -0700
From: Devin Ben-Hur <dbenhur@egames.com>
Subject: Re: Kudos to Tom Christiansen and problems with OO
Message-Id: <3355143B.51AC@egames.com>
Terrence M. Brannon wrote:
> > Any other jazz pianist Perl types out there besides myself?
>
> The only Perl types are scalar, array, and hash. :-)
What about filehandle and subroutine?
--
Devin Ben-Hur <dbenhur@egames.com>
eGames.com, Inc. http://www.egames.com/
eMarketing, Inc. http://www.emarket.com/
"No, I'm not going to explain it. If you can't figure it out,
you didn't want to know anyway..." --Larry Wall
------------------------------
Date: 16 Apr 1997 18:12:07 GMT
From: "Stephen Hill" <scsREMOVE@huron.net>
Subject: Passwords
Message-Id: <01bc4a91$fc957d60$1a91e9cd@garcia.huron.net>
I am working on a script that will allow people to send/receive email
through thier browser.
I want to have people fill out a form on the main page to check thier mail
and I want to use the existing password file.
Is there a way to encrypt the password and then compare it to the password
file? If so, where do I get info on that?
--
Stephen Hill
scsREMOVE@huron.net
To email me just take the REMOVE outta the line above.
Getting really ticked at these Spammers!!!
------------------------------
Date: Wed, 16 Apr 1997 10:57:45 -0700
From: "Dipti V. Sonak" <dsonak@us.oracle.com>
Subject: Perl Shell instead of C Shell
Message-Id: <33551319.42DB@us.oracle.com>
My default shell is the C shell [ csh ]. I am wondering if I can have a
perl shell as my default shell ?
This is what I want to do :
% echo " This is a c shell"
.. This will echo the "This is a C shell" on the screen.
I want to :
% print "This is the perl shell"
.... This should "echo" the "This is a perl shell" on the screen.
Is there a way I can do this ?
Thanks,
Dipti Sonak
------------------------------
Date: 16 Apr 1997 18:26:55 GMT
From: Alain.Deckers@man.ac.uk (A. Deckers)
Subject: Re: Perl Shell instead of C Shell
Message-Id: <slrn5la6ff.hnh.Alain.Deckers@nessie.mcc.ac.uk>
In comp.lang.perl.misc,
dsonak@us.oracle.com wrote:
>My default shell is the C shell [ csh ]. I am wondering if I can have a
>perl shell as my default shell ?
Save this as psh and use it as your default shell:
---cut here---
#!/usr/bin/perl -w
print "psh> ";
while (<STDIN>) {
eval $_;
print "psh> ";
}
__END__
---cut here---
:-)
--
Alain.Deckers@man.ac.uk <URL:http://www.man.ac.uk/%7Embzalgd/>
Perl information: <URL:http://www.perl.com/perl/>
Perl FAQ: <URL:http://www.perl.com/perl/faq/>
Perl archive: <URL:http://www.perl.com/CPAN/>
>>>>>>>>>>>>> NB: comp.lang.perl.misc is NOT a CGI group <<<<<<<<<<<<<<
------------------------------
Date: 16 Apr 1997 14:49:26 -0400
From: Melissa Algeo <melissa@vorlon.mit.edu>
Subject: Prob with FAQ answer? Eliminating duplicates
Message-Id: <m367xmajm1.fsf@vorlon.mit.edu>
I'm trying to use the FAQ's suggested code for eliminating duplicates
from an array. Unfortunately, it seems to be eliminating entries
entirely. Here's the relevant bit of my program:
undef @valuesraw;
undef %name;
for $n (0 .. $#dbase) {
($value, $name) = ($dbase[$n]{'icreator'}, $dbase[$n]{'ecreator'});
$name{$value} = $name;
push @valuesraw, $value;
@values = grep(!$saw{$_}++, @valuesraw);
foreach $value(@values) {
print "<option value=$value>$name{$value} (creator code $value)\n";
}
}
The Mac creator codes are what need to be unique; it's OK if the
English names are the same. When I print it without the checking for
duplicates, I can verify that I'm slurping up all the data OK. The
inital list is *huge*, so I'll only include part of it here to
demonstrate my point:
<option value=XPR3>Quark XPress (creator code XPR3)
<option value=8BIM>Adobe Photoshop (creator code 8BIM)
<option value=movr>System Fonts (creator code movr)
<option value=XPR3>Quark XPress (creator code XPR3)
<option value=8BIM>Adobe Photoshop (creator code 8BIM)
<option value=movr>System Fonts (creator code movr)
<option value=ALD5>Adobe Pagemaker (creator code ALD5)
<option value=mdos>DOS Application (creator code mdos)
<option value=8BIM>Adobe Photoshop (creator code 8BIM)
<option value=movr>System Fonts (creator code movr)
<option value=ALD5>Adobe Pagemaker (creator code ALD5)
<option value=mdos>DOS Application (creator code mdos)
<option value=Cr37>Multi-Ad Creator (creator code Cr37)
<option value=movr>System Fonts (creator code movr)
<option value=ALD5>Adobe Pagemaker (creator code ALD5)
<option value=mdos>DOS Application (creator code mdos)
<option value=Cr37>Multi-Ad Creator (creator code Cr37)
<option value=ttxt>SimpleText (creator code ttxt)
<option value=8BIM>Adobe Photoshop (creator code 8BIM)
<option value=movr>System Fonts (creator code movr)
<option value=ALD5>Adobe Pagemaker (creator code ALD5)
<option value=mdos>DOS Application (creator code mdos)
<option value=Cr37>Multi-Ad Creator (creator code Cr37)
<option value=ttxt>TeachText (creator code ttxt)
<option value=ttxt>TeachText (creator code ttxt)
<option value=mdos>DOS Application (creator code mdos)
<option value=Cr37>Multi-Ad Creator (creator code Cr37)
<option value=Cr37>Multi-Ad Creator (creator code Cr37)
<option value=ALD5>Adobe Pagemaker (creator code ALD5)
<option value=movr>System Fonts (creator code movr)
<option value=ALD5>Adobe Pagemaker (creator code ALD5)
<option value=mdos>DOS Application (creator code mdos)
<option value=Cr37>Multi-Ad Creator (creator code Cr37)
<option value=ALD5>Adobe Pagemaker (creator code ALD5)
<option value=SIT!>Stuffit Classic (creator code SIT!)
<option value=8BIM>Adobe Photoshop (creator code 8BIM)
After the sort, here's the resulting list in its entirety:
<option value=XPR3>Quark XPress (creator code XPR3)
<option value=movr>System Fonts (creator code movr)
<option value=mdos>DOS Application (creator code mdos)
<option value=Cr37>Multi-Ad Creator (creator code Cr37)
<option value=ttxt>SimpleText (creator code ttxt)
<option value=DRVR>Fonts (creator code DRVR)
<option value=WDEF>Fonts (creator code WDEF)
<option value=MDEF>Fonts (creator code MDEF)
<option value=CDEF>Fonts (creator code CDEF)
<option value=PDEF>Fonts (creator code PDEF)
<option value=PACK>Fonts (creator code PACK)
<option value=RSV1>Fonts (creator code RSV1)
<option value=RSV2>Fonts (creator code RSV2)
<option value=ASPF>Fonts (creator code ASPF)
<option value=ART5>Adobe Illustrator (creator code ART5)
<option value=FH50>Macromedia Freehand (creator code FH50)
<option value=dplt>Script Editor (creator code dplt)
What happened to Adobe Photoshop, Adobe Pagemaker, Stuffit Classic,
TeachText, etc?
--
melissa@vorlon.mit.edu Melissa Algeo aa575@seorf.ohiou.edu
"Quis custodiet ipsos custodes?"
-Juvenal
------------------------------
Date: 16 Apr 1997 18:49:03 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Q: How to make a dirhandle local to a subroutine?
Message-Id: <5j36uv$fvk@news-central.tiac.net>
In article <5j0s3s$5kn@atlantis.utmb.edu>,
David Stoner <dstoner@marlin.utmb.edu> wrote:
>How can I make a dirhandle local to a subroutine?
>
>As mentioned in a previous article, I wrote a recursive subroutine in Perl to
>traverse a tree of directories, but I could find no way to make the dirhandle
>local to the subroutine, so different instances of the subroutine clobbered
>each other's dirhandles. I worked around the problem by having the subroutine
>read the entire directory into an array and close it before the subroutine
>called itself. That makes the routine a memory hog, so it fails on moderate-
>sized filesystems.
If you're using
opendir (DIR, $dir) || die ... ;
style coding then you can say
local (*DIR);
in the subroutine. If you're using perl 5 of a recent vintage then the
DirHandle module lets you put a reference to a DirHandle object into a
scalar so my (or local if you really want) can be used to scope the
scalar.
Hope this helps,
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com | Pencom Systems Administration (work)
------------------------------
Date: 16 Apr 1997 18:20:59 GMT
From: bill@sover.net.no.junkmail (Bill)
Subject: Re: Q: Uniq'ing a list
Message-Id: <slrn5la64b.2ts.bill@granite.sover.net>
[Posted and mailed.]
In article <5j0v6p$3qj@mortimer.deas.org>, Andreas Steffan wrote:
> Hi,
>
>Would someone please be so kind and tell me how to uniq a list
>in perl without using the UNIX 'uniq' command ?
>--
> TNX, Andreas
I generally stuff things into a hash and grab them back out again.
Granted, there may be better ways to do it, but it sure is easy. :) Try
something like:
#!/usr/bin/perl -w
@list = qw(one two three two four five);
foreach (@list) {
$hash{$_} = 1;
}
@list = ();
foreach (keys %hash) {
push(@list, $_);
}
Note that order is not preserved, but if you took the uniq approach
you've have to sort the array first anyway. Hope this helps...
Bill
--
Sending me unsolicited email through mass emailing about a product or
service your company sells ensures that I will never buy or recommend your
product or service.
------------------------------
Date: 16 Apr 1997 03:39:08 GMT
From: hclsmith@tallships.istar.ca (Hume Smith)
Subject: Re: Reply to Ousterhout's reply (was Re: Ousterhout and Tcl ...)
Message-Id: <5j1hks$46o@news.istar.ca>
In article <hbaker-1504971737030001@10.0.2.1>, hbaker@netcom.com says...
>
>In article <5j0gq5$jbi@mimsy.cs.umd.edu>, clin@cs.umd.edu (Charles Lin) wrote:
>
>> If one had to choose a single type for everything, a string is a
>> pretty good choice. Why not a number? How would you represent a
>> string with a number?
>
>Goedel showed how to represent everything with bignums.
same thing, really. Gvdel used base 1000, strings use base 256. (tcl strings,
anyway, where NUL can't be used. the "obivous" mapping won't distinguish the
null string from NUL from NUL-NUL etc.)
IIRC, it was in fact one of JO's points, that in a computer *everything* is a
number. i'm just as glad he chose to use strings, since i don't think i'd like
programming in 38154 much:
34758273445786346634726782237283742374857385683724
is my new newsreader, but it's got a bug. can you find it? :)
------------------------------
Date: Wed, 16 Apr 1997 14:46:45 GMT
From: wescott@cygnus.ColumbiaSC.NCR.COM ()
Subject: Re: Running as root
Message-Id: <E8qJpx.59z@ncrcae.ColumbiaSC.NCR.COM>
In article <5it3m7$b1q$1@power42t.hkbu.edu.hk>, Mr. Chow Wing Siu <wschow@Comp.HKBU.Edu.HK> writes:
> Hi, I write a C wrap program (setuid as root) to call a perl as root also.
> However, inside the perl script, it has many system() calls, apparently,
> it cannot run the system() calls as root. How to fix it?
In your wrapper program change the uid to root before exec'ing perl.
--
-Mike Wescott
mike.wescott@ColumbiaSC.NCR.COM
------------------------------
Date: 16 Apr 1997 14:42:25 -0400
From: Olin Shivers <shivers@lambda.ai.mit.edu>
Subject: Strings as a uniform representation & tcl
Message-Id: <qijbu7e95da.fsf_-_@lambda.ai.mit.edu>
> If one had to choose a single type for everything, a string is a
> pretty good choice. Why not a number? How would you represent a
> string with a number?
Perlis, as usual, summed it up well in one of his aphorisms:
The string is a stark data structure, and everywhere it
occurs there is much hiding of information.
This is what is wrong with both Unix and tcl. Their power is also a great
weakness: they are designed around a "least common denominator"
representation, strings. What it buys you is that everything interoperates.
The above aphorism explains what it costs you.
-Olin
------------------------------
Date: Wed, 16 Apr 1997 14:03:15 -0500
From: Mike Bartolone 5-4266 <bartolonem@med.ge.com>
Subject: Re: system(); problem
Message-Id: <33552273.446B@med.ge.com>
I just discovered that a friend of mine decided to play with my
browser's reply-to field as a joke, so I am reporting this in case any
one wants to e-mail me with a reply. The one on this message should
work.
I've been fighting with a perl script for over a month now. The
script compiles and runs just fine. When the script runs, it makes a
system(); call like this:
system("$ENV{'EXEHOME'}/program $params");
program $params produces an output file. It works just fine if I make
that call from the command line. I have checked and EXEHOME is in the
environment like it needs to me, along with a few other ENV vars.
For a long time we didn't know why we were getting no data in our
output file. Today, in some fine print, though, I discovered this
in the Programming PERL book, under 'system':
Note that argument processing varies depending on the number of
arguments, as described for exec.
I checked under exec and found this:
If there is more than one argument in LIST, or if LIST is an array with
more than one value, the function calls C's execvp(3) routine with the
arguments in LIST. If there is only one scalar argument, the argument is
checked for shell metacharacters. If there are any, the entire argument
is passed to "/bin/sh -c" for parsing. If there are none, the argument
is split into words and passed directly to execvp(3) in the interest of
efficiency.
So, I looked at my code again. The whole thing is in double quotes, so,
for the system call, it looks like one argument..it has shell meta's
(the $ in $params), so the whole thing is passed to "/bin/sh -c" for
parsing. I tried this by calling program like this:
/bin/sh -c program $params
(Yes, I set $params). This fails. I then typed this:
program $params
that seems to work just fine!
In place of the system call, I have tried the following commands:
`$ENV{'EXEHOME'}/program $params`
system('/usr/3p/bin/program $params');
and various other combinations of single quotes, double quotes, back
quotes, no quotes. I cannot get it to work!
So, does anyone know how to get my external program to run from within
my perl script?
--
Michel Bartolone | A competent and self-confident person
bartolonem@med.ge.com | is incapable of jealousy in anything.
bartolon@execpc.com | Jealousy is invariably a symptom of
| neurotic insecurity. -Robert Heinlein
------------------------------
Date: 16 Apr 1997 18:41:33 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Two Perl Language Questions
Message-Id: <5j36gt$rdo$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Paul Matthews
<plm@pcug.org.au>],
who wrote in article <335344C0.67368979@pcug.org.au>:
> G'Day,
>
> In the artical entitled 'Irregual Expressions', Tom Christiansen
> outlines how it would be nice to have a recursive matching with
> nesting. The example he gives is :
>
> /\b(?{begin)\b.*\b(?}end)\b/i
>
> to match begin...end blocks. Being in a position where this
> form of pattern matching would be nice, is there any 'offical'
> plans to include this in some future version of the language?
Not this, but a more powerful feature.
> Is so when?
When time comes.
Ilya
------------------------------
Date: Wed, 16 Apr 1997 18:37:23 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Unix and ease of use (WAS: Who makes more ...)
Message-Id: <E8quEC.8Cx@nonexistent.com>
On 16 Apr 1997 13:52:45 GMT, Jettero Heller wrote in
misc.jobs.misc,comp.lang.perl.misc,comp.lang.c++,comp.lang.c,comp.unix.advocacy,comp.os.ms-windows.advocacy,comp.os.linux.advocacy,comp.lang.basic.visual,comp.lang.javascript,comp.lang.tcl,comp.object,comp.databases,comp.infosystems.www.advocacy,comp.sys. <URL: news:5j2ljd$q0f@tracy.nacs.net>:
++ Tim Behrendsen (tim@a-sis.com) wrote:
++ [in reference to pkzip over tar+gzip]
++ : Or how about self-extracting archives?
++
++ This concept is utterly useless in un*x. The fact that you bring it
++ up indicates that you aren't completely clear on the concept behind
++ un*x.
What about shar?
Abigail
------------------------------
Date: 16 Apr 1997 17:45:45 GMT
From: ralph@hemi.com (Ralph Forsythe)
Subject: Re: WANTED: perl guru ;-)
Message-Id: <5j3389$eqr@news.hemi.com>
Well, you could try and put perl5 on there. It's available on CPAN. I'd
venture to say that you will like it a lot better than rewriting the
script to support perl 4.
- ralph forsythe
ralph@contact-paging.com
>I have a perl 5 script which I would like to run as a cgi.
>Unfortunately my system only supports perl 4 so I was wondering if
>someone could be so kind to see whether the script can be rewritten in
>perl 4 or not.
------------------------------
Date: 16 Apr 1997 18:08:05 GMT
From: klassa@gumby.ivc.com (John Klassa)
Subject: Re: Why doesn't until(<FILE> =~ /^\D/) { work?
Message-Id: <5j34i5$p3c@client2.news.psi.net>
Edited, you said something like:
->I wanted to use the following:
->until(<FILE> =~ /^\D/) {
->but htat didn't work, so I tried:
->until(<FILE> =~ /^\D/) {
->which also failed so I tried:
->while(<FILE>) {
->Which works, as I expected. Why do the other two methods not woek?
I don't think you can use the angle operator (<FILE>, in your case) in the
way you've used it ("<FILE> =~ /foo/)... The "while" version works per p.
53 of the new Camel...
--
John Klassa (W) klassa@ivc.com (H) klassa@ipass.net
<>< http://www.ivc.com/~klassa http://www.ipass.net/~klassa
(pgp fingerprint: 3C EE B4 02 40 76 DA 80 F1 96 90 FD 7A 1D 7D 53)
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V8 Issue 317
*************************************