[6955] in Perl-Users-Digest
Perl-Users Digest, Issue: 580 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jun 6 11:20:05 1997
Date: Fri, 6 Jun 97 08:00:40 -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 Fri, 6 Jun 1997 Volume: 8 Number: 580
Today's topics:
Re: 'rsh' questions (Kerry Schwab)
[AIX 4.1.4] Where is syscall.h file needed by Hostname. (DUTKA-MALEN Ivan)
Re: Applets in Perl (Chris Nandor)
Re: attaching a file to an email using sendmail <news@alf.impaq.com.pl>
Re: call perl script from c program? (Bob Wilkinson)
Re: EBCDIC and Perl (Dominic Dunlop)
Get remote telnet hostname ? <Iain.Bisset@ubs.com>
Re: Help : Error running a script from a script <rootbeer@teleport.com>
Help: (Win32, build 306), connect won't work with dial <jbokma@caiw.nl>
Re: Help: (Win32, build 306), connect won't work with <jbokma@caiw.nl>
Re: HELP: Where is this anti-rounding error from?!! (Tad McClellan)
Re: How can I set up this server to run perl faster?... (Scott M. Hinnrichs)
Re: HTML Output from Perl (Tung-chiang Yang)
Re: looping question <rootbeer@teleport.com>
Package question <wood@ziplink.net>
Perl Camel Book (Thee Boon Hoo)
Re: Perl Camel Book (Chris Nandor)
Re: perl simulated 'enter' key <nospam-djohnson@uu.net-nospam>
Re : Search Engine (Ccadic)
Re: Rounding off numbers (Precision Farming Project)
Shared DBM files (Gene Johannsen)
Re: Sockets in MacPerl? (Paul J. Schinder)
Re: String Compare Problem (Greg Zevin)
Tricky Syntax Question (Helmut Jarausch)
TRYITOUT: Global HD <terma@post1.tele.dk>
Re: What does "UNIX" stand for.. (Christopher Thompson)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 6 Jun 1997 06:07:05 -0600
From: kschwab@nyx10.cs.du.edu (Kerry Schwab)
Subject: Re: 'rsh' questions
Message-Id: <5n8uh9$6nb@nyx10.cs.du.edu>
In article <01bc7127$5330c6a0$774698c2@prss3wlk.prestel.co.uk>,
John Bell <JohnBell@johnb.prestel.co.uk> wrote:
>Dear All,
>
>I've two questions which are inter-related and which are stumping me. I
>want to be able to run a Perl script which does the following running on a
>sysV UNIX box:
>
>1) tests to see whether a given file exists on a remote machine (on the
>LAN),
>2) move some files around on the remote machine *as root*, and
>3) copies a file from a local machine to this remote machine, *as root*
>(i.e. it requires the person invoking the script to supply a password for
>root.)
>
>Problem 1:
>
>I'm trying to test to see whether a given file exists on a remote machine
>by doing something like this:
>
>system('rsh','root\@$machine','test -f $file');
>print "it exists" if (($? & 255) == 0);
>
>However, the value returned and put in $? is the return status of 'rsh' and
>not of 'test' whose return status I actually want to find out. In the code
>above, as long as 'rsh' can execute 'test', $? is always 0. (I know I can
>do the following to find out if the file exists, but it's tacky:
This is a pretty common question, and is in the comp.unix.* FAQ.
(they suggest a shell script called "ersh")
"rsh"'s return value indicates whether or not rsh was able to do it's
work (i.e connecting to the other end and passing the command)
Most workarounds are gross, here's a typical workaround:
This is okay if the remote account isn't a csh family shell.
(If it is, you can muck about with /bin/sh -c and quoting hell.
$retval=`rsh $machine 'somecommand >>/dev/null 2>&1;echo \$?'`
>
>system('rsh', 'root\@$machine','ls $file > $file.tmp');
>system('rcp','$machine:$file.tmp','tmp');
>print "it exists" if -s tmp;
>
>)
>
>Problem 2:
>
>If I do the equivalent to 'su - root' in the script, then a new shell is
>invoked, and the remaining script 'disappears' until ^D is hit. I would
>like to be able to 'su root', run some commands and then 'su' to the
>existing user id, but can't seem to do this. The only other alternative I
>can see (with my very limited knowledge) is to do something like:
>
>system('su', '-', 'root', 'rsh root\@$machine <some command>');
>
>but this would require the user giving a password for root for every
>command executed on the remote machine.
>
>Any help would be greatly appreciated,
>
>John Bell
You don't need to be root on the local machine to have rsh call a program
as root on the other machine. Have a look at the rsh man page. (specifically
the -l option) Also read up on the .rhosts file format.
Or look into "super" or "sudo" or some other wrapper program that tries to
do this sort of thing (somewhat) securely.
This can, of course, be dangerous. If you are going to put scripts into
production that use a trusted host relationship and run things as root, you
should invest some time in learning the pitfalls.
--
Kerry
------------------------------
Date: 06 Jun 1997 15:29:49 +0200
From: dutka@rantanplan.dr.gdf.fr (DUTKA-MALEN Ivan)
Subject: [AIX 4.1.4] Where is syscall.h file needed by Hostname.pm ?
Message-Id: <xll7mg7n9ki.fsf@rantanplan.dr.gdf.fr>
I've successfully compiled and installed PERL 5.004 on my IBM machine
(AIX 4.1.4) but when I try to use the Sys::Syslog package, it claims
that it needs the 'syslog.ph' and 'sys/syslog.h' files. So I created
them using the h2ph utility.
But now Sys::Syslog calls Sys::Hostname, and this latter claims the
'syscall.ph' file. And I have no 'syscall.h' file in /usr/include/...
so I wonder where I can find it.
Can anybody help me ? Any help appreciated.
Thanks in advance.
--Ivan
--
------------------------------------------------------------------------------
Ivan DUTKA-MALEN
dutka@dr.gdf.fr
------------------------------
Date: Fri, 06 Jun 1997 09:07:51 -0400
From: pudge@pobox.com (Chris Nandor)
Subject: Re: Applets in Perl
Message-Id: <pudge-ya02408000R0606970907510001@news.idt.net>
In article <33972523.2EA1@unsu.com>, Arthur Merar <amerar@unsu.com> wrote:
#Hello, I am writing my first PERL script for my homepage. The script
#will accept some data from the user and pass that data to an applet
#which will run.
#
#Can I execute an applet from within a Perl script? If so, how do I do
#this?
1. You have not given enough information for anybody to solve your
problem. What kind of applet? In what environment?
2. This is not a Perl question, it sounds like a CGI question. See
comp.infosystems.www.authoring.cgi. The answer would be the same
regardless of what type of language (Perl, shell, C, etc.) you were using.
Please ALWAYS read the newsgroup FAQ before posting.
--
Chris Nandor pudge@pobox.com http://pudge.net/
%PGPKey=('B76E72AD',[1024,'08 24 09 0B CE 73 CA 10 1F F7 7F 13 81 80 B6 B6'])
#=============================================================================
stab_val(stab)->str_nok = 1; /* what a wonderful hack! */
--Larry Wall in stab.c from the perl source code
#=============================================================================
------------------------------
Date: Fri, 06 Jun 1997 10:17:54 +0200
From: Andrew Filip <news@alf.impaq.com.pl>
To: alastair@redboxad.demon.co.uk
Subject: Re: attaching a file to an email using sendmail
Message-Id: <3397C7B2.D87937D2@alf.impaq.com.pl>
THERE IS A LIVE BEHIND PERL
alastair brown wrote:
> Does anyone know if it is possible to attach a file to an email
> message
> using the sendmail program?. If so could someone please supply an
> example of the coded needed to do this
#!/bin/sh
FILE=file
RECIPIENT=recipient
(echo Subject: FILE $FILE; echo ; uuencode $FILE $FILE) |
/usr/lib/sendmail $RECIPIENT
--
common sense is uncommon
------------------------------
Date: Fri, 06 Jun 1997 14:43:50 +0100
From: b.wilkinson@pindar.co.uk (Bob Wilkinson)
Subject: Re: call perl script from c program?
Message-Id: <b.wilkinson-0606971443500001@ip57-york.pindar.co.uk>
In article <3397000A.517A@bayfront.org>, xuc@bayfront.org wrote:
> I have two cgi programs, one written in c, another in perl. Now, the C
> program needs to use a subroutine in the perl script. Is it possible to
> call the perl script in the c program?
>
> Thanks a lot.
>
> --Chun Xu
Hello,
Type 'perldoc perlembed' at your prompt for instruction.
Bob
--
I have become death, destroyer of the worlds.
------------------------------
Date: Fri, 6 Jun 1997 10:22:10 +0200
From: domo@tcp.ip.lu (Dominic Dunlop)
Subject: Re: EBCDIC and Perl
Message-Id: <19970606102210254545@dialup19.ip.lu>
Daniel Honig <liquid@izzy.net> wrote:
> Has anyone seen or written a perl script to convert
> between EBCDIC and ASCII?
If you're running on a UNIX system (although your posting hosts suggests
that this may not be the case), piping the text in question through the
(weird, old) dd command should do the trick. See the dd man page for
more details. If you need speed, and have dd around to poke at, get
it to reveal the contents of its conversion tables by feeding it bytes
with values from 0 to 255, see what it outputs, then use the results to
build a translation table for perl's tr///. Or, whether you have a dd
binary around or not, get hold of the Linux, FreeBSD or GNU file
utilities source for the dd command, and copy the tables from there.
--
Dominic Dunlop
------------------------------
Date: Fri, 06 Jun 1997 10:34:00 +0200
From: Iain Bisset <Iain.Bisset@ubs.com>
Subject: Get remote telnet hostname ?
Message-Id: <3397CB78.72D8@ubs.com>
Hi,
Anyone know a way from Perl (or Unix shell) to figure out which box a
user has TELNETed from, in order to set up a display. The user is coming
from a VMS machine and telnetting to a Solaris box.
Thanks !
Iain Bisset
--
-------------------------------------------------------------------------
------------------------------
Date: Fri, 6 Jun 1997 07:54:34 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Daneshjoo <eermmb@engunx.unl.edu>
Subject: Re: Help : Error running a script from a script
Message-Id: <Pine.GSO.3.96.970606074442.21788L-100000@kelly.teleport.com>
On Thu, 5 Jun 1997, Daneshjoo wrote:
> I have written a script to work as an auto-reply for incoming
> email messages. It is supposed to send messages with random subjects,
> messages, signatures, and quotes.
What could you possibly want that for? :-)
> When I write the whole thing in one script, it works fine, but the
> problem is the file has to be customized for each person I want to
> reply.
That shouldn't prevent it from all being written as one file.
> But I thought if I put some parts in an individual script, which will be
> common, then try to run it through the main script, and getting the out
> put, I can minimize the script.
But you'd be maximizing the load on your system. :-) Don't start several
processes when one will do.
> But the problem is at the part where it is supposed to get the common
> values from the common script. It doesn't work.
That's a little vague. What do you mean by "It doesn't work"? Does it not
give the right answer? Does it not give any answer? Does it give you the
same value every time? Does it misspell things? Does it spend all day
watching TV and complaining that there's nothing good on? :-)
> open (Subs, "h_friends_all") || die $!;
> @SUBS = <Subs>;
> srand;
> $SUB = rand @SUBS;
>
> @STAMPS = ("stamp4","stamp5","stamp6","stamp7");
> @BODYS = ("body1","body2","body3","body4","body5","body6","body7","body8");
>
> open (Quotes, "quotes_2_friends") || die $!;
> @QUOTES = <Quotes>;
> srand;
You shouldn't use srand more than once in a script under normal
circumstances.
> $QUOTE = rand @QUOTES;
>
> srand;
> $STAMP = rand @STAMPS;
> $BODY = rand @BODYS;
Well, you've set a bunch of variables. But you've never produced any
output. Could that be the problem?
> #!/usr/local/bin/perl -w
>
> #************************
> # This is the Main script
> #************************
>
> @script = `Friends_auto_reply`;
If that's calling your other script, you can be sure that @script is
empty, since nothing was printed.
> open (MAIL, "|/usr/bin/mail -s '$SUBS[$SUB]' eermmb\@engvms ");
You should really check that that succeeded. And you never set
$SUBS[$SUB], so that's going to be empty. (Variables don't transfer from
one script to another. Maybe you wanted to write a library to be
require()d?)
> print "$STAMPS[$STAMP]\n" ;
Did you know that (if this printed anything) this wouldn't print to the
mail?
> print MAIL ("Hi Daneshjoo : \n");
> print MAIL ("$BODYS[$BODY]\n\n");
> print MAIL (" Daneshjoo \n\n");
> print MAIL ("--- ");
> print MAIL ("$QUOTES[$QUOTE]");
> close (MAIL);
I won't complain about that code. :-)
Hope this helps!
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.lightlink.com/fors/
------------------------------
Date: 5 Jun 1997 15:39:41 GMT
From: "John Bokma" <jbokma@caiw.nl>
Subject: Help: (Win32, build 306), connect won't work with dial up (unknown error 0x00002751)
Message-Id: <01bc71c6$e0358b40$da0ab2c2@tschai>
Connect gives: unknown error 0x00002751 if I use a dial up
connection.
On my local network (TCP/IP), no problems.
I am using build 306 (ActiveWare), on a Windows95 machine.
Snippet of my code: ($remote = "www.perl.com")
$port = 80;
$iaddr = inet_aton($remote);
$paddr = sockaddr_in($port, $iaddr);
$proto = getprotobyname('tcp');
unless (socket(SOCK, PF_INET, SOCK_STREAM, $proto))
{
log_error("socket error ($!) URL:$url\n");
return 0;
}
unless (connect(SOCK, $paddr))
{
log_error("connect error ($!) URL:$url\n");
return 0;
}
The error logged is:
[05/Jun/1997 17:24] connect error (Unknown Error: 0x00002751)
URL:http://www.perl.com/
Wat does the error code mean?
I already know that 0x00002741 means that the name is invalid (i.e.
can't find the IP address)
Thanks in advance,
John
--
----------------------------------------------------------------------
Need a Freelance Software Developer (MSc)? (CGI, Perl, Java, C, C++)
http://www.caiw.nl/~jbokma [Java demo's, Curriculum Vitae and
more...]
email: jbokma@caiw.nl phone: +31 10 4291827
------------------------------
Date: 5 Jun 1997 16:23:17 GMT
From: "John Bokma" <jbokma@caiw.nl>
Subject: Re: Help: (Win32, build 306), connect won't work with dial up (unknown error 0x00002751)
Message-Id: <01bc71cc$f7a0aa20$cf0ab2c2@tschai>
John Bokma <jbokma@caiw.nl> wrote in article
<01bc71c6$e0358b40$da0ab2c2@tschai>...
> Connect gives: unknown error 0x00002751 if I use a dial up
> connection.
Aaaaaaaaargh, stupid me!!! My IP uses a proxy server!!
So that's causing the problem. (Connecting to the proxy works, i.e. I
get the same response
in both my browser and my perl script).
> The error logged is:
>
> [05/Jun/1997 17:24] connect error (Unknown Error: 0x00002751)
> URL:http://www.perl.com/
>
> Wat does the error code mean?
Well, something like "your forgot to use the proxy!", but the real
question remains,
where can I find a list which explains the error codes?
John
--
----------------------------------------------------------------------
Need a Freelance Software Developer (MSc)? (CGI, Perl, Java, C, C++)
http://www.caiw.nl/~jbokma [Java demo's, Curriculum Vitae and
more...]
email: jbokma@caiw.nl phone: +31 10 4291827
------------------------------
Date: Thu, 5 Jun 1997 21:11:53 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: HELP: Where is this anti-rounding error from?!!
Message-Id: <9lr7n5.qvb.ln@localhost>
Michael Saunders (micsaund@holly.ColoState.EDU) wrote:
: Hello!
: I am working on a program (pretty simple) and I am having trouble
: with numbers getting "un-rounded." The easiest way to explain this
: is with some code/output:
[snip]
: As you can see, in the PAD10 example, the first (X) number
: is correct (975.5 + 10 = 985.5), but the second (Y) number
: has been "un-rounded" from 2152.7 to 2152.6999999999998.
[snip]
: Can someone help me fix and explain why this "un-rounding" is
: happening (particularily in such a simple program)?
It is a result of how numbers are stored in computer memory.
Has nothing to do with Perl.
Some numbers cannot be represented exactly in binary...
Some cannot be represented exactly in decimal,
such as pi, 1/3 ...
: Your help is much appreciated!
The usual "solution" is to round them off again:
printf "%6.1f\n", 2152.6999999999998;
--
Tad McClellan SGML Consulting
Tag And Document Consulting Perl programming
tadmc@flash.net
------------------------------
Date: Fri, 06 Jun 1997 03:14:59 -0700
From: smh@netserv.com (Scott M. Hinnrichs)
Subject: Re: How can I set up this server to run perl faster?...
Message-Id: <smh-0606970314590001@smh-ppc.netserv.com>
In article <3396AD2A.377B4F03@iht-ii.rwth-aachen.de>, Michael Mess
<mess@iht-ii.rwth-aachen.de> wrote:
>> #stressed$%....
>I suggest you to buy a harddisk and use this harddisk only for swapping.
>When you have swap on a separate drive or a drive which is not accessed
>often, this will increase the systems' speed.
>
>If this doesn't solve your problem, buy more RAM.
>You should have at least 64 MB Ram.
I don't know why I haven't seen this idea posted before. It seemed pretty
obvious to me. Anyway...
I first ran into this for a medical library site, they had one swap
partition, and the access time for that partition was *really* long. Even
though they had 512MB of memory they still had slow CGI performance.
The problem is that everytime a bin runs it creates an entry in swap,
whether it ever uses it or not.
You can make things run quicker by spreading your swap area over many
disks/heads/controllers, but you still have the delay in creating the swap
entry.
The simple answer is to run without swap.
Get enough memory that you never run out (limit your server processes,
etc). Then look up the detail in your OS docs to turn off swap.
On Solaris just remove the entry for swap from /etc/vfstab. You can then
reboot, or run swap -d. Watch out, if it is a real busy server wap -d
will slow things down, and take a while doing it.
I had done this before for other applications, but the effects on the WWW
server were startling. It was like a whole new machine.
Hope it works for you.
Scott
------------------------------
Date: Fri, 6 Jun 1997 07:11:37 GMT
From: tcyang@netcom.com (Tung-chiang Yang)
Subject: Re: HTML Output from Perl
Message-Id: <tcyangEBCEnD.8xJ@netcom.com>
Nope..... AFAIK, the server he/she used can configure what kinds of
codes he/she can execute as CGI. It is not that you can just put a Perl
or any executable program in the HTML directory, give it world execution
permission and it can be executed. Basically this is not a Perl question,
and he/she is advised to go to WWW, or especially the server newsgroup.
==================================
Andrew Starr (atstarr@seebelow.com) wrote:
: You want to put ptest.cgi in your public_html (or whatever directory you
: usually put your html files in) directory and then call it as
: http://www.example.com/ptest.cgi or
: http://www.example.com/gdaniell/ptest.cgi
: or something like that.
: In other cases, you can call a script from an html file by using a form
: with get or post. I suppose you could do that here too, but since there
: are no variables referred to in the script, you should just call it from
: your browser.
--
Tung-chiang Yang tcyang@netcom.com
soc.culture.taiwan, soc.culture.china (by SCC FAQ Team) FAQ's:
http://www.iglou.com/tcyang/Taiwan_faq.shtml, China_faq.shtml
------------------------------
Date: Fri, 6 Jun 1997 07:32:34 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Brian Freeze <webmaster@deltastar.nb.ca>
Subject: Re: looping question
Message-Id: <Pine.GSO.3.96.970606073111.21788I-100000@kelly.teleport.com>
On Thu, 5 Jun 1997, Brian Freeze wrote:
> I have the following piece of code which I want to have loop if
> conditions are not right. How do I end the statement in the sleep
> portion so that after it sleeps it will go back to the first part of the
> loop? ( I want it to call uptime again.)
Since you failed to indent your code, I couldn't see quickly what you
wanted. But I'm guessing that you might want either redo or next, easily
found in the docs. Hope this helps!
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.lightlink.com/fors/
------------------------------
Date: Fri, 06 Jun 1997 10:43:58 -0400
From: Bob Wood <wood@ziplink.net>
Subject: Package question
Message-Id: <3398222E.41C67EA6@ziplink.net>
Is there any convenient way to have several different packages
require/use the same module, but maintain different namespaces
for each use of the module?
Specifically: I have some code that uses the Date::Manip module
from CPAN. I've wrapped up my code as a module, and use it
in several other scripts. In one case, the script I want to
include my module in already uses Date::Manip. Unfortunately,
the script initializes Date::Manip one way, and my module wants
to initialize Date::Manip another way. What I'd really like to
do, I think, is create MyPackage::Date::Manip for use by my
module, and let the script play with Date::Manip. Is that
possible without having to maintain a second copy of Manip.pm
in my directory tree?
--
bob wood
wood@ziplink.net http://www.ziplink.net/~wood
------------------------------
Date: 6 Jun 1997 08:59:55 GMT
From: isc60289@leonis.nus.sg (Thee Boon Hoo)
Subject: Perl Camel Book
Message-Id: <5n8jib$t1u@nuscc.nus.sg>
Hi, i just started learning Perl using the Camel book which i bought
recently. The problem is : i'm not sure how to approach this book and i'm
confused.
For e.g, in the beginning chapters, some examples given touch on subjects
that have not been introduced before,(for e.g chap3 abt passing arguments
by reference to subroutine, formats, package) and unless we have previous
knowledge of Perl, i guess we have to flip thru later chapters to understand
some of the new functions being introduced. (The authors even say that if
we haven seen <these> before, jus look at the pictures first:)
Hmm...maybe my approach was wrong, or should i get another book first,
such as the llama book, to gain a strong background? Please enlighten me!:)
Btw, most of the time i really enjoy this book, and the way the authors
presented it with humor and accuracy, really a 'break' from the old and
boring programming books that i have read.:)
--
boonhoo
------------------------------
Date: Fri, 06 Jun 1997 09:13:12 -0400
From: pudge@pobox.com (Chris Nandor)
Subject: Re: Perl Camel Book
Message-Id: <pudge-ya02408000R0606970913120001@news.idt.net>
In article <5n8jib$t1u@nuscc.nus.sg>, isc60289@leonis.nus.sg (Thee Boon
Hoo) wrote:
#Hi, i just started learning Perl using the Camel book which i bought
#recently. The problem is : i'm not sure how to approach this book and i'm
#confused.
#
#For e.g, in the beginning chapters, some examples given touch on subjects
#that have not been introduced before,(for e.g chap3 abt passing arguments
#by reference to subroutine, formats, package) and unless we have previous
#knowledge of Perl, i guess we have to flip thru later chapters to understand
#some of the new functions being introduced. (The authors even say that if
#we haven seen <these> before, jus look at the pictures first:)
#
#Hmm...maybe my approach was wrong, or should i get another book first,
#such as the llama book, to gain a strong background? Please enlighten me!:)
>From the perlbook man page:
_Programming Perl, Second Edition_ is a reference work that covers
nearly all of Perl, while _Learning Perl_ is a tutorial that covers
the most frequently used subset of the language.
Reference books are not the best tutors, while tutorials usually are.
If you are "Learning Perl," as you say, you probably want to get the book
by that title, aye? ;-) The Second Edition of Learnign Perl (the llama
book) is due within the next couple months, so you might want to either
wai,or y now and upgrade later (I think you can get a discount if you own a
previos edition; see www.ora.com for details).
Have a good one,
--
Chris Nandor pudge@pobox.com http://pudge.net/
%PGPKey=('B76E72AD',[1024,'08 24 09 0B CE 73 CA 10 1F F7 7F 13 81 80 B6 B6'])
#=============================================================================
If you want your program to be readable, consider supplying the argument.
--Larry Wall in the perl man page
#=============================================================================
------------------------------
Date: Fri, 06 Jun 1997 08:58:43 -0500
From: Dale Johnson <nospam-djohnson@uu.net-nospam>
To: rferr <rferr@voicenet.com>
Subject: Re: perl simulated 'enter' key
Message-Id: <33981793.446B9B3D@uu.net-nospam>
rferr wrote:
>
> i am writing a perl script in dos. is it possible to have the script
> simulate the
> 'enter' key being hit ?
>
> thanks.
I would probably try this:
print "\r\n";
Dale
--
Dale R. Johnson, Jr. -- djohnson[at]uu.net -- http://www.drsj.com/
PGP Key: 1024/7F16D9FF Fingerprint: D52DF796E5693AA3 F500A8FCEF354154
perl -e 'foreach(`finger johnson\@doit.net`){$a=1if/^-/;print if$a}'
------------------------------
Date: 6 Jun 1997 11:42:58 GMT
From: ccadic@aol.com (Ccadic)
Subject: Re : Search Engine
Message-Id: <19970606114201.HAA18834@ladder02.news.aol.com>
Dans l'article <3396A7BD.3080@herts.ac.uk>, Coulon <X.Coulon@herts.ac.uk>
icrit :
>Sujet : Search Engine
>De : Coulon <X.Coulon@herts.ac.uk>
>Date : Thu, 05 Jun 1997 12:49:17 +0100
>
>Hello,
>
>I'm very new at PERL, and I use the compiler for Win32.
>I would like to write a script that opens a file, looks for a word and
>prints the found line. Basically, the file would be an index file, and I
>should then add some HTML tags to link to the destination.
No exactly what you need. But a wrote a similar function in my WEB search
engine .
Have a look at http://www.spiraweb.com/cadisearch/cgi.html
If you want to see a searching engine working:
http://www.spirawen.com/cadisaerch
Yours
------------------------------
Date: 6 Jun 1997 13:44:20 GMT
From: goddard@pop.srv.ualberta.ca (Precision Farming Project)
Subject: Re: Rounding off numbers
Message-Id: <5n947k$hmc$1@pulp.ucs.ualberta.ca>
In article <3396296B.36BC@cats.edu.ph>, felix@cats.edu.ph says...
>
>Is there a built-in perl function for rounding off floating point
>numbers.
If these numbers come from an experiment, and hence have an associated
variance (non-zero), then to properly round a number you need to
know what the variance is.
Multiply the variance by (N/(N-1)) (Bessel's correction) and then
take the square root to find the standard deviation. If the
most significant digit of the standard deviation starts with a "1",
the standard deviation is allowed to have 2 significant figures,
otherwise it can have 1. Round the number to the same number of
digits.
For example 12.317894287 +/- 0.017647856
The standard deviation has a leading significant digit of "1",
so we round 0.017647856 to 0.018, and then round the number
12.317894287 to the same number of digits, 12.318.
Hope this helps.
Gordon Haverland
Precision Farming Project
Alberta Agriculture
haverlan @ agric.gov.ab.ca
------------------------------
Date: 6 Jun 1997 12:58:29 GMT
From: gej@spamalot.mfg.sgi.com (Gene Johannsen)
Subject: Shared DBM files
Message-Id: <5n91hl$3lh$1@murrow.corp.sgi.com>
Hey:
I am working on a project where I'd like to use a DBM file to share
data between two perl scripts, running at the same time.
The problem is that there seems to be some sort of buffering causing
the reading script not to see the data the writing script puts in
there.
Now, I know I can close and reopen the hash in order to get the data,
but I'm wondering, is there an easier way?
gene
------------------------------
Date: Fri, 06 Jun 1997 10:10:41 -0400
From: schinder@leprss.gsfc.nasa.gov (Paul J. Schinder)
Subject: Re: Sockets in MacPerl?
Message-Id: <schinder-0606971010410001@slip166-72-171-168.pa.us.ibm.net>
In article <bloore-ya023180000506971335360001@news.bellglobal.com>,
bloore@h-plus-a.com (mARCO bLOORE) wrote:
} Has anyone succeeded in using sockets under MacPerl? The example server and
Lots of people, including me. I generally don't try to roll my own,
though, but use tools like IO::Socket that handle the messy details
properly.
After a cursory look at the code, I see two scripts that will loop and
print out whatever comes through the socket (in fact, one of them prints
back to itself; that should be fun), but I don't see where anything is
ever provided to the socket. Computers aren't great conversationalists;
you ususally give them something to say.
} client fromt the camel book fail on undefined functions. The examples
} from the html perlipc manpage that comes with MacPerl compile and run
Sounds like you're using an older version of MacPerl, since the
documentation has come in *.pod files for a while now. Upgrade. The
latest version is 5.13r2. The code below bears little resemblance to the
code in perlipc.pod. The server in the current perlipc.pod, for example,
actually prints a line to the client, and doesn't do a read loop on the
socket.
} with minor modification, and the server accepts a connection when I run
} the client, but no data seems to get sent to the client. Both sit there
} waiting.
}
} The server code is
}
} ($port) = @ARGV;
} $port = 2345 unless $port;
} use Socket;
} $sockaddr = 'S n a4 x8';
} ($name, $aliases, $proto) = getprotobyname('tcp');
} ($name, $aliases, $port) = getservbyname($port, 'tcp')
} unless $port =~ /^\d+$/;
} $this = pack($sockaddr, &AF_INET, $port, "\0\0\0\0");
} select(NS); $| = 1; select(stdout);
} socket(S, &PF_INET, &SOCK_STREAM, $proto) || die "socket: $!";
} bind(S, $this) || die "bind: $!";
} listen(S, 5) || die "connect: $!";
} select(S); $| = 1; select(stdout);
} for (;;) {
} print "Listening again\n";
} ($addr = accept(NS,S)) || die $!;
} print "accept ok\n";
} ($af,$port,$inetaddr) = unpack($sockaddr,$addr);
} @inetaddr = unpack('C4',$inetaddr);
} print "$af $port @inetaddr\n";
} while (<NS>) {
} print;
} print NS;
} }
} }
}
} and the client code is
}
} ($them,$port) = @ARGV;
} $port = 2345 unless $port;
} $them = 'ha4' unless $them;
} $SIG{'INT'} = 'dokill';
} sub dokill { kill 9,$child if $child; }
} use Socket;
} $sockaddr = 'S n a4 x8';
} $hostname = 'myDNSname';
} ($name, $aliases, $proto) = getprotobyname('tcp');
} ($name, $aliases, $port) = getservbyname($port, 'tcp')
} unless $port =~ /^\d+$/;
} ($name, $aliases, $type, $len, $thisaddr) =
} gethostbyname($hostname);
} ($name, $aliases, $type, $len, $thataddr) = gethostbyname($them);
} $this = pack($sockaddr, &AF_INET, 0, $thisaddr);
} $that = pack($sockaddr, &AF_INET, $port, $thataddr);
} socket(S, &PF_INET, &SOCK_STREAM, $proto) || die "socket: $!";
} bind(S, $this) || die "bind: $!";
} connect(S, $that) || die "connect: $!";
} select(S); $| = 1; select(stdout);
} while (<S>) {
} print;
} }
}
} the server prints
} Listening again
} when it starts, and
} accept ok
} 2 2047 <my IP address>
} when the client runs (on a separate machine), but then both hang with no
} furthur output.
}
} mARCO bLOORE bloore@h-plus-a.com
} Vice-President, Software Engineering
} I. Hoffmann + assoc inc. http://www.h-plus-a.com/
} http://www.nikolai.com/
--
Paul J. Schinder
Code 693
NASA Goddard Space Flight Center
schinder@leprss.gsfc.nasa.gov
------------------------------
Date: 6 Jun 1997 10:51:29 +1000
From: greg@turing.une.edu.au (Greg Zevin)
Subject: Re: String Compare Problem
Message-Id: <5n7muh$vpb@turing.une.edu.au>
pcartier@ix.netcom.com (Paul Cartier) writes:
>Could someone give me an example on how I can search the
>begining of a string for a match.
Well, It's written in all perl books. Try to add ^ in regexp
Greg Zevin
:for example, when searching for a zip-code (065) using
:the code below will return
:06518 this is the result I am looking for, all 065???? values
:87065 Not the two below.
:80653
:Looking for a result like this:
:06518
:06512
:06577
:script compare code:
: for ($x = @word_list; $x > 0; $x--) {
: $match_word = $word_list[$x - 1];
: if ($db_value =~ /$match_word/) {
: splice(@word_list,$x - 1, 1);
: } # End of If
: } # End of For Loop
:Thanks for any help you can give me!
:Paul Cartier
:fmp@tiac.net
------------------------------
Date: 6 Jun 1997 10:11:10 GMT
From: jarausch@numa1.igpm.rwth-aachen.de (Helmut Jarausch)
Subject: Tricky Syntax Question
Message-Id: <5n8nnu$h17$1@news.rwth-aachen.de>
Hi,
my C++ background let my try the following construct which Perl (5.004)
didn't like.
push ( /\! / ? @Rest : @Selected ),$_;
it says: Type of arg 1 to push must be array
Now the question is - what is the type of a conditional expression
if both alternatives are arrays?
Thanks for your opinions - current Perl's opinion isn't mine.
--
Helmut Jarausch
Lehrstuhl f. Numerische Mathematik
Institute of Technology
RWTH Aachen
D 52056 Aachen, Germany
------------------------------
Date: Fri, 06 Jun 1997 16:21:53 +0200
From: TERMA Elektronik AS <terma@post1.tele.dk>
Subject: TRYITOUT: Global HD
Message-Id: <33981D01.1EC7@post1.tele.dk>
Want to use your html pages as a global HD?
Test this system that enables your visitors to
* upload, download, and delete files
* make and delete directories
- on your site. The client actually sees the files and directories
appearing, and he can enter and leave directories, he just made.
This is accomplished by combining ordinary html pages, frames, and cgi
scripts (cgi scripts are known from various search engines on the net).
The system supports htpasswd (used on the Apache and NCSA web server).
Some systems simillar to this is very complex and difficult to use. This
system don't care who touches which files. Instead (using htpasswd),
users can be divided into five categories/groups, giving the webmaster a
little control over, who has access to what, and where. The uploader of
each file is registered to enhance security.
The system uses Perl scripts and runs on unix based web servers.
You can try it out on the following address:
http://www.et.aarhus.ih.dk/~knudris/filetrans
You have to use Netscape 3 because of the special use of frames. the
latest IE should do as well, but the Netscape 4 Beta still has
difficulties uploading properly.
There's no limit as to the size of upload, but to prevent huge amounts
of data on my site, I'v limited tryout uploads to 100 bytes (yearh I
know, it's not much).
If you want a full working test copy of the system, mail me at:
btp@terma.dk (untill July 1st)
or
3288@et.aarhus.ih.dk (after July 1st)
*
*
*
* * *
***
*
Prize: Bug feedback and comments + a little about yourself + a
description of what the system will be used for.
To be able to use the system on your own site, the following
requirements must be met:
- the web server must run in an unix environment
- you must be able to execute scripts
- you must have a copy of Perl installed
- your web server must send unknown file types as binary files
(not actually essential but almost)*
*some web servers send unknown file types as plain text, which means
that the browser changes unix line feeds to the type of line feeds used
by the browsers platform. This will corrupt binary files with unknown
extensions.
TRY IT OUT TODAY!
Regards
Bjarni Thor Pjetursson
------------------------------
Date: 5 Jun 1997 18:37:24 GMT
From: thompson@scapa.cs.ualberta.ca (Christopher Thompson)
Subject: Re: What does "UNIX" stand for..
Message-Id: <5n7114$q46$1@pulp.ucs.ualberta.ca>
Don Yuniskis (dgy@rtd.com) wrote:
: MULTICS -> UNICS -> UNIX --> FreeBSD (shameless plug! :>)
: I've never understood the bias *against* MULTICS as I thought it was
: *decades* ahead of it's time! I suspect the delays in getting it
: up and running were the inspiration for UNICS's genesis.
My introduction to the wide world of the internet came in 1990 when
I got access to a machine running Multics. It was finally shut down
some time in '91 or '92, at which point it was _definitely_ decades
behind its time. Not a bad run for an operating system, though.
-=Christopher Thompson=-
------------------------------
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 580
*************************************