[7023] in Perl-Users-Digest
Perl-Users Digest, Issue: 648 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jun 23 23:07:27 1997
Date: Mon, 23 Jun 97 20:00:20 -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 Mon, 23 Jun 1997 Volume: 8 Number: 648
Today's topics:
**BEST C++ BOOK YOU MUST READ (Mbslcom)
Re: a string to an array <esupu@warwick.ac.uk>
Re: beautifier for perl code <merlyn@stonehenge.com>
CGI.pm help? <mikus@sirius.com>
Re: Checking a string for "@' and "." (Tung-chiang Yang)
Re: Checking a string for "@' and "." (Abigail)
distributed objects in perl <gcancio@mail.cern.ch>
Re: int function <rootbeer@teleport.com>
Re: int function (Dr. Frank J. Mabry, Jr.)
Re: leading zeroes (Trey Valenta)
Re: leading zeroes (Craig Berry)
Newbie: 500 Server Error message <ip201945@ip.pt>
Re: Q: an alternative to this use of "goto"? (Lloyd Zusman)
Re: reading a data file? <rootbeer@teleport.com>
Re: Reset an EOF condition - HowTo <rootbeer@teleport.com>
Re: RFC: Xlib.pm (Stephen McCamant)
Re: Rounding a Random Number <rootbeer@teleport.com>
Re: Search all /home2/user/WWW/index.htm(l) <rootbeer@teleport.com>
Re: Sockets (Bob Wilkinson)
Very Basic Perl Question on Array hcchan@wellsfargo.com
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 24 Jun 1997 00:08:12 GMT
From: mbslcom@aol.com (Mbslcom)
Subject: **BEST C++ BOOK YOU MUST READ
Message-Id: <19970624000800.UAA06473@ladder01.news.aol.com>
The best and the most student friendly book in C++ is now on the market.
If you want to learn C++ easily and quickly, read it. The book is
"Object-Oriented C++ Primer" by Leon Poskar. Despite the fact that it has
been published this year, it has sold thousands of copies. The book is
written in a clear, easy to understand manner.
It gives a thorough treatment of C++ features inherited from C, such as:
data presentation and data types, control statements, arrays, functions,
structures, unions, character strings, pointers, operators, preprocessor
directives, C style run-time allocation, C style input/ output, ANSI
Standard Library. It goes in depth in describing C++ specific: classes,
operator overloading, inheritance, polymorphism, virtual functions,
function and class templates, exception throwing, function overloading,
functions with default arguments, C++ style input/output, C++ style
run-time allocation, iostream libary.
Each theoretical concept in the book is illustrated by a runable
example. Many examples have been tried on at least two compilers to insure
the most portability of the code and generality of concepts. The book is
based on ANSI (ISO) Standards for C and ANSI Standard Draft for C++. The
text is good for students, engineers, programmers, or anybody who wants to
study C++. You will be able to become proficient in C++ does not matter
whether you have or do not have any experience in programming and language
C. The book covers all the platforms and environments (DOS, Windows 3...,
95, NT...), UNIX, Macintosh.
The book is sold in "Quantum Books" (Cambridge near MIT, MA), "New
England Mobile Book Fair" (Newton, MA), "Harvard Bookstore" (near Harvard
University), Microcenter (14 locations natinwide), "Baker Books" (North
Dartmouth, MA), Computer Literacy Bookshop" (4 locations in CA and
Virginia), your local "Barnes &Noble", and other stores. It is available
from a distributor via phone. Call 1-800-431-1579 to order. Have your
credit card ready. The price is $25.95 + $3 shipping &handling in US.
Again the book is "Object-Oriented C++ Primer" written by Leon Poskar.
------------------------------
Date: Tue, 24 Jun 1997 02:52:49 +0100
From: mike mah <esupu@warwick.ac.uk>
To: "Jason D. Borneman" <Jason.D.Borneman@rose-hulman.edu>
Subject: Re: a string to an array
Message-Id: <Pine.SOL.3.95.970624025111.8330A-100000@crocus>
> I'm pretty new to the perl language, but have come to love it. I just
> have one question. Is it possible to convert a string to an array of
> letters. Like converting "HELP" to (H,E,L,P)? If so, how cna I do
> this.
You can try the code below although there is a lot of better way
to do it.
#!/usr/local/bin/perl -w
$a= "d.jfdksfj";
$a=~ s/(\S)/\1\t/g;
@a= split(/\s/,$a);
print @a;
Hope it helps.
--
Yours sincerely,
Mike Mah
First year computer systems engineering student.
University of Warwick
------------------------------
Date: 22 Jun 1997 09:00:39 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: clay@panix.com (Clay Irving)
Subject: Re: beautifier for perl code
Message-Id: <8cd8peocew.fsf@gadget.cscaper.com>
>>>>> "Clay" == Clay Irving <clay@panix.com> writes:
Clay> In <33AA5799.167EB0E7@rocketship.com> Sanjay Varma <sanjay@rocketship.com> writes:
>> is there a beautifier for perl code? (written in perl or otherwise)
Clay> There are several of them: Tom, Randal, Tod, Mike...
Heh. Some would argue that one of those people up there makes Perl
look more ugly than necessary. :-)
One of my "back burner, gotta try it someday" projects is to process
perly.y into a perl-byacc program that parses perl *for real* and
creates a "null compiler" that could spit the fully recognized source
code right back out. Then, we could do things like add
pretty-printing hooks or dataflow analysis or function/variable
cross-refs.
Actually, that might all be possible with B.pm, now that I think about
it, presuming we don't lose the comments. Hmm.... :-) Too bad it's
still way way down there on the priority list, but maybe this message
will inspire someone with a little less legal hassle and a little more
time to take the project on.
print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,495.69 collected, $182,159.85 spent; just 436 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@ora.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: Tue, 17 Jun 1997 18:55:44 -0700
From: Mike Aarset <mikus@sirius.com>
Subject: CGI.pm help?
Message-Id: <33A74020.173F@sirius.com>
Hi
Try to make this short. I finaly got access to a Linux server so I could
start useing Perl5. I'm able to do short simple perl scripts and run
them from the command line and now I want to tie them into a web page.
Oh and CGI.pm is installed and that is what I'm trying to use.
The below program asks for someone's name and there email address and
stores it in two seperate files on my server.
#!/usr/local/bin/perl
# A program that will give you a menu of what to input and where to
input it
# Variables for files
$email_file = '/usr/home/mikus/logs/email.log';
$name_file = '/usr/home/mikus/logs/name.log';
# Variables for data input
$yes = 1;
# Variables for the loop
$done = 1;
print ("Do you wish to input data to the email database:\n");
print ("To do this you must type 1 for yes:\n");
$answer = <STDIN>;
if ($answer == $yes) {
print ("You typed yes so you want to continue with this nifty program
that lets you input a name and email address to two seperate files
automatically:\n");
}
else {
print ("Your answer was no and now please press ctrl + D to end this
program:\n");
}
while ($done == 1) {
print ("Please enter the email address of the person you want
saved:\n");
$email_data = <STDIN>;
chop ($email_data);
print ("Please enter the name of the person that has that email address
now:\n");
$name_data = <STDIN>;
chop ($name_data);
open(DATA, ">>$email_file"); # opens a file for appending useing
perldata varprint DATA
print DATA ("$email_data");
close (DATA);
open(NAME, ">>$name_file"); # Opens name.log so that the name of
person will be put in.
print NAME ("$name_data");
close (NAME);
# now we see if the user wants to continue
print ("Would you like to add another name and email address? If so
type 1. If no any other number will do:\n");
$done = <STDIN>;
chop ($done);
}
Now I'm trying to use CGI.pm so that some one can go to a page with form
tags and input a name and email address and have that info stored in the
two log files.
If I put use CGI; $query = new CGI; just below the pound bang line when
I go to the command line and do the
chmod 755 filename.cgi and then
perl filename.cgi I get the mode thing What do I do then?
(offline mode: enter name=value pairs on standard input)
Or should I use this below the pound bang line
use CGI qw(:standard);
cause when I run the script with [ use CGI qw(:standard); ] It
doesn't ask for the name=value thing.
Sorry this is such long winded
I hit this site
http://www-genome.wi.mit.edu/ftp/pub/software/WWW/cgi_docs.html
And don't really understand it.
This is what my form html page looks like
<HTML>
<HEAD>
<TITLE>First CGI with file saveing.</TITLE>
</HEAD>
<form action="fircgi.cgi" method=POST>
this simple CGI will ask for email address and name of that person and
hopefully store it in my log files.<P>
Enter name of person!<INPUT TYPE="text" NAME="name_data" VALUE=""><BR>
Enter email address of person!<INPUT TYPE="text" NAME="email_data"
VALUE=""></BR>
<input type=submit name="submit" value="submit"><input type=reset
name="reset" value="reset"><BR>
</FORM>
And the perl script looks like
#!/usr/local/bin/perl
use CGI qw(:standard);
# going to try the cgi thing again!
$email_file = '/usr/home/mikus/logs/email.log';
$name_file = '/usr/home/mikus/logs/name.log';
# now we open the files and append them with the data stored in the
variables
open(DATA, ">>$email_file"); # opens a file for appending useing
perldata varprint DATA
print DATA ("$email_data");
close (DATA);
open(NAME, ">>$name_file"); # Opens name.log so that the name of
person will be put in.
print NAME ("$name_data");
close (NAME);
When I run this on Netscape I get the following error page
The server encountered an internal error or misconfiguration and was
unable to complete your request.
I think the html page is finding the script but something is wrong with
it.
Can anyone help me if they have time.
Thanks
------------------------------
Date: Mon, 23 Jun 1997 23:25:32 GMT
From: tcyang@netcom.com (Tung-chiang Yang)
Subject: Re: Checking a string for "@' and "."
Message-Id: <tcyangEC952K.LH8@netcom.com>
I believe you need to escape '.' in /./ or /./ matches anything except
an empty line.
===========================
Mattias Lvnnqvist typed before Poison Ivy kissed him:
: One easy way is:
: $_=$string_to_check;
: if ((/@/)&&(/./) {
: }
: A simple perl tutorial that covers this, and much more, can be found on
: http://agora.leeds.ac.uk/Perl/start.html
--
========= Try the low-crossposting robomoderated 'alt.culture.taiwan' ===
soc.culture.taiwan, soc.culture.china (by SCC FAQ Team) FAQ's:
http://www.iglou.com/tcyang/Taiwan_faq.shtml, China_faq.shtml
------------------------------
Date: Mon, 23 Jun 1997 17:36:12 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Checking a string for "@' and "."
Message-Id: <EC8owC.8KK@nonexistent.com>
Dean Hollister (deanh@nospam.mail) wrote on 1392 September 1993 in
<URL: news:33ADE275.395B@nospam.mail>:
++
++ Can anyone point me to the required code to check whether or not a
++ string has BOTH the "@" and "." characters in it?
$line =~ /\@/ && $line =~ /\./;
(Now, I can make valid email addresses without @ and .)
Abigail
--
perl5.004 -wMMath::BigInt -e'$^V=new Math::BigInt+qq;$^F$^W783$[$%9889$^F47$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W98$^F76777$=56;;$^U=$]*(q.25..($^W=@^V))=>do{print+chr$^V%$^U;$^V/=$^U}while$^V!=$^W'
------------------------------
Date: Mon, 23 Jun 1997 18:22:36 GMT
From: German Cancio Melia <gcancio@mail.cern.ch>
Subject: distributed objects in perl
Message-Id: <Pine.GSO.3.95a.970623201000.19778M-100000@asis-w3>
Hello,
Is anybody here who has already tried to access perl 5 object from outside
a perl script (eg. from tcl?)??
I have a complex object model structure in perl and I'm trying to write a
graphical interface in tcl. For this purpose, I can a) rewrite all the
data structure in tcl, which would be very painful or b) try to write a
script which instantiates the objects and executes the requested methods
connecting to the tcl script (via eg. a socket).
This could be like:
(Request)
MyRemotePerlClass:[#object_id] method_name @parameter_array
(Answer)
@result_array
if #object_id is missing (a unique id within the class) we would have a
class method (eg. for instantiating a new object).
This example is very simple and easy to implement. But what happens if I
want to have complex data types for the parameters/return values, eg.
returning other objects?
I'm not very sure on how to do it, and maybe somebody already tried it!
Thank you for your help!
german
------------------------------------------------------
German Cancio Melia IT - DIS CERN - 1211 Geneve 23
Phone: +41 2276 79801 mail: German.Cancio@cern.ch
------------------------------------------------------
------------------------------
Date: Sat, 21 Jun 1997 14:07:13 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Mike Wendl <mwendl@watson.wustl.edu>
Subject: Re: int function
Message-Id: <Pine.GSO.3.96.970621140421.24220I-100000@kelly.teleport.com>
On Thu, 19 Jun 1997, Mike Wendl wrote:
> $val = 5.015;
> $arg = 100.0*$val+0.5;
> $val = int ($arg);
> print "ARG IS $arg and RESULT IS $val\n";
> ARG IS 502 and RESULT IS 501
What you're seeing here is that $arg has a value something like
501.99999999999999999; when you go to print that, you get 502 (because
perl's standard numeric format doesn't print that many digits) but when
you use int() you get the mathematically correct answer of 501. This isn't
perl's fault; it has to do with the way that your system works with real
numbers.
Maybe you wanted to use sprintf in the first place? :-)
Hope this helps!
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 23 Jun 97 13:14:12 GMT
From: df6954@eecs1.eecs.usma.edu (Dr. Frank J. Mabry, Jr.)
Subject: Re: int function
Message-Id: <33AE76A4.7AB8@eecs1.eecs.usma.edu>
The difference between a "perfect representation" ( that would
yield an exact value of 502 rather than 501.999999999 )and what
Perl is giving you is between 0.000000000000028 and 0.000000000000029.
Dr. Frank Mabry
Dept. of EE&CS
USMA
West Point
Email df6954@eecs1.eecs.usma.edu
------------------------------
Date: 21 Jun 1997 20:55:14 GMT
From: trey@zipcon.net (Trey Valenta)
Subject: Re: leading zeroes
Message-Id: <866926676.381764@ran.zipcon.net>
In <33a96f4f.0@amhnt2.amherst.edu> bgjohnso@unix.amherst.edu (Brad Johnson) writes:
>: Mariana Wuerz <mariana.wuerz@fernuni-hagen.de> writes:
>: > $four=04
>: >
>: > How can I get $four=4?
>: } # end sub nozeros
Or $four *= 1; and convert it to a number from a sting.
--
Trey Valenta trey@zipcon.net
------------------------------
Date: 24 Jun 1997 00:26:25 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: leading zeroes
Message-Id: <5on47i$t64$1@marina.cinenet.net>
Brad Johnson (bgjohnso@unix.amherst.edu) wrote:
: : Mariana Wuerz <mariana.wuerz@fernuni-hagen.de> writes:
: : > $four=04
: : >
: : > How can I get $four=4?
:
: how 'bout using
: s/^0*//g
: ?
: or even
: s/^0*|\b0*//g
: ?
The latter is redundant; start-of-string (^) is a word boundary (\b).
It's also wasteful in that it matches nothingness (thanks to *), though
the optimizer will probably catch this. Finally, it will replace a
standalone 0 with nothing, which probably isn't desirable.
I'd suggest
s/\b0+(?=\d)//g
as a better alternative; translated into English, this means "replace any
sequence of one or more zeros which are preceded by a non-word character
or beginning of string, and followed by a digit, with an empty string."
By the way, I just finished reading Friedl's "Mastering Regular
Expressions" -- and I very highly recommend it to anyone crafting regexes
for Perl or any other tool. It's a truly eye-opening book.
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| Member of The HTML Writers Guild: http://www.hwg.org/
"Every man and every woman is a star."
------------------------------
Date: Tue, 24 Jun 1997 01:40:45 +0200
From: Andre Pinheiro <ip201945@ip.pt>
Subject: Newbie: 500 Server Error message
Message-Id: <33AF097D.762C@ip.pt>
The answer to my question is probably very simple, but, you
know, I've just started programming in Perl... so, please
help me!
I have a script called "games_search.pl" in the "cgi-bin" dir.
By the way, I have other .pl scripts here and they work fine.
When I specify "http://www.mysite.com/cgi-bin/games_search.pl"
in the browser, the server returns:
----
500 Server Error
The server encountered an internal error or misconfiguration and was
unable to complete your request.
Please contact the server administrator and inform them of the time
the error occurred, and anything you might have done that may have
caused the error.
Error: HTTPd: malformed header from script
/usr/local/etc/httpd/cgi-bin/games_search.pl
----
Here is the script source code:
----
#!/usr/local/bin/perl
&showHTML_header;
&showHTML_footer;
exit;
sub showHTML_header {
print 'Content-type: text/html' . "\n\n";
print '<HTML><HEAD><TITLE>xxxx</TITLE></HEAD>' . "\n";
print '<BODY TEXT="#000000" LINK="#008000" VLINK="#800000"
BGCOLOR="#FFFFCC">' . "\n";
print '<CENTER>' . "\n";
print '<IMG SRC="Images/Logo.jpg" WIDTH=272 HEIGHT=175 BORDER=0
ALT="xxxxxxx">' . "\n";
print '<BR>' . "\n";
print '<IMG SRC="Images/GreenBlackStripe.gif" WIDTH=536 HEIGHT=5><BR>'
. "\n";
print '<IMG SRC="Images/GreenBlackStripe.gif" WIDTH=536 HEIGHT=5>' .
"\n";
print '<P>' . "\n";
}
sub showHTML_footer {
print '<FONT SIZE=-1>' . "\n";
print 'Feedback:<BR>' . "\n";
print '<P>' . "\n";
print '</FONT>' . "\n";
print '</CENTER></BODY></HTML>' . "\n";
}
----
What am I doing wrong?
Please reply to ip201945@ip.pt
Thanks in advance.
------------------------------
Date: 24 Jun 1997 00:18:25 GMT
From: asfast@asfast.com (Lloyd Zusman)
Subject: Re: Q: an alternative to this use of "goto"?
Message-Id: <slrn5qu4g7.6as.asfast@ljz.asfast.net>
On Mon, 23 Jun 1997 17:18:24 GMT, Abigail <abigail@fnx.com> wrote:
> Lloyd Zusman (asfast@asfast.com) wrote on 1392 September 1993 in
> <URL: news:slrn5qs35c.bk0.asfast@ljz.asfast.net>:
> ++ On Sun, 22 Jun 1997 20:29:23 -0700, Craig Scrivner
> ++ <scrivner@gps.caltech.edu> wrote:
> ++ >
> ++ > START: {
> ++ > if (...) {
> ++ > ...
> ++ > }
> ++ > elsif (...) {
> ++ > ...
> ++ > redo START;
> ++ > }
> ++ > }
> ++
> ++ But aside from spelling "goto" as "redo" and requiring an extra level
> ++ of braces, how does this example differ from using "goto"?
>
> You can't just jump anywhere. You can only jump to the beginning
> (or end) of an enclosing block. It's like a goto, but with a limited
> set of landing points.
>
> You are right, this example doesn't differ from using 'goto'. But
> there are examples of using 'goto' where it does matter.
Agreed.
> ++ The "goto" statement first fell into disfavor many years ago as part
> ++ of the philosophy of "modular programming". The above construct would
> ++ be considered just as undesirable by the proponents of modular
> ++ programming as the following construct.
> ++
> ++ START:
> ++ if (...) {
> ++ ...
> ++ }
> ++ elsif (...) {
> ++ ...
> ++ goto START;
> ++ }
>
> Actually, the 'undesirable' case is a jump the other way:
>
> foreach (1 .. 10) {
> ...
> LABEL:
> ...
> }
> goto LABEL;
>
> *That* is what makes goto considered harmful.
Yes, your example is even *more* undesirable than mine. However, the
modular programming (sometimes called "structured programming")
purists used to fervently complain about both of these constructs.
To use "goto" to jump into a block creates situations that are
undefined or ambiguously defined at run time. This is clearly a "bad
thing". However, in most languages there is nothing ambiguous at run
time with using "goto" to leave a block (as long as you end up in a
block which contains your own block). Nor is there anything ambiguous
at run time in these languages in using "goto" to transfer control to
a different place within the current block.
Keeping this in mind, attempts were made to define languages which
allowed "goto", but which restricted its use to situations where its
run-time meaning would not be ambiguous (e.g., not allowing a "goto"
to transfer control into a block). However, this didn't mollify the
group of people who wanted to eliminate "goto" altogether.
There were other considerations put forth against the use of "goto"
besides the avoidance of ambiguous run-time constructs. There was
a vast proliferation of goto-laden "spaghetti code" that was
very hard to maintain, and the restriction of the use of "goto" was
seens as a way to ameliorate this unfortunate situation. However,
there were many people (often in positions of influence) who became
downright religious about this, and who started to preach in favor
of the total elimination of "goto".
I agree with many of the ideas put forth by this group of people, but
in my opinion, they went a bit too far. Those people who tried to
rigidly adhere to the "no goto" rule would sometimes be forced to
write deeply nested, convoluted code just to avoid a few "goto"
statements which, for example, could neatly transfer control to an
error exit near the end of a routine.
It is with these "no goto" purists in mind that I posted my comments
about "redo" and "goto".
> [ ... ]
>
> ++ Therefore, it's my opinion that if you really want to use that "redo"
> ++ construct, you might as well just leave off the extra braces and spell
> ++ "redo" as "goto".
>
> Nope, redo is a limited goto. You can simulate redo with goto, but
> you can't simulate goto with redo.
Of course. But in the subset of cases where "redo" and "goto" are
equivalent, there is nothing wrong with "goto" ... or at least nothing
worse about it than using the equivalent "redo" construct.
--
Lloyd Zusman
ljz@asfast.com
------------------------------
Date: Mon, 23 Jun 1997 18:53:04 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Brandon <weekend_warrior@mindless.com>
Subject: Re: reading a data file?
Message-Id: <Pine.GSO.3.96.970623185008.15285F-100000@kelly.teleport.com>
On Mon, 23 Jun 1997, Brandon wrote:
> What I need the script to do is read a data file with the information of
> the users in a format like:
> 1234 = someone@somewhere.com
> 4321 = someonelse@somewhere.com
> or
> 1234
> someone@somewhere.com
> 4321
> someonelse@somewhere.com
> and return only the email address as $id depending on the input.
Could you want something as simple as getpwuid(), with '@somewhere.com'
tacked on?
If you have a choice, use the first file format; it's simple to read and
stash in a hash with a few lines of code. (You could even leave out the
equal sign, since it's not needed.)
Let us know if you get stuck trying to do this. Hope this helps!
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Sat, 21 Jun 1997 14:56:28 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Helmut Jarausch <jarausch@numa1.igpm.rwth-aachen.de>
Subject: Re: Reset an EOF condition - HowTo
Message-Id: <Pine.GSO.3.96.970621145325.24220R-100000@kelly.teleport.com>
On 20 Jun 1997, Helmut Jarausch wrote:
> open FILE,....
> while( define(<FILE>) ) { ... scan the file }
You probably meant one of these; they're equivalent.
while (<FILE>) { ... }
while (defined($_=<FILE>)) { ... }
> # now I want to process FILE again without close/open
>
> # reset the error conditon (EOF) on FILE -- HowTo
>
> seek FILE,0,0;
>
> while( define(<FILE>) ) { ... process again }
You were really close; the example for seek() in the docs or in the Blue
Camel pp. 209-210 will show you a way which may work. If it doesn't, blame
your stdio implementation. :-) Hope this helps!
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 23 Jun 1997 23:25:03 GMT
From: stephen@alias-2.pr.mcs.net (Stephen McCamant)
Subject: Re: RFC: Xlib.pm
Message-Id: <slrn5qu1c2.v1e.stephen@alias-2.pr.mcs.net>
On 23 Jun 1997 13:31:56 GMT, Brian Wheeler <bdwheele@indiana.edu> wrote:
>I'm currently writing an Xlib clone in perl. So far, it'll let you write
>programs like this:
>
>use Xlib;
>
>$display=Xlib->new("localhost:0");
>$window=$display->CreateWindow($display->{'screen'}->[0]->{'root'},
> 0,0,
> 100,100,
> 1,
> 16,
> 0,
> 0,
> 2,0);
>$display->MapWindow($window);
>sleep 20;
>$display->DestroyWindow($window);
>$display->Bell;
>
>Which will create a window, show it for 20 seconds, erase it, and then
>ring the display's bell.
>
>I've also got events, errors, etc. built in. I'm about half-way done with
>the requests, so there's still alot to do before its ready for the public.
>
>The nice thing about this module is that it only requires IO::Socket. The
>system doesn't need to have Xlib installed.
>
>After Xlib is done, it should be pretty easy to write a perl-based toolkit
>on top of it. Window managers would be nice too....very nice :)
>
>Any thoughts? Is this a silly idea?
>If you're interested in seeing the code as is, send me mail!
Grr.... I knew if I waited long enough this would happen.
No, it isn't a silly idea. In fact, at least two people have come up with it
before. Mark Eichin wrote a bunch of perl4-type packages for this purpose,
(written up in the last issue of The Perl Journal) and I wrote, then
procrastinated about releasing, a module named X11::Protocol that's eerily
similar to yours.
I'd be interested to hear how you handled some details (like
authentication); I'll email you if you don't respond to this message.
For you or anyone else in an alpha-testing mood, I've put up a tarfile of
the current state of my module up at
http://www.mcs.net/~alias/public_stuff/X11-Protocol-0.01.tar.gz
--
____________________________________________________________
Stephen McCamant ======== alias@mcs.com (finger for PGP key)
------------------------------
Date: Sat, 21 Jun 1997 14:36:47 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Scott Crumpton <scott@moriah.com>
Subject: Re: Rounding a Random Number
Message-Id: <Pine.GSO.3.96.970621140855.24220J-100000@kelly.teleport.com>
On Thu, 19 Jun 1997, Scott Crumpton wrote:
> I'm trying to get a random item from a list.
>
> I created the code below but I since it gets the random number before it
> gets rounded to the integer I think there are too many number to choose
> from making it not truly random.
You're right. There's a small propensity to choose earlier items more
frequently than later ones.
> @list = (zero, one, two, three);
> $r = $list[int(rand(@list))];
You could omit the int, since that's implied.
$r = $list[ rand(@list) ]; # (nearly) random element
For small lists, the difference is negligible. When you have thousands of
items, though, it becomes noticeable, and with millions you may even have
some items which can't be selected at all. :-(
One good method is to cut down large lists to a smaller size. This is
analogous to what happens when millions of people are entered in a
drawing: For each prize, a lucky mailbag is selected at random, then an
entry can be drawn from that bag. If each bag has about the same number of
letters in it, it's still random enough. (But I'd put my letter in a
mailbag all its own! :-)
If you have a million items, first use a small random number from 0 to 99
to pick which 10,000 to choose from next. Another such number can cut it
down to 100 choices, and then it's simple.
If you need something better than this (and if your system rand() is good
enough to make the effort meaningful, which is not always the case) let me
know and I'll see what else I can do.
Hope this helps!
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Sat, 21 Jun 1997 14:04:01 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Lauri Laakso <lauri@samoilu.net>
Subject: Re: Search all /home2/user/WWW/index.htm(l)
Message-Id: <Pine.GSO.3.96.970621140316.24220H-100000@kelly.teleport.com>
On Thu, 19 Jun 1997, Lauri Laakso wrote:
> I need some help to get all users index.htm or index.html files which
> are located at /home2/[user]/WWW/index.html
Then you probably want to use find2perl to get started. If your perl was
properly installed, you should have find2perl as well. Hope this helps!
-- Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Fri, 20 Jun 1997 16:38:28 +0100
From: b.wilkinson@pindar.co.uk (Bob Wilkinson)
Subject: Re: Sockets
Message-Id: <b.wilkinson-2006971638280001@ip57-york.pindar.co.uk>
In article <d7mfsgk9c.fsf@s3i.com>, Clark Dorman <clark@s3i.com> wrote:
> hjs@Cadence.COM (Henry Salvia) writes:
> > In article 5D7D@inta.net.au, Anil Gupta <anil@inta.net.au> () writes:
> > > Hello there..
> > >
> > > Does anyone know where I can find a good socket tutorial?
> > > I tried perlipc but it was a bit advanced
>
> Sorry for the piggyback, but I didn't see the original.
>
> I would recommend that you look at:
>
> http://www.cs.uno.edu/~golden/teach.html
>
> Basically, these are close to the same socket programs that are presented in
> perlipc, but they are very heavily documented. Each line is explained in
> more detail than perlipc, thus making it much more clear what is going on.
> If you don't know sockets, this will help.
>
> --
> Clark Dorman "Evolution is cleverer than you are."
> http://cns-web.bu.edu/pub/dorman/D.html -Francis Crick
Hello,
More general Unix sockets info at.
http://kipper.york.ac.uk/~vic/sock-faq/
This page has other links, too.
Bob
--
Do what thou wilt shall be the whole of the law.
------------------------------
Date: Mon, 23 Jun 1997 19:21:36 -0600
From: hcchan@wellsfargo.com
To: hcchan@wellsfargo.com
Subject: Very Basic Perl Question on Array
Message-Id: <867111149.17930@dejanews.com>
Hi,
I am new to Perl and have a very basic question.
How do I write up a perl program which will create an array.
I have a file which contains the name of tablespaces in Oracle and
will be insert into the array.
The size of tablespace grows/shrink dynamcially, so it
may be different each day. And I don't know how big
an array I should set aside.
Any ideas,
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
------------------------------
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 648
*************************************