[6729] in Perl-Users-Digest
Perl-Users Digest, Issue: 354 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Apr 23 11:09:18 1997
Date: Wed, 23 Apr 97 08:01:32 -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, 23 Apr 1997 Volume: 8 Number: 354
Today's topics:
Re: Ousterhout and Tcl lost the plot with latest paper (Arturo Prez)
Re: Ousterhout and Tcl lost the plot with latest paper (Andrew Koenig)
Passing parameter <Postmaster@ts-group.fi>
Re: Perl and EBCDIC (Jay Flaherty)
Re: Perl and EBCDIC (Bob Wilkinson)
Re: Perl as its own metalanguage? <lpa@sysdeco.no>
Re: PERL Editor (Eric Harley)
perl in commercial product, what to take care of? <Christoph_Marquardt@bbn.hp.com>
Re: Regular Expression Help Newbie (Andrew M. Langmead)
Re: STDOUT | PAGER (Bob Wilkinson)
W Setzer's curses (a-9) and turning off cursor (Dave Wheeler)
Re: why cant I access/print a list-of-lists this way (David Alan Black)
Win95: Socket connections (or not as the case may be) <Chris.King@swindon-fc.demon.co.uk.mars>
Re: wretched C++ (Was: Ousterhout and Tcl lost the plot (David Thornley)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 23 Apr 1997 08:58:33 -0400
From: perez@acm.org (Arturo Prez)
Subject: Re: Ousterhout and Tcl lost the plot with latest paper
Message-Id: <AF837FB99668DC55@ppp131.itw.com>
In article <MPG.dbeb63e1cab1e39989772@news.demon.co.uk>,
cyber_surfer@gubbish.wildcard.demon.co.uk (Cyber Surfer) wrote:
>With a mighty <01bc45a2$98f8ec40$0f02000a@gjchome.nis.newscorp.com>,
>
>Isn't it ironic that it's _MS_ doing this, and not Sun? What about
>Apple? Perhaps they've been doing this for years, and I've just missed
>it - considering how much bickering people do, it wouldn't be hard.
Apple, as usual, addressed this problem several years ago. It's called
OSA (I think it stands for Open Scripting Architecture).
Some weird, perhaps not exact descriptions of it are:
Imagine being able to activate Xt accelerators via an IPC mechanism.
Or
Imagine OpenLook synthetic events available via IPC.
You have your choice of syntaxes (Perl, AppleScript or Frontier are
available or you can make your own). You can do it from C (but man!
does that hurt from what I hear).
Print shops love the thing. With it they can automate an entire production
process using the applications they already have; e.g. QuarkExpress,
FileMaker, etc, etc.
If you're a consultant it may pay very well to know about it...
------------------------------
Date: Wed, 23 Apr 1997 13:23:50 GMT
From: ark@research.att.com (Andrew Koenig)
Subject: Re: Ousterhout and Tcl lost the plot with latest paper
Message-Id: <E93EJr.IBr@research.att.com>
In article <335D64A7.167E@nospam.acm.org> Thant Tessman <thant@nospam.acm.org> writes:
> And I recommend folks learn *any* language that supports higher-order
> functions, automatic memory management, and incremental compilation
> to see how truly wretched C++ is, regardless of whatever claims
> Stroustrup makes for it.
I learned Standard ML, which has all three of these properties,
several years ago, and I can say with confidence that from where
I sit, C++ is not wretched by comparison -- just different.
Each language has its strengths and weaknesses.
For example, I can write programs that manipulate trees and tree-like
data structures much more easily in ML than I can in C++, as long as
I stick to the operations that ML supports. But it can be useful sometimes
to do things that ML doesn't support well, and those things are much
harder to implement in a language that has trees virtually built in
than in a language where trees are built on top of a lower-level
abstraction.
Here is a somewhat simplistic example. The following ML code defines a
binary-tree data structure where each node contains a value and is
either a leaf or has two subtrees:
datatype 'a Tree = LEAF of 'a | TREE of 'a Tree * 'a Tree
Gorgeous! It's hard to imagine how such structures could be easier
to define. Now let me define a function that takes a tree and a
pair of values x and y and yields a new tree in which all nodes containing
x now contain y:
fun replace(t, x, y) =
case t of
LEAF a => LEAF (if a=x then y else a)
| TREE (left, right) =>
TREE(replace(left, x, y), replace(right, x, y))
Again, it's really nice to be able to write code like this.
But now suppose we want to be able to identify a specific subtree of a tree.
If I had gone to the trouble of creating a tree abstraction in C++, I could
identify a particular subtree by the address of its root. But there's no
corresponding facility in ML. Trees are values, and although one can compare
them for equality, there is no notion of object identity.
One way to solve that problem is to use ML references for the tree nodes.
But then the trees really do become objects, and treating them as values
becomes much more difficult. Moreover, I might not have thought I would
need to identify particular subtrees, and changing an existing data structure
to use references requires rewriting all of the code that uses it.
I have discussed this particular problem with people who know ML far better
than I do, and they agree that it is a problem. The best solution anyone has
offered is to define another abstraction that represents a path from the root
of a tree to a particular node, and traverse the tree in terms of such abstract
paths. This is not particularly hard to do in the example above, because there
are only two kinds of nodes involved. But if we were dealing with parse trees
in a programming environment, there might be dozens of kinds of nodes, and
the solution would become much more difficult.
Of course the real answer is to structure one's ML programs so as to avoid
such knotty problems. But that's exactly my point! Although ML offers
abstractions that make some programs extremely easy to write, it does so at
a cost. A professional attitude toward solving problems involves looking
at the tools available, picking the most useful one for the context --
the WHOLE context -- and then using it.
Incidentally, this whole discussion talks only about language. In deciding
what programming tools to use, there is more than that to consider. After
all, if all you care about is how easy the language is for you to use, why not
just invent your own language? You won't have a compiler for it unless you
write one, but if ease of programming is all you care about, that doesn't
matter. Of course, this facetious remark is intended to illustrate that
having a compiler that works well in your context matters too. But even that
is not all that matters. There is also the question of what tools your colleagues
use, and what tools the people might be using who will be maintaining your
code, and what machines you might be called on to support in the future.
C++ built on C precisely so that it would appeal to the existing C community.
As a result, support tools, a body of knowledge, and a community came along
more readily than they would have if the language had been designed totally
from scratch. And that knowledge and community, and those tools, are among
the main reasons why C++ is now in widespread commercial use and so many
of the designed-from-scratch languages are not.
--
--Andrew Koenig
ark@research.att.com
http://www.research.att.com/info/ark
------------------------------
Date: Wed, 23 Apr 1997 17:40:35 +0300
From: Postmaster <Postmaster@ts-group.fi>
Subject: Passing parameter
Message-Id: <335E1F63.14FA@ts-group.fi>
Hi,
I was wondering if the following would be possible.
I have a Perl script, which calls an exe-file with
following method and passes one parameter into it:
Example:
$test01 = "test.exe";
$test02 = "1234567890";
system "$test01 $test02";
Test.exe returns a string, which I would like to use
later in my script. The two problems are these:
Am I using the right way to call an external program
with a parameter?
How can I assing that string, which that external
program returns into a variable, since the following
fails:
$test03 = system"$test01 $test02";
Thank you in advance.
------------------------------
Date: 23 Apr 1997 13:15:04 GMT
From: fty@hickory.engr.utk.edu (Jay Flaherty)
Subject: Re: Perl and EBCDIC
Message-Id: <5jl20o$k7p$2@gaia.ns.utk.edu>
Chris Brown (cbrown@alaska.net) wrote:
:
: Looking for anything in Perl to help in converting
: EBCDIC to ASCII. Any ideas?
:
If you just want to convert ebcdic to ascii look at dd on unix.
Do a man on dd. This does not handle packed decimal or binary data
fields...Jay
--
**********************************************
Jay Flaherty fty@hickory.engr.utk.edu
------visualize whirled peas------
**********************************************
------------------------------
Date: Wed, 23 Apr 1997 15:02:30 +0100
From: b.wilkinson@NOSPAM.pindar.co.uk (Bob Wilkinson)
Subject: Re: Perl and EBCDIC
Message-Id: <b.wilkinson-2304971502300001@ip57-york.pindar.co.uk>
cbrown@alaska.net (Chris Brown) writes:
>
>
> > Looking for anything in Perl to help in converting
> >EBCDIC to ASCII. Any ideas?
> >
>
I found a program called charconv (written in C) on the web written by
Burkhard Kirste (kirste@chemie.fu-berlin.de).
So I'd just use a "system" call.
Bob
P.S. This program also converts between other formats, too.
--
I have become death, destroyer of the worlds.
------------------------------
Date: Wed, 23 Apr 1997 16:40:56 +0200
From: Luca Passani <lpa@sysdeco.no>
Subject: Re: Perl as its own metalanguage?
Message-Id: <335E1F78.6E38@sysdeco.no>
Well, comparing Prolog to Perl can cause an interesting academical
discussion, but, in practice, they are two totally different worlds
not worth comparing.
Perl is good for having things done. Perl is legitimated by those who
use it. Perl does not expect anyone to give it respect it didn't deserve
on the programming fields. Perl is capitalism.
Prolog is not good for any serious application. Prolog is legitimated by
those guys in Universities that never really had to deal with real
software development. Prolog is made and supported by idealist
raving about a future that will never come. Prolog is communism.
By unfortunate coincidence Prolog and Perl scripts share the .pl suffix,
though.
Luca
PS :-)
Terrence M. Brannon wrote:
>
> I was going through a book on Prolog and realized that all the
> features of Prolog that the author described which make it a
> metalanguage for itself also apply to Perl:
> * a program can create new goals by computation and
> then execute them.
>
> * a program can examine itself and modify itself
>
> * by declaring operators, a program can even change the
> syntax of the language itself (not sure on this one)
>
> * Prolog programs can extend and modify the inference
> engine that controls program execution. Perl can create
> any number of control structures via redo, last, next
>
> * As a sidenote he says: Prolog blurs the distinction
> between program and data.
--
======================================================================
Luca Passani. | Sysdeco Innovation AS, http://www.sysdeco.no
Email: lpa@sysdeco.no | Trondheimsveien 184, 0570 Oslo, Norway
Tel: (+47) 22 09 66 06 | Fax: (+47) 22 09 65 03
======================================================================
------------------------------
Date: Wed, 23 Apr 1997 06:52:48 -0700
From: erich@powerwareintl.com (Eric Harley)
Subject: Re: PERL Editor
Message-Id: <erich-2304970652480001@ppp-207-104-16-39.snrf01.pacbell.net>
In article <335DFEF3.3F89@unl.ac.uk>, a.aitken@unl.ac.uk wrote:
> Kyzer wrote:
> >
> > Dick Barker of dickb@eskimo.com wrote in comp.lang.perl.misc:
> > : Real perl programmers use cat >fname to write their stuff.
> > Actually they use emacs.pl :)
>
> I use twenty six half potatoes. I'm working on puntuation now but kanji
> scares the hell out of me :-)
>
> vi anyone?
vi is for amatuers. I use ed.
------------------------------
Date: Wed, 23 Apr 1997 14:13:46 +0200
From: Christoph Marquardt <Christoph_Marquardt@bbn.hp.com>
Subject: perl in commercial product, what to take care of?
Message-Id: <335DFCEA.53BB@bbn.hp.com>
I need to find out what I should take care of if I want to use Perl
in a commercial product.
Do you have any pointers to information about
- what copyrights/pointers etc. need to be kept with Perl?
- what files/libs/... are required to have a minimum functioning
distribution?
Any help appreciated, replies please mailto:chrism@bbn.hp.com
Best regards,
Christoph Marquardt
--
the above message does not necessarily reflect my employer's opinion
------------------------------
Date: Wed, 23 Apr 1997 14:11:08 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Regular Expression Help Newbie
Message-Id: <E93GqK.EGI@world.std.com>
Deepak Thadani <deepak@pcsltd.com> writes:
> I have a perl script in which
>$_ = "881 /usr/spool/mmdf/lock/home"
>What I want to do is get the number (in this case 881) into a variable
>called $VALUE. This is what I've got, which only seems to return
>the 1.
>$VALUE = /[0-9]*\S\//;
>What I believe the above is doing is getting all the numbers until
>I get to a white space or / right? Apparently wrong since $VALUE
>after running that line, is simply 1.
One problem is that you aren't saving the numbers you are
matching. Take a look at where the perlre man page discusses
parenthesis.
Another problem is that "\S" matches non-whitespace characters. You
mean "\s".
One last problem is that m// returns different things depending on
whether it is given a scalar or a list context. In a scalar context
(like being assigned to a scalar variable named $VALUE) the match
operator returns either 1 or 0, depending on whether it matched or
not. A list context will return all the subexpressions that the
parenthesis matched, or the list (1) if there are none.
I think what you want is:
($VALUE) = m#^([0-9]*)\s#;
Or you can say:
$VALUE = $_ + 0;
(Since perl sees a numeric context, it will convert $_ to a number.)
--
Andrew Langmead
------------------------------
Date: Wed, 23 Apr 1997 15:21:06 +0100
From: b.wilkinson@NOSPAM.pindar.co.uk (Bob Wilkinson)
Subject: Re: STDOUT | PAGER
Message-Id: <b.wilkinson-2304971521060001@ip57-york.pindar.co.uk>
In article <5jk15n$utu$1@dartvax.dartmouth.edu>,
Ronald.J.Kimball@dartmouth.edu (Chipmunk) wrote:
> My perl program pipes some of its output through a pager:
> $pager = $ENV{PAGER} || 'more';
> open (PAGER, "| $pager") or *PAGER = *STDOUT;
>
> Unfortunately, if the pager is more, and I exit more in the middle of
> the output by typing 'q', my perl program exits with the message
> 'Broken Pipe'.
>
> How can I make the perl continue execution normally if someone exits
> the pager before reaching the end of the output?
>
> thanks,
> Chipmunk
I think that this is a shell problem, not a Perl problem.
Bob
--
I have become death, destroyer of the worlds.
------------------------------
Date: Wed, 23 Apr 1997 15:16:26 GMT
From: Dave@xenware.demon.co.uk (Dave Wheeler)
Subject: W Setzer's curses (a-9) and turning off cursor
Message-Id: <335e26fa.78506153@news.demon.co.uk>
I am using the above quite successfully under SCO openserver, with the
exception that I can find no way to turn off the cursor (curs_set
appears not to be implemented).
Does anyone know of an alternative (other than defining and printing a
string, thus making it terminal dependant)?
TIA
Dave
------------------------------
Date: 23 Apr 1997 13:53:29 GMT
From: dblack@icarus.shu.edu (David Alan Black)
Subject: Re: why cant I access/print a list-of-lists this way
Message-Id: <5jl48p$k6l@pirate.shu.edu>
Hello -
tgy@chocobo.org (Tim Gim Yee) writes:
>On 22 Apr 1997 14:20:54 -0700, brannon@bufo.usc.edu (Terrence M.
>Brannon) wrote:
>>@vilist = ( [ $p, $s ] , [ $p, $s ] , [ $s , $p ] , [ $s , $p ] );
>>@ivlist = (0,1,0,1);
>>
>>foreach $vi (@vilist) {
>> foreach $invariant_value (@ivlist) {
>> print "=" x 50;
>> print "\n";
>> $variant = $vi[0]; # <--- this line
>> $invariant = $vi[1]; # <--- and this line both fail
>Each $vi from @vilist is an array reference. You need to dereference
>it first. Perhaps...
> my @tmp = @$vi;
> $variant = $tmp[0];
> $invariant = $tmp[1];
or:
$variant = $$vi[0];
$invariant = $$vi[1];
(Same principle as @$vi, but grabbing one element instead of the
whole list.)
or:
$variant = $vi->[0];
$invariant = $vi->[0];
David Black
dblack@icarus.shu.edu
------------------------------
Date: Wed, 23 Apr 1997 14:06:22 +0100
From: Chris King <Chris.King@swindon-fc.demon.co.uk.mars>
Subject: Win95: Socket connections (or not as the case may be)
Message-Id: <pdYk$XAOlgXzEwox@swindon-fc.demon.co.uk>
Hi,
I'm attempting (not too succesfully at the moment!) to get Perl5.003
(build 305, 02Apr1997) for Win95 to communicate with the outside-world.
I've used a slightly altered version of the server/client programs in
the back of the first camel, they work fine connecting to my machine,
but not an external one.
The 'connect()'
fails with the message:
No such file or directory
Here's the whole program anyway - it's supposed to be a finger client.
Well I thought I'd start with something that had an easy protocol... any
suggestions greatly appreciated.
#!/bin/perl -w
use Socket;
# Finger client - RFC1288 for protocol
# Get username@host[@host] info from command-line
($user,@hosts)=split("\@",$ARGV[0]);
$hosts[0]="localhost" unless @hosts;
$user=join("\@",$user,@hosts[0..($#hosts-1)]) if ($#hosts>0);
$host=$hosts[$#hosts];
print "Fingering: $user \@ $host\n";
$thishost="localhost";
$port=79;
$AF_INET=Socket::AF_INET;
$SOCK_STREAM=Socket::SOCK_STREAM;
$sockaddr='S n a4 x8';
($name,$aliases,$proto)=getprotobyname('tcp'); #20
($name,$aliases,$port)=getservbyname($port,'TCP') unless $port =~
/^\d+$/;;
($name,$aliases,$type,$len,$thisaddr)=gethostbyname($thishost);
($name,$aliases,$type,$len,$thataddr)=gethostbyname($host);
print "Trying ",join("\.",unpack("C4",$thataddr)),"\n\n";
$this=pack($sockaddr,$AF_INET,0,$thisaddr);
$that=pack($sockaddr,$AF_INET,$port,$thataddr);
if (socket(S,$AF_INET,$SOCK_STREAM,$proto)){
# print "Socket ok\n";
}
else {
print "Socket failed\n";
die $!;
}
if (bind(S,$this)) {
# print "bind ok\n";
}
else {
print "bind failed:\n";
die $!;
}
if (connect(S,$that)) { # Fails here
# print "Connect ok\n";
}
else {
print "Connect failed:\n";
die "$!";
}
select(S);$|=1;select(STDOUT); # Doesn't get this far
print S "$user\r\n";
while (<S>) {
print;
}
__END__
--
Chris King
The similarity of any fact mentioned within this post and
any in reality, living or dead, is purely coincidental.
Remove 'mars' from address when replying. I hate spam.
I like corned beef though.
------------------------------
Date: 23 Apr 1997 13:29:27 GMT
From: thornley@visi.com (David Thornley)
Subject: Re: wretched C++ (Was: Ousterhout and Tcl lost the plot with latest paper)
Message-Id: <5jl2rn$5gf$1@darla.visi.com>
In article <335D8429.41C6@nospam.acm.org>,
Thant Tessman <thant@nospam.acm.org> wrote:
>I wrote:
>
>[...wretched C++...]
>
>If what I wrote sounds harsh, let me explain what I had just spent
>the previous two hours doing.
>
>I had this:
>
> struct A { /* ... */ }
>
> template <class T>
> struct B : A { /* ... */ }
>
>I wanted to do this:
>
> A* a = new B<whatever>;
>
> B<whatever>* b = dynamic_cast<B<whatever>*>(a);
>
OK, looks like templates and RTTI. These aren't exactly the latest
features in the draft standard, but I don't expect them to be
completely stable yet.
>I managed to figure out that in order for this to work, it's
>not enough that the compiler see the entire definition of B<T>,
>but it also needs to see B<whatever> explicitly instantiated.
>According to the ANSI C++ proposal, this is done like so:
>
> template class B<whatever>;
>
>But of course the compiler I'm using doesn't support this yet.
>(IRIX 6.2 C++ 7.1) so you have to do this instead:
>
> #pragma instantiate B<whatever>
>
>There were no warnings, and no clues about what I was doing
>wrong. dynamic_cast just consistently returned zero.
>
OK, so your compiler doesn't support the draft ANSI standard,
and doesn't provide warnings or clues. This looks like an
implementation problem to me. In particular, I don't think
it's actually Stroustrup's fault you spent hours figuring this
out.
>C++ is *full* of bullshit like this and I've spent way too
>much of my life fighting it.
>
No, C++ compilers are full of bullshit. On my favorite platform,
the C++ libraries automatically installed are really, really
shaky, requiring explicit iterator_traits declarations just
in able to do a simple vector<Fnord, allocator<Fnord> >
(which, of course, should be writable as vector<Fnord>).
C++ started when Stroustrup wanted to program with the ease of
Simula and the efficiency of C. It's taken a while, but it
looks to me like the C++ standard is something like the closure
(in the mathematical sense, sort of) of the facilities he needs
to program his way over the possible facility space. In other
words, the C++ committee has largely been following Stroustrup's
lead, and continuing in logical directions. This isn't a bad
way to design a programming language, but no way is perfect
or guaranteed success.
The current result is certainly massive, but my HTML copy of
the latest draft takes up a lot less of my disk than the Common
Lisp Hyperspec. I don't think it's necessarily too complicated,
but it has been moving fast and implementations will need to
catch up.
When the dust is settled, C++ will have many of the things I like
about Lisp, and will be cheaper, more readily available, and will
be better about producing stand-alone applications. Further, I
think C++ will be very usable, and that many of its faults can
be corrected with libraries, just as many things that should be
in Common Lisp have been implemented with macros. (Yes, there is
at least one freely available garbage collection library for C++.)
In the meantime, I suggest that, when you spend hours in frustration
with your C++ system, let your vendor know. (You should have seen
the fireworks in comp.sys.mac.programmer.codewarrior after CW 11
was released!) Let whoever makes decisions on buying systems know.
Vendors in a competitive field don't like to have their customers
angry at them.
Not that this has a whole lot to do with Lisp, but I at least
mentioned it twice above.
David Thornley
"Remember, we're the Phone Company. We don't care. We don't have to."
-Lily Tomlin on Saturday Night Live
------------------------------
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 354
*************************************