[6766] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 391 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Apr 29 13:17:40 1997

Date: Tue, 29 Apr 97 10:00:23 -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           Tue, 29 Apr 1997     Volume: 8 Number: 391

Today's topics:
     'C' structure passing <ohlund@industry.net>
     Re: Deleting Files (A. Deckers)
     Re: Deleting Files <a.aitken@unl.ac.uk>
     Extracting pseudo HTML from string (Todd Wallace)
     Re: Extracting pseudo HTML from string <a.aitken@unl.ac.uk>
     Re: file copy (Chipmunk)
     Re: file copy (Martin Cohen)
     Re: Genetic programming (revisited) <fawcett.SPAMBEGONE@nynexst.com>
     Re: Genetic programming (revisited) (Zachary Brown)
     How to do asynchronous I/O on a socket ?? <joshua.spurgeon@blr.sni.de>
     Re: Is perl too slow? (Eric Bohlman)
     Re: joinig 2 files <flg@vhojd.skovde.se>
     Re: joinig 2 files (Tad McClellan)
     Re: joinig 2 files (M.J.T. Guy)
     Re: List Syntax vs. Conventional Syntax (was Re: Ouster (Henry Baker)
     Re: List Syntax vs. Conventional Syntax (was Re: Ouster (Paul Wilson)
     Re: MIF File Generator (Periat Henri)
     nds newNDS = nestedDataStructure->copy()? <stephen+usenet@farrell.org>
     Re: Network Programming and Sockets (Eric Bohlman)
     Re: Notice to antispammers <rsi@lucent.com>
     Re: Notice to antispammers <tchrist@mox.perl.com>
     Re: Object IDs are good ( was: Object IDs are bad ) (Paul Wilson)
     Re: Ousterhout and Tcl lost the plot with latest paper (Donal K. Fellows)
     Perl as a script interpreter in win32 app <hhowe@trgnet.com>
     Re: Perl auto-replier (Chipmunk)
     Re: Perl auto-replier <tchrist@mox.perl.com>
     Perl database search and page generation RyanO@AccessComms.co.uk
     Re: Pointing a Filehandle _AT_ a Subroutine (Brand and Karina Hilton)
     Re: pre-RFD: comp.lang.perl.{data-structure,inter-proce <seay@absyss.fr>
     Re: quote of the day? (Chipmunk)
     SQL database access with Perl <tschuber@syskonnect.de>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Tue, 29 Apr 1997 11:36:57 -0400
From: Mark Ohlund <ohlund@industry.net>
Subject: 'C' structure passing
Message-Id: <33661599.33DE@industry.net>

I have a 'C' application which has defined a type XLong as:

typedef struct XLong {
	long high;
	long low;
} XLong;

I'm trying to pass this back to Perl and I can't figure out what entry
to put in the 'typemap' file for the XS compiler. Anyone have any ideas
about this?

Please reply to ohlund@netsinc.com. Thanks.

~Mark.




-- 
____________________________
Mark Ohlund                
80% Systems Architect 
Nets Inc.
ohlund@netsinc.com
phone: 412.560.3723


------------------------------

Date: 29 Apr 1997 13:58:40 GMT
From: I-hate-cyber-promo@man.ac.uk (A. Deckers)
Subject: Re: Deleting Files
Message-Id: <slrn5mbvk8.ib8.I-hate-cyber-promo@nessie.mcc.ac.uk>

In comp.lang.perl.misc,
	cristo@consotech.se wrote:
>
>Hi!
>
>A quick question. How do I delete a file in Perl?

unlink $file;

>Second question. How do I make a back button with HTML?

You don't. You could do it with JavaScript, though.

>Third question. How do I create a Directory?

mkdir $dir, $perms;

>Thanx!

Pleasure. Now go read the FAQ.

HTH,

Alain

-- 
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/>


------------------------------

Date: Tue, 29 Apr 1997 16:50:31 +0100
From: Alastair Aitken <a.aitken@unl.ac.uk>
Subject: Re: Deleting Files
Message-Id: <336618C7.4A8A@unl.ac.uk>

Cristo wrote:

> A quick question. How do I delete a file in Perl?

system ("rm <filename>");	# returns the exit value of the wait() call -
divide this by 256
exec ("rm <filename>");		# does not return anything
$scalar = `rm <filename`;	# bit silly in this case but backticks return
the out of the command (eg ls)

> Second question. How do I make a back button with HTML?

print "<a href=\"$ENV{'HTTP_REFERER'}\"><img
src=\"backbutton.gif\"></a>\n";

That line makes an educated (sheesh - did I say that?) guess at your
CGI's behaviour.  Oh - and you need that gif too.

> Third question. How do I create a Directory?

mkdir("<dirname>",<mode>);	# <mode> is probably 0755 ... but maybe not
:-)

> Thanx!

Ce niente.

> Please e-mail me the answer to cristo@consotech.se

No.

Alastair.


------------------------------

Date: 29 Apr 1997 14:05:28 GMT
From: twallace@nicom.com (Todd Wallace)
Subject: Extracting pseudo HTML from string
Message-Id: <5k4v78$52h@intra.icma.org>

I have a string that looks like 
"asdfafasdf<FNAME>Tom</FNAME>sdfsdfsfsd"
and I want to extract the text between the <FNAME> and </FNAME> tags.
I have been trying to do with with split, substitute (s///) etc., and I can't
figure out how to do this.

Any help greatly appreciated.



------------------------------

Date: Tue, 29 Apr 1997 17:05:11 +0100
From: Alastair Aitken <a.aitken@unl.ac.uk>
Subject: Re: Extracting pseudo HTML from string
Message-Id: <33661C37.4410@unl.ac.uk>

Todd Wallace wrote:
 
> I have a string that looks like
> "asdfafasdf<FNAME>Tom</FNAME>sdfsdfsfsd"
> and I want to extract the text between the <FNAME> and </FNAME> tags.
> I have been trying to do with with split, substitute (s///) etc., and I can't
> figure out how to do this.

$a =  "asdfafasdf<FNAME>Tom</FNAME>sdfsdfsfsd";
$b = substr($a,index($a,"<FNAME>") + 7, index($a,"</FNAME>") -
(index($a,"<FNAME>) + 7));

That calculates the startpoint and length of the string in the middle:
"Tom" in this case.  You'll find "Tom" in the scalar $b.  It's probably
more efficient than patterning but that's a lot of indexing :-).

The "7" that I used there is the length of "<FNAME>" which has to be
accounted for in order to derive the startpoint for the target string. 
The length of "</FNAME>" does not have to be accounted for because the
startpoint is what I was after.

Alastair.


------------------------------

Date: 29 Apr 1997 13:41:18 GMT
From: Ronald.J.Kimball@dartmouth.edu (Chipmunk)
Subject: Re: file copy
Message-Id: <5k4tpu$k7r$3@dartvax.dartmouth.edu>

In article <3364C6F3.7A58@pobox.upenn.edu>
Becky Schonfeld <rebecc60@pobox.upenn.edu> writes:

> I have used the following bit of perl to attempt to get file $A to be
> copied to $B except for one line ($break of file $A).  However it seems
> to not skip line $break.  Can anyone help?
> 
> $records=0;
> open(IN, "$A") || die "cannot open $A for reading";
> open(OUT, ">$B") || die "cannot create $B";
> while (<IN>){
> if ($records != $break){
> print OUT $_;}
> $records++;
> }

Here's your problem:

!= is a numeric comparison operator.
You want ne (for not equal) which is a string comparison operator.

Similarly, all the numeric comparison operators have string comparison
counterparts.

Chipmunk


------------------------------

Date: 29 Apr 97 10:15:55 GMT
From: mcohen@arl.mil (Martin Cohen)
Subject: Re: file copy
Message-Id: <3365CA5B.E66@arl.mil>


Becky Schonfeld wrote:
-
- I have used the following bit of perl to attempt to get file $A to be
- copied to $B except for one line ($break of file $A).  However it
seems
- to not skip line $break.  Can anyone help?
-
- $records=0;
- open(IN, "$A") || die "cannot open $A for reading";
- open(OUT, ">$B") || die "cannot create $B";
- while (<IN>){
- if ($records != $break){
- print OUT $_;}
- $records++;
- }

Just a thought: did the line following $break get copied?
Perhaps $break is one-based; $records is 0-based.
-- 
Martin Cohen - AMSAA-North - Custom House Rm 800 Phila PA 19106-2976


------------------------------

Date: 29 Apr 1997 11:08:17 -0400
From: Tom Fawcett <fawcett.SPAMBEGONE@nynexst.com>
To: zbrown@lynx.dac.neu.edu (Zachary Brown)
Subject: Re: Genetic programming (revisited)
Message-Id: <8j3es9lvdq.fsf@nynexst.com>

zbrown@lynx.dac.neu.edu (Zachary Brown) writes:
> No reply to my question if anyone had written a library for creating 
> random perl code within user defined parameters. I did get an email from 
> someone else interested in the same problem, though.

So probably no one has.

> Any takers? I tried and failed, but if it were done right, it would be 
> great.

For a while I considered writing/porting a genetic algorithm package in/to
Perl, but gave up for two reasons.  They probably apply to GP as well.

- Perl isn't fast enough to do it natively.  While perl data structures are
  convenient and malleable, people doing GA's want maximum speed and
  probably aren't willing to take a 10x time hit for the implementor's
  convenience.

- Interfacing to an existing C library has problems.  The data has to be
  kept on the C side, but the population has to be evaluated on the Perl
  side, but evaluation needs code/strings retrieved from the C side.  Apart
  from the difficulty of implementing this well in XS or SWIG, I guessed
  that passing data back and forth so much would incur about the same
  penalty as keeping it all on the Perl side.

So I gave it up based on these observations.  I didn't actually implement
enough of either approach to do time tests.  

> Perl is an ideal genetic programming environment.

Except for speed, yes.  In any case, if you write something, please
contribute it to the CPAN.

-Tom


------------------------------

Date: 29 Apr 1997 12:00:09 -0400
From: zbrown@lynx.dac.neu.edu (Zachary Brown)
Subject: Re: Genetic programming (revisited)
Message-Id: <5k55u9$e2t@lynx.dac.neu.edu>

In article <5k4rng$d4r@lynx.dac.neu.edu>,
Zachary Brown <zbrown@lynx.dac.neu.edu> wrote:
>No reply to my question if anyone had written a library for creating 
>random perl code within user defined parameters. I did get an email from 
>someone else interested in the same problem, though.
>
>Any takers? I tried and failed, but if it were done right, it would be 
>great. Perl is an ideal genetic programming environment.
>
>Zack
>

Well, I got some replies now. They basically say that perl is too slow 
for genetic programming, and that scheme would be better. That is a big 
disappointment.

Zack



------------------------------

Date: Tue, 29 Apr 1997 16:48:55 +0200
From: "K.Joshua Spurgeon" <joshua.spurgeon@blr.sni.de>
Subject: How to do asynchronous I/O on a socket ??
Message-Id: <33660A57.41C67EA6@blr.sni.de>

Hello, 

Can anybody help me about setting the nonblocking flag on 
a socket? I tried like this

fcntl(SOCK, F_SETFL, O_NONBLOCK)

but it gives an error saying "access to read-only attributes not
allowed"

Please help me.

Thanks in advance.

K.J. Spurgeon.


------------------------------

Date: Tue, 29 Apr 1997 14:31:04 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Is perl too slow?
Message-Id: <ebohlmanE9ELns.51n@netcom.com>

Jan "Yenya" Kasprzak (no_spam_please@fi.muni.cz) wrote:
: 	I have visited a www page of my friend, where he compares
: speed of various interpreters and compilers. You can visit this page
: page at http://www.fi.muni.cz/~pdm/lang-competition.html.
: He simply compares a sorting algorithm written in (_not_ built in)
: various languages. Perl is there even slower than Java and Emacs LISP.
: I have looked at his perl code -- it is rather ugly, but I wasn't
: able to achieve any massive speed improvement by rewriting it.
: I was able to get a 10%-25% better speed than the original code.

: 	Is perl too slow? Or can anyone write faster sorting algorithm
: (not using builtin sort)?

When you take a language with built-in sophisticated string processing 
features and try to use them as primitives for something like sorting, 
you're always going to get a major slowdown, simply because there's a 
fair amount of overhead inside the sophisticated string processing 
routines.  When you use the sophisticated routines for sophisticated 
processing, that overhead is a small percentage of the total run time, 
but when you use them to do lots of little steps instead of a few big 
steps, the overhead becomes large.  This isn't unique to Perl, or to 
string processing.  If you were to use Mathematica or Matlab to write a 
step-by-step matrix inversion routine, it would be horribly slow, because 
those languages are designed to do "big step" operations on matrices, and 
have lots of overhead when used in a "little step" manner.



------------------------------

Date: 29 Apr 97 12:20:58 GMT
From: "Fredrik Lindberg" <flg@vhojd.skovde.se>
Subject: Re: joinig 2 files
Message-Id: <01bc5497$c9a59c40$e20f10c2@odens.di.vhojd.skovde.se>

Marco Giardini <marco@tecnogi.mdnet.it> wrote in article
<336542D0.289BC6E0@tecnogi.mdnet.it>...
> I have 2 differnet files with the same number of rows and I want to
> join them togheter iin order to get only file that will have for each
> row the "sum" of the rows of the single file.

> the result i need is something like:
> file RESULT
> a 1
> b 2
> c 3
> d 4
> e 5

Hi!

Here is one way of doing it. I simply read from both file and
print the lines out together. You can of course print the result
to another file, or store it in a list or something if you want to.

#!/usr/bin/perl -w
#
$file1 = shift;  # Get first filename from commandline
$file2 = shift;  # Get second filename

open(FIL1, "<$file1") or die("Error opening $file1: $!\n");
open(FIL2, "<$file2") or die("Error opening $file2: $!\n");

# Start reading until we hit EOF from one of the files
while(($line1 = <FIL1>) && ($line2 = <FIL2>)) {
   chomp($line1); # remove newline
   chomp($line2); #         ""
   print "$line1 $line2\n";  # Print the strings
}

close FIL1;
close FIL2;
__END__

Hope this helps

/Fredrik



------------------------------

Date: Tue, 29 Apr 1997 09:02:35 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: joinig 2 files
Message-Id: <r1v4k5.9e4.ln@localhost>

Marco Giardini (marco@tecnogi.mdnet.it) wrote:
: I have 2 differnet files with the same number of rows and I want to
: join them togheter iin order to get only file that will have for each
: row the "sum" of the rows of the single file.

: I.E.
: file ALPHA
: a
: b
: c
: d
: e

: file BETA
: 1
: 2
: 3
: 4
: 5

: the result i need is something like:
: file RESULT
: a 1
: b 2
: c 3
: d 4
: e 5

: How can i get the combined file using Perl?


open(ALPHA, "ALPHA")   || die "could not open ALPHA  $!";
open(BETA, "BETA")     || die "could not open BETA  $!";
open(RESULT, ">RESULT" || die "could not open RESULT  $!";

while ($alpha = <ALPHA>) {         # get a line from alpha
   chomp($alpha);                  # remove newline from alpha
   $beta = <BETA>;                 # get a line from beta
   print RESULT "$alpha $beta"     # write 'em to result
}
close(ALPHA);
close(BETA);
close(RESULT);


: Thanks to everybody will give ma an help mailing me to
: marco@tecnogi.com or giardini@telnetwork.it

: Thanks again

: Marco
: -- 
: //////////////////////////////////////////////////////////////////////
:  It's better to lose a few beans from your bag that have no bag for your
: beans    
:     OOoooo......DREAMING ........
:  
:       `:::'                  .......  ......
:        :::  *                  `::.    ::'
:        ::: .::  .:.::.  .:: .::  `::. :'
:        :::  ::   ::  ::  ::  ::    :::.
:        ::: .::. .::  ::.  `::::. .:'  ::.
:       .:::.....................::'   .::::..
:  
:  Marco Giardini
:  marco@tecnogi.com
:  http://www.tecnogi.com/marco/
: /////////////////////////////////////////////////////////////////////


Your signature is excessive.


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


------------------------------

Date: 29 Apr 1997 15:33:49 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: joinig 2 files
Message-Id: <5k54ct$krs@lyra.csx.cam.ac.uk>


Fredrik Lindberg <flg@vhojd.skovde.se> wrote:
>while(($line1 = <FIL1>) && ($line2 = <FIL2>)) {

 while(defined ($line1 = <FIL1>) && defined ($line2 = <FIL2>)) {

would be safer and better practice.


Mike Guy


------------------------------

Date: Tue, 29 Apr 1997 16:22:22 GMT
From: hbaker@netcom.com (Henry Baker)
Subject: Re: List Syntax vs. Conventional Syntax (was Re: Ousterhout...)
Message-Id: <hbaker-2904970822220001@10.0.2.1>

In article <5k3qn4$p43@roar.cs.utexas.edu>, wilson@cs.utexas.edu (Paul
Wilson) wrote:

> (Eval should be used
> very carefully and sparingly in normal apps, because it is
> slow and tends to confuse compilers so that they can't
> optimize *other* code as well.  You can usually get the
> effect you want straightforwardly with lambda (for the non
> Lispers, think of it as "make-procedure"), and it'll be
> tons faster.

Of course, you can always do 'apply' of 'compile' of consed stuff instead
of 'eval'.  This 'JIT' compilation solves the speed problem.  (You _do_ have a
builtin compiler, don't you?)


------------------------------

Date: 29 Apr 1997 11:37:00 -0500
From: wilson@cs.utexas.edu (Paul Wilson)
Subject: Re: List Syntax vs. Conventional Syntax (was Re: Ousterhout...)
Message-Id: <5k583c$rrm@roar.cs.utexas.edu>

In article <hbaker-2904970822220001@10.0.2.1>,
Henry Baker <hbaker@netcom.com> wrote:
>In article <5k3qn4$p43@roar.cs.utexas.edu>, wilson@cs.utexas.edu (Paul
>Wilson) wrote:
>
>> (Eval should be used
>> very carefully and sparingly in normal apps, because it is
>> slow and tends to confuse compilers so that they can't
>> optimize *other* code as well.  You can usually get the
>> effect you want straightforwardly with lambda (for the non
>> Lispers, think of it as "make-procedure"), and it'll be
>> tons faster.
>
>Of course, you can always do 'apply' of 'compile' of consed stuff instead
>of 'eval'. 

Right.  (For example, in RScheme and some other schemes, this is how
eval is actually implemented---it just compiles what you give it,
and runs the resulting code immediately.)

>This 'JIT' compilation solves the speed problem.  

Not the one I was talking about.  A lot of naive users don't understand
that eval is a weird thing to do, and may be rather slow because it
involves either interpretation  or compilation.  In contrast, lambda
is generally quite fast, because it doesn't actually create  new
code, just a new closure to pair code with an environment.

In many scripting apps, this doesn't matter much, but when you start
writing whole programs in a language, it's good to be able to avoid
eval.  Using lambda and procedure calling (or macros if necessary)
is usually cleaner and easier anyway.

>(You _do_ have a builtin compiler, don't you?)

Sure.  (We don't have an interpreter in the usual sense.)

-- 
| Paul R. Wilson, Comp. Sci. Dept., U of Texas @ Austin (wilson@cs.utexas.edu)
| Papers on memory allocators, garbage collection, memory hierarchies,
| persistence and  Scheme interpreters and compilers available via ftp from 
| ftp.cs.utexas.edu, in pub/garbage (or http://www.cs.utexas.edu/users/wilson/)      


------------------------------

Date: 29 Apr 1997 12:35:34 GMT
From: periat@ens.ascom.ch (Periat Henri)
Subject: Re: MIF File Generator
Message-Id: <5k4pum$gpq@ascomax.hasler.ascom.ch>

A long time ago i wrote a perl modul, which can read MIF files in to
perl data structures and generate a MIF file from this structures
again. It was my first time with complex data structures in perl and 
took me about two month to write it. Now it needs to be extended to
make it able to read also FrameMaker 5 MIF files.
I did the mork for my employer, so if some budy is interested to get it
i need to check if i can give it a way.

Regards
Henri

-- 
-----------------------------------------------------------------------
Henri Periat				Phone:	0041 32 624 35 78
Ascom Business Systems AG		E-Mail:	periat@ens.ascom.ch
Dep. 3578				Fax:	0041 32 624 31 56
Ziegelmattstr. 1
CH-4503 Solothurn
Switzerland
-----------------------------------------------------------------------




------------------------------

Date: Tue, 29 Apr 1997 15:07:14 GMT
From: stephen farrell <stephen+usenet@farrell.org>
Subject: nds newNDS = nestedDataStructure->copy()?
Message-Id: <8767x5lvfh.fsf@phaedrus.uchicago.edu>


so how do i copy a nested data structure?  e.g., i have

	$x = [ { a => b, c => d} ];

and i want to make a new copy, manipulate it, and not affect $x.
obviously i'm interested in a clean, general purpose way of doing this
(i know i can just iterate through the thing and make a new one like
it... but is writing a function to this the only way?).

incidentally, 

	$y = [ @$x ];

doesn't work, presumably because it only makes a copy of the "first
level" of the nested data structure, but its contents are still
references. 

thanks much, steve farrell


------------------------------

Date: Tue, 29 Apr 1997 14:12:28 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Network Programming and Sockets
Message-Id: <ebohlmanE9EKss.3yB@netcom.com>


Luca Passani (lpa@sysdeco.no) wrote:

: 1) wouldn't it be possible for Perl to offer some higher-level interface
: to TCP/IP (even Socket.pm requires a rather deep understanding of 
: C/TCP/IP stuff)

Have you been over to CPAN lately?  There are plenty of modules there 
that provide simplified interfaces to the most common protocols run over 
TCP/IP.  It makes a lot of sense for that sort of stuff to be handled in 
modules rather than the core language, since there are plenty of Perl 
applications that have nothing to do with TCP/IP.



------------------------------

Date: 29 Apr 1997 11:15:36 -0400
From: Rajappa Iyer <rsi@lucent.com>
Subject: Re: Notice to antispammers
Message-Id: <xnyvi55hnc7.fsf@placebo.hr.lucent.com>

Tom Christiansen <tchrist@mox.perl.com> writes:

> In comp.lang.perl.misc, 
>     stanley@skyking.OCE.ORST.EDU (John Stanley) writes:
> :If you are really talking about mail messages, go ahead. It's rude to
> :put bogus addresses in mail. But, if you are really talking about 
> :USENET messages, then think about it a minute. USENET isn't mail. 
> 
> As I read the specs, a bogus From: line requires a real Sender:
> line.  You aren't supposed spoof.

Wrong! The Sender: line is inserted by the transport when it doesn't
like the look of the From: line. It has nothing to do with the
validity of the From: line... to illustrate, my From: line is
perfectly legal---a valid mailbox. Yet, there is a Sender: line which
is different from the From: line. This includes information about the
host from which I posted the article and does *NOT* necessarily
represent a valid mail address.

> :What you will be doing is the spammer's work for them, handing them a
> :list of valid addresses on a platter.
> 
> Yes, that's right.  I intend to do that.  Stop foisting the spam problem
> on others -- it needs to be addressed at the legislative level.  By avoiding
> it, you merely delay fixing the problem.    

Stop foisting *YOUR* problem---i.e. the need to send a `courtesy' copy
of your posts---onto others. My mailbox is *MY* (or my employer's)
property... not yours. If I don't wish to receive mail from you (or
anyone else) that's *MY* business... not *YOURS*! If you're bothered
by people mungeing their From: headers, take the time to understand
why: people don't like to deal with junk mail and maybe they don't
care to have `courtesy' copies of posted articles mailed to them. If
the fact that people don't like junk mail bothers you, go after the
root cause... the spammers who send all the junk mail.

Whatever you do, stop acting like you own comp.lang.perl.misc or the
mailboxes of people who post there. No matter how useful your
contributions are, you do not.
-- 
Rajappa Iyer <rsi@lucent.com>	   #include <std_disclaimer.h>
	They also surf who only stand on the waves.


------------------------------

Date: 29 Apr 1997 16:33:51 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Notice to antispammers
Message-Id: <5k57tf$bg1$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, rsi@lucent.com writes:
:Whatever you do, stop acting like you own comp.lang.perl.misc or the
:mailboxes of people who post there. No matter how useful your
:contributions are, you do not.

Bye.

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com

    Just don't create a file called -rf.  :-)
            --Larry Wall in <11393@jpl-devvax.JPL.NASA.GOV>


------------------------------

Date: 29 Apr 1997 11:20:29 -0500
From: wilson@cs.utexas.edu (Paul Wilson)
Subject: Re: Object IDs are good ( was: Object IDs are bad )
Message-Id: <5k574d$rln@roar.cs.utexas.edu>

In article <pog1wbcuqw.fsf@dogbert.cs.chalmers.se>,
Lennart Augustsson  <augustss@cs.chalmers.se> wrote:
>
>wilson@cs.utexas.edu (Paul Wilson) writes:
>> Matthias Blume <blume@mocha.cs.princeton.edu> wrote:
>> >   - Things that _actually_ look the same in each and every
>> >     respect_are_ the same.
>> 
>> No.  This is bad philosopy.  Things that are indistinguishable
>> given a certain subjective point of view may become distinguishable
>> when you learn more about them.
>Do you have a problem with reading? :-)

I don't think so.  But would I necessarily know if I did?

>Matthias Blume wrote "in each and every respect"; how can something
>look the same "in each and every respect" and then be "distinguishable
>when you learn more about them"?  If objects can be distinguished when
>you learn more about them then they were not equal in each and every
>respect.

I think this has been answered sufficiently by other posters (correct
me if I'm wrong), but I'm not sure exactly what you mean here, and
how it relates to programming languages.

"learn more about" doesn't necessarily mean "mutate".  Depending on
how I choose to map the application semantics onto the language
semantics, I may or may not modify language-level objects when
I learn more about the conceptual objects they represent.  Often,
I just make a notation in a table off to the side, rather than
modifying the object itself.  The objects may in fact be immutable.
Nonetheless, I may want to distinguish between two immutable objects
that are *local* equal in every respect except object identity---so
that I *can* have different information recorded about them "off
to the side".

I'm not sure why people think this is an easy issue with a single
answer.  There's no good, fixed mapping from application-level
concepts to langauge-level objects, so whatever the default in your
language is w.r.t. object identity, you'll often have to fake something
else.  Which is the default is less interesting than the fact that no
language can solve all the problems for you automatically.  Matthias
likes ML's default, which is an entirely reasonable attitude.  I like
Scheme and Smalltalk and C's default, which lets me either use or
ignore object identity without any special hacking of tags, etc.
It's a handy kind of polymorphism.

-- 
| Paul R. Wilson, Comp. Sci. Dept., U of Texas @ Austin (wilson@cs.utexas.edu)
| Papers on memory allocators, garbage collection, memory hierarchies,
| persistence and  Scheme interpreters and compilers available via ftp from 
| ftp.cs.utexas.edu, in pub/garbage (or http://www.cs.utexas.edu/users/wilson/)      


------------------------------

Date: 29 Apr 1997 13:58:55 GMT
From: fellowsd@cs.man.ac.uk (Donal K. Fellows)
Subject: Re: Ousterhout and Tcl lost the plot with latest paper
Message-Id: <5k4uqv$8a@m1.cs.man.ac.uk>

In article <3364DD2D.86195F2@physik.tu-muenchen.de>,
Christopher Eltschka  <celtschk@physik.tu-muenchen.de> wrote:
[ ... ]
> BTW, what would the following possible C++ interface for menus look
> like in tcl/tk?
> 
> MenuBar MainMenu
> (
>   Menu("Main")
>     .Item
>       (
>         Menu("~File")
>           .Item(Command("~Open", cmOpenFile), helpOpen)
>           .Item(Command("~Save", cmSaveFile), helpSave)
>           .Item(Command("~Save ~As", cmSaveFileAs), helpSaveAs)
>           .Separator()
>           .Item(Switch("Make ~Backup", BackupFlag), helpBackup)
>       )
>     .Item
>       (
>         Menu("~Search")
>           .Item(Command("~Find"), cmFind), helpFind)
>           .Item(Command("~Replace"), cmReplace), helpReplace)
>           .Separator()
>           .Item(Command("Find ~Again"), cmFindAgain), helpFindAgain)
>       )
> )
> 
> Here cmXXX specifies the Action (or Message, as usual in GUIs),
> while helpXXX specifies an optional help context for online help.

Well, using a (modified) version of some code that I've used in my own
apps (and which is available on my website), I get something like this:

    dkfMenu .mbar hvar {
    	button -text "Main" -contents {
    	    cascade -label "~File" -menu {
    		command -label "~Open" -command cmOpenFile -help helpOpen
    		command -label "~Save" -command cmSaveFile -help helpSave
    		command -label "Save ~As" -command cmSaveFileAs \
    			-help helpSaveAs
    		separator
    		checkbutton -label "Make ~Backup" -variable BackupFlag \
    			-help helpBackup
    	    }
    	    cascade -label "~Search" -menu {
    		command -label "~Find" -command cmFind -help helpFind \
			-accel <Control-s>
    		command -label "~Replace" -command cmReplace \
    			-help helpReplace -accel <Meta-percent>
    		separator
    		command -label "Find ~Again" -command cmFindAgain \
    			-help helpFindAgain -accel <F3>
    	    }
    	}
    }

Modifications from my published code are as follows:
  1) Excessive curlies are removed (a line or two as Tcl has built-in
     primitives to help with this trick)
  2) "~" processing to extract underline positions (totally trivial in
     Tcl)
  3) Help is modified to redirect through a message catalogue - not
     unreasonable in the circumstances... :^)

Points to note:
  1) I've specified my keyboard accelerators as part of the menu
     definition.  That causes a user-readable string to be attached to
     the menu entry and an appropriate keyboard binding to be made
     within that window.
  2) There are a lot of options that I've not specified in there.
     Having a menu item with a picture on it instead of a text label
     does not increase the complexity of the code.
  3) I wrote the original code nearly two years ago as one of my first
     little projects in Tcl.  It is _not_ even close to idiomatic IMHO

As you can see, Tcl can easily see everything that you did (without
difficulty I might add) and raise proper keyword-based arguments that
make maintenance much easier while allowing for a much greater range
of behaviour.  Indeed, this is an advantage shared with languages like
Perl, Lisp and many others (that should placate Erik a little... :^)
and it is the design of C/C++ which is a stumbling block here.
Admittedly, this can be kludged around (either using the inefficient
mechanism used above or by using a variable number of arguments, which
unfortunately compromises anything even remotely approximating to type
safety)

Donal.
--
Donal K. Fellows   http://r8h.cs.man.ac.uk:8000/  (SAY NO TO COMMERCIAL SPAMS!)
(work) fellowsd@cs.man.ac.uk     Dept. Comp. Sci, Univ. Manchester, U.K.
 |     donal@ugglan.demon.co.uk  6,Randall Place, Heaton, Bradford, U.K. (home)
 +-> ++44-161-275-6137  Send correspondence to my office  ++44-1274-401017 <-+


------------------------------

Date: Tue, 29 Apr 1997 11:22:58 -0500
From: Harold Howe <hhowe@trgnet.com>
Subject: Perl as a script interpreter in win32 app
Message-Id: <33662062.3442@trgnet.com>

Howdy folks,

My company is bidding on a win32 project. The program's job is to test
hardware in the PC, which could require drivers and all sorts of other
stuff. The user interface for the program doesn't need to be fancy, but
we do need to write a standard windows UI with menus, buttons and all
that other junk (ie not a console mode program).

Our program needs to provide some scripting ability. This allows users
of the program to write their own custom hardware test. I would like to
know if Perl is a practical alternative. I know that we could write
scripts in perl and execute them OK. My biggest concern is how to
communicate from the script back to the main EXE. 

The hardware test routines will lie in the gui EXE somewhere. Is it
possible for a Perl script to call a function from the main program? Can
Perl scripts run in win32 call the win32 API functions? I guess what I
need is a way to export functions from the EXE to the perl script. Is
this even possible?

To make a long story short, can a perl script call functions in a
standard windows dll or exe? If not, could a perl script send messages
to a windows program? If not, how would I communicate from the script
back to the main EXE?

Thanks for any advice you might have.

Harold Howe
hhowe@trgnet.com


------------------------------

Date: 29 Apr 1997 13:37:26 GMT
From: Ronald.J.Kimball@dartmouth.edu (Chipmunk)
Subject: Re: Perl auto-replier
Message-Id: <5k4tim$k7r$2@dartvax.dartmouth.edu>

In article <5k26bn$jnu$1@csnews.cs.colorado.edu>
Tom Christiansen <tchrist@mox.perl.com> writes:

> In comp.lang.perl.misc, Ronald.J.Kimball@dartmouth.edu (Chipmunk) writes:
> :Something which scans the posts to comp.lang.perl.misc and
> :automatically generates replies to posters' questions.  Replies such
> :as:
> :
> :"You moron, look at the perlxxx man pages."
> :"You moron, that's not a Perl question, try comp.xxx.xxx.xxx."
> :"You moron."
> :
> :Such a script would definitely save certain posters to this newsgroup a
> :lot of time and effort spent replying to questions.  (Not mentioning
> :any names.)
> 
> I have a much better answer: remove all Perl documentation.  It's obvious
> that 90% of the posters don't grep it before posting.  
> 
> This is not a newsgroup full of babysitters dedicated to reading children
> stories out of the perl manpages at night before they go to sleep.
> Nor is it a place to whine your way into limitless free consulting help.
> It isn't even the place for those who refuse to follow netitquette and
> find the right newsgroup before asking how to tie their shoes or walk
> their dog (or program in bash).  This isn't, in fact, just a simple
> q&a forum, although it's been a long time since I've seen any threads
> beyond that.
> 
> When's the last time you saw a posting by Larry?  Ever wonder about that?

Disclaimer: I've only been on comp.lang.perl.misc for about 2 weeks.
In that time, I've seen an alarming number (to me anyway) of rude and
condescending responses to naive questions.  I do not object to
directing people to the FAQs, the man pages, or other newsgroups.  What
I object to is doing so in such an arrogant way.

While it would be nice to stop the posting of questions that are best
answered by the documentation or in other newsgroups, doing so is an
impossible task.  On the other hand, the rude responses are posted by a
handful of rational, intelligent people.  Is it necessary or
appropriate for these repliers to discard netiquette in their responses
becausethe original poster is clueless or lazy?  I'd just like them to
consider that.

Obviously, since I've only been here for two weeks, I've only seen two
weeks worth of users posting these silly questions, while the people
replying to them have been here for months, years, I don't know. 
Perhaps when I've been on here for a significant amount of time, I'll
turn nasty too.  I hope not, but if I do, I'll owe you all an apology.

Until that happens, though, I'm still going to argue against being so
openly rude to these posters.

Chipmunk

P.S.  I'm afraid I've never seen a posting by Larry - that two week
thing, again.


------------------------------

Date: 29 Apr 1997 16:40:42 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Perl auto-replier
Message-Id: <5k58aa$bg1$2@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    Ronald.J.Kimball@dartmouth.edu (Chipmunk) writes:
:Disclaimer: I've only been on comp.lang.perl.misc for about 2 weeks.
:In that time, I've seen an alarming number (to me anyway) of rude and
:condescending responses to naive questions.  I do not object to
:directing people to the FAQs, the man pages, or other newsgroups.  What
:I object to is doing so in such an arrogant way.

When >90% of anything you read is dreck, you tire of suffering
fools gladly.  This newsgroup is no longer worth wasting time
reading, or contributing to.  

:P.S.  I'm afraid I've never seen a posting by Larry - that two week
:thing, again.

It got to be too much for him.  When something's too much for him,
he bails.  I, on the other hand, got pissy and tried to stick with it.
I was wrong, twice, but I'm through with those mistakes.  I go now to
join Larry in that great Perl heaven far removed from Usenet.

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com

    "Oh, I'm totally outrageous--I just never seem to inspire any outrage.  :-)"
    	--Larry Wall


------------------------------

Date: Tue, 29 Apr 1997 10:52:06 -0600
From: RyanO@AccessComms.co.uk
Subject: Perl database search and page generation
Message-Id: <862328575.32566@dejanews.com>

Hi,

I wonder if anyone here can help. I'm after a Perl script to generate Web
pages on the fly from a flat file. The file is a standard comma separated
variable format and may look like the following:

FirstName,Surname,Imagelink1,Imagelink2,Detailtext,Address,location
Jane,Smith,images/junk1.gif,images/junk2.gif,Jane is...,addr,location

I am looking for something that will generate a page from this and
include the html for the image fields so that the two images appear and
the text is inserted afterwards.

It may need to have the strings (all personal details) delimited by
double quotes. I also need to be able to search this flat file and
display abbreviated output which will then lead to the dynamically
generated page.

I would appreciate any help on this as I am new to Perl and will be using
version 5. I'm good with C though so it should not be a problem.

Thanks in advance. Could you copy any replies to my email
RyanO@AccessComms.co.uk

Ryan

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet


------------------------------

Date: Tue, 29 Apr 1997 14:46:02 GMT
From: bkhilton@netcom.com (Brand and Karina Hilton)
Subject: Re: Pointing a Filehandle _AT_ a Subroutine
Message-Id: <bkhiltonE9EMCq.LK0@netcom.com>

In article <Pine.SOL.3.95.970428214949.18696A-100000@tempest.rs.itd.umich.edu>,
automan  <automan@umich.edu> wrote:
>
>
>This may be a newbie question, so forgive...
>
>Anyway, disclaimer aside, What I'd like to do is to create a filehandle to
>a pseudo-pipe that is really a subroutine internal to my script.
>
>In otherwords, I could write a little perl program to print files to a
>local printer via an Ascii command to the terminal like so:
>
>	print "\033\133\065\151";		#Printer on
>	foreach (<>) {print;}			#Send file to printer
>	print "\014";				#Form Feed
>	print "\033\133\064\151";		#Printer off
>
>and then make it +x.  Then I could open a pipe to it by calling 
>	open FILEHANDLE, "| printcommand";

Here's the first hint.  What happens here is your program forks and 
execs printcommand, with everything going into FILEHANDLE from the 
parent showing up in STDIN in printcommand.  Hey, wait a minute!  That's
interprocess communication!  A quick look at the perlipc man page,
a few mods to the example under Safe Pipe Opens, and voila!

    #!/usr/local/bin/perl

    use English;
    my $sleep_count = 0;

    sub printcommand {
        print "\033\133\065\151";               #Printer on
        while (<STDIN>) {
            print; # child's STDIN is parent's KID
        }
        print "\014";                           #Form Feed
        print "\033\133\064\151";               #Printer off
    }

    do {
        $pid = open(KID_TO_WRITE, "|-");
        unless (defined $pid) {
            warn "cannot fork: $!";
            die "bailing out" if $sleep_count++ > 6;
            sleep 10;
        }
    } until defined $pid;

    if ($pid) {  # parent
        @some_data = ("this is a test.\n", "lets see how it goes.\n");
        print KID_TO_WRITE @some_data;
        close(KID_TO_WRITE) || warn "kid exited $?";
    } else {     # child
        printcommand;
        exit;  # don't forget this
    }


>Please e-mail me with responses.  

Ok.

>Thanks!
>Tobias
>
>***************************************************************************
>*  Tobias Zimmerman                    |     E-Mail: automan@umich.edu    *
>*  University of Michigan              |     Phone: 313-763-0193          *
>*  Psychology Computer Support Team    |     1223 E. Engineering Building *
>***************************************************************************
>

Brand


------------------------------

Date: Tue, 29 Apr 1997 18:33:35 +0100
From: Douglas Seay <seay@absyss.fr>
Subject: Re: pre-RFD: comp.lang.perl.{data-structure,inter-process,porters,regex}
Message-Id: <336630EF.62FB2A5B@absyss.fr>


Evan Kirshenbaum wrote:
> How about if we create clp.cgi and clp.www, but we make them
> robomoderated groups, where the moderation policy is to reject all
> postings with a note pointing to ciwa.cgi?
> 
> They'll be a relatively low-volume groups, so nobody should mind, and
> it might cut down on the traffic here.
> 
> [Tongue only slightly in cheek.]

Aye!

Is it possible to make one usenet group an alias of another?  Just make
this new c.l.p.www be a "symbolic reference" to c.i.w.a.cgi might do the
trick.  I've never heard of such a thing, so I doubt if it is already in
a RFC.


Calle Dybedahl wrote:
	<snip of my post>
> 
> Agreed, but perhaps comp.lang.perl.cgi would be a better name? Not only is
> it more obvious, it also comes before .misc when sorted alphabetically.

Another good idea, but I'm afraid that many who post things claiming
that perl is broken because it works from the command line, but not from
the web server don't know what CGI is.  Although "www" comes after
"misc", it is sure to be known by (nearly) everyone.


More food for thought: how many "clueless web programmers" will
cross-post to both the new group and good ol' misc?  Or even worse, send
duplicate copies?  If this percentage is high, we're just wasting our
time dreaming about stopping these boneheads.

- doug


------------------------------

Date: 29 Apr 1997 13:20:49 GMT
From: Ronald.J.Kimball@dartmouth.edu (Chipmunk)
Subject: Re: quote of the day?
Message-Id: <5k4sjh$k7r$1@dartvax.dartmouth.edu>

In article <33642B97.2DB2@fatdays.com>
"Brian H. Marston" <webguy@fatdays.com> writes:

> sub DateAndTime {
>         $ENV{"TZ"} = "CST6CDT";
>         $thismonth = (January, February, March, April, May, June, July,
>                       August, September, October, November,
>                       December)[(localtime)[4]];
>         $thisday   = (localtime)[3];
>         $thisyear  = (localtime)[5];
>         $hour      = (localtime)[2] % 12;
>         $minutes   = (localtime)[1];
> 
>         if ((localtime)[2] >= 12) {
>                 $AMorPM = "PM";
>         }
>         else {
>         $AMorPM = "AM";
>         }
> 
>         if ($hour == 0) {
>                 $hour = 12;
>         }
> 
>         if ($minutes <= 9) {
>                 $minutes = "0$minutes";
>         }
> }

You're calling localtime six times, when you could call it just once.

sub DateAndTime {
   $ENV{"TZ"} = "CST6CDT";
   ($minutes, $hour, $thisday, $thismonth, $thisyear) = localtime;

   $thismonth = (January, February, March, April, May, June, July,
                 August, September, October, November,
                 December)[$thismonth];

   if ($hour >= 12) {
       $AMorPM = "PM";
   } else {
       $AMorPM = "AM";
   }

   $hour = $hour % 12;
   if ($hour == 0) {
       $hour = 12;
   }

   if ($minutes <= 9) {
       $minutes = "0$minutes";
   }
}

That shouldn't change how the code works, but it should make it more
efficient.

Chipmunk


------------------------------

Date: Tue, 29 Apr 1997 17:29:05 +0200
From: Thomas Schuber <tschuber@syskonnect.de>
Subject: SQL database access with Perl
Message-Id: <336613C1.2D47@syskonnect.de>

Hello,

I want access a SQL database on a SQL 6.5 Server (NT4.0) with Perl.
Is it possible to access a SQL database with Perl?
Is it possible to send SQL commands from Perl to the database?

Any help would be greatly appreciated.

Thanks,
Thomas Schuber


------------------------------

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 391
*************************************

home help back first fref pref prev next nref lref last post