[13282] in Perl-Users-Digest
Perl-Users Digest, Issue: 692 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 1 01:07:21 1999
Date: Tue, 31 Aug 1999 22:05:08 -0700 (PDT)
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, 31 Aug 1999 Volume: 9 Number: 692
Today's topics:
[ANNOUNCE] Text-Ispell-0.03 <jdporter@min.net>
Re: Binary to Text (Martien Verbruggen)
Can I have a subroutine return a hash? <gremlin_NO_SPAM_@ix.netcom.com>
Re: cgi error on apache (David Efflandt)
CGI question: CGI output being mixed with older output, <cshannon@mdo.net>
Comparing lists (Delarock)
Dos Perl System and Redirection kinh@my-deja.com
Re: Dos Perl System and Redirection <kmonte@columbus.rr.com>
Re: editors?? <kmonte@columbus.rr.com>
example,beginner,if,elsif,else <bzhaainc@erols.com>
Re: example,beginner,if,elsif,else (David Efflandt)
Re: example,beginner,if,elsif,else <pziatek@sgi.com>
Re: gethosybyaddr (Martien Verbruggen)
Re: gethosybyaddr (William Herrera)
How to read webpages and post HTML forms with PERL <larc@writeme.com>
Re: is the mtime time between date1 and date2? (Martien Verbruggen)
Re: perl equivalent of a Unix command line sort? (Martien Verbruggen)
Re: perl equivalent of a Unix command line sort? <uri@sysarch.com>
Re: Simulating Carriage Returns (Bill Moseley)
Re: Sockets and Threads Lee.Lindley@bigfoot.com
Re: Sockets and Threads Lee.Lindley@bigfoot.com
Re: SSN format <gremlin_NO_SPAM_@ix.netcom.com>
Re: subtraction error (Bill Moseley)
tied hash <pziatek@sgi.com>
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 31 Aug 1999 20:27:47 GMT
From: John Porter <jdporter@min.net>
Subject: [ANNOUNCE] Text-Ispell-0.03
Message-Id: <7qhdrj$72k$1@nnrp1.deja.com>
I'm pleased to announce the availability of my Text::Ispell module,
a spell-checking facility which uses the external program ispell
to do the real work. It can be found in
CPAN/authors/id/J/JD/JDPORTER
(While you're there, take a sidelong glance at my other modules,
Tie::Multidim and Text::Macros.)
I would be very grateful for any feedback, especially advice on
how to make this module more useful.
For your convenience, the module distribution's README file
is included below.
hand,
John Porter
__README__
Note:
A simple "spellchecking" program is included in this distribution.
It is a perl program named "spellcheck". It simply prints the
analysis of the input text; it provides no way to modify the text.
It is simply given as a demonstration of the module. Type
spellcheck -h
for a usage summary. If no input files are specified, it will
read from stdin. After each line of input, it will print the
analysis of the terms. By default, it only gives output for
terms which are "incorrect". Give it the -v option to have it
report on the "correct" terms as well.
Tests:
'make test' currently does nothing. To test the installation,
try out the "spellcheck" program provided.
For your convenience, the module's pod is included below.
__POD__
NAME
Text::Ispell.pm - a module encapsulating access to the Ispell
program.
SYNOPSIS
# Brief:
use Text::Ispell;
Text::Ispell::spellcheck( $string );
# or
use Text::Ispell qw( spellcheck ); # import the function
spellcheck( $string );
# Useful:
use Text::Ispell qw( spellcheck );
for my $r ( spellcheck( "hello hacking perl shrdlu 42" ) ) {
print "$r->{'type'}: $r->{'term'}\n";
}
DESCRIPTION
Text::Ispell::spellcheck() takes one argument. It must be a
string, and it should contain only printable characters. One
allowable exception is a terminal newline, which will be chomped
off anyway. The line is fed to a coprocess running ispell for
analysis. The line is parsed on non-wordchars into a sequence of
terms. By default, the set of wordchars is defined in ispell as
letters, digits, and the apostrophe. In other words, the line is
subjected the equivalent of
split /[^a-zA-Z0-9']+/
(ispell has a means to add characters to the default set, but
currently Text::Ispell does not provide access to that feature.)
The result of ispell's analysis of each term is a categorization
of the term into one of six types: ok, root, miss, none,
compound, and guess. Some of these carry additional information.
Text::Ispell::spellcheck returns a list of objects, each
corresponding to a term in the spellchecked string. Each object
is a hash (hash-ref) with at least two entries: 'term' and
'type'. The former contains the term ispell is reporting on, and
the latter is ispell's determination of that term's type (see
above). For types 'ok' and 'none', that is all the information
there is. For the type 'root', an additional hash entry is
present: 'root'. Its value is the word which ispell identified
in the dictionary as being the likely root of the current term.
For the type 'miss', an additional hash entry is present:
'misses'. Its value is a string of words, comma-separated, which
ispell identified as being "near-misses" of the current term,
when scanning the dictionary.
A quickie example:
use Text::Ispell qw( spellcheck );
for my $r ( spellcheck( "hello hacking perl shrdlu 42" ) ) {
if ( $r->{'type'} eq 'ok' ) {
# as in the case of 'hello'
print "'$r->{'term'}' was found in the dictionary.\n";
}
elsif ( $r->{'type'} eq 'root' ) {
# as in the case of 'hacking'
print "'$r->{'term'}' can be formed from root
'$r->{'root'}'\n";
}
elsif ( $r->{'type'} eq 'miss' ) {
# as in the case of 'perl'
print "'$r->{'term'}' was not found in the dictionary;\n";
print "Near misses: $r->{'misses'}\n";
}
elsif ( $r->{'type'} eq 'none' ) {
# as in the case of 'shrdlu'
print "No match for term '$r->{'term'}'\n";
}
}
According to the ispell man page, there should be two more
types: compound and guess. However, I have not figured out how
to elicit responses of these types from ispell.
ERRORS
`Text::Ispell::spellcheck()' starts the ispell coprocess if the
coprocess seems not to exist. Ordinarily this is simply the
first time it's called.
ispell is spawned via the `Open2::open2()' function, which
throws an exception (i.e. dies) if the spawn fails. The caller
should be prepared to catch this exception -- unless, of course,
the default behavior of die is acceptable.
Nota Bene
The full location of the ispell executable is stored in the
variable `$Text::Ispell::path'. The default value is
/usr/local/bin/ispell. If your ispell executable has some name
other than this, then you must set `$Text::Ispell::path'
accordingly before you call `Text::Ispell::spellcheck()' for the
first time.
AUX FUNCTIONS
add_word(word)
Adds a word to the dictionary. Be careful of capitalization. If
you want the word to be added "case-insensitively", you should
call `add_word_lc()'
add_word_lc(word)
Adds a word to the dictionary, in lower-case form. This allows
ispell to match it in a case-insensitive manner.
accept_word(word)
Similar to adding a word to the dictionary, in that it causes
ispell to accept the word as valid, but it does not actually add
it to the dictionary. Presumably the effects of this only last
for the current ispell session.
parse_according_to(formatter)
Causes ispell to parse subsequent input lines according to the
specified formatter. As of ispell v. 3.1.20, only 'tex' and
'nroff' are supported.
set_params_by_language(language)
Causes ispell to set its internal operational parameters
according to the given language. Legal arguments to this
function, and its effects, are currently unknown by the author
of Text::Ispell.
save_dictionary()
Causes ispell to save the current state of the dictionary to its
disk file. Presumably ispell would ordinarily only do this upon
exit.
terse_mode()
nonterse_mode()
In terse mode, ispell will not produce reports for "correct"
words. This means that the calling program will not receive
results of the types 'ok', 'root', and 'compound'.
ispell starts up in NON-terse mode, i.e. reports are produced
for all terms, not just "incorrect" ones.
LIMITATIONS
Currently this package assumes, and only supports, the default
language, i.e. English. It does not provide access to the
features of ispell which allow the selection of alternate
languages or dictionaries.
FUTURE ENHANCEMENTS
Take advantage of these ispell options:
-d file
Specify an alternate dictionary file.
For example, use -d deutsch to choose a German dictionary.
-p file
Specify an alternate personal dictionary.
-w chars
Specify additional characters that can be part of a word.
-B Report run-together words with missing blanks as
spelling errors.
-C Consider run-together words as legal compounds.
-P Don't generate extra root/affix combinations.
-m Make possible root/affix combinations that aren't
in the dictionary.
I should consider allowing these kinds of options to be set at
any time; this would entail stopping and restarting the
coprocess.
DEPENDENCIES
Text::Ispell uses the external program ispell, which is the
"International Ispell", available at
http://fmg-www.cs.ucla.edu/geoff/ispell.html
as well as various archives and mirrors, such as
ftp://ftp.math.orst.edu/pub/ispell-3.1/
This is a very popular program, and may already be installed on
your system.
Text::Ispell also uses the standard perl modules FileHandle,
IPC::Open2, and Carp.
AUTHOR
jdporter@min.net (John Porter)
This module is free software; you may redistribute it and/or
modify it under the same terms as Perl itself.
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Wed, 01 Sep 1999 03:03:41 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Binary to Text
Message-Id: <hI0z3.187$qP5.8106@nsw.nnrp.telstra.net>
In article <37CB3794.1E1D9781@rochester.rr.com>,
Bob Walton <bwalton@rochester.rr.com> writes:
> Excellent point, Larry. But I can never remember if it is pack or
> unpack, h or H, etc, and I'm too lazy to look it up each time I need
> it (perlfunc isn't real clear, so I have to go to a book). Since
> laziness is a virtue, I let the computer do the work.
I wonder whether your computer thinks laziness is a virtue too :) If
you make it work too hard, it may revolt some day.
Martien
--
Martien Verbruggen |
Interactive Media Division | Never hire a poor lawyer. Never buy
Commercial Dynamics Pty. Ltd. | from a rich salesperson.
NSW, Australia |
------------------------------
Date: Tue, 31 Aug 1999 23:55:14 -0400
From: gremlin <gremlin_NO_SPAM_@ix.netcom.com>
Subject: Can I have a subroutine return a hash?
Message-Id: <37CCA3A2.C5832276@ix.netcom.com>
Hi;
I would like to call a subroutine and have that routine open up a file,
add data to a hash, and return the new hash to the calling routine. I
have everything working except getting the data back to the caller! Can
anyone show me the declaration; call; sub. return statement that will
make all this work?
Thanks,
Mike
--
-----------------------------------------------------
To reply to me via email, remove the "__NO_SPAM__" in
the header email address.
-----------------------------------------------------
------------------------------
Date: 1 Sep 1999 03:37:56 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: cgi error on apache
Message-Id: <slrn7sp84o.1f0.efflandt@efflandt.xnet.com>
On Tue, 31 Aug 1999 19:35:59 GMT, Patrick Meidl <p.meidl@klivv.oeaw.ac.at>
wrote:
>
>on a debian 2.1 system with apache 1.3.3 and perl 5.004, I get the
>following errors when I try to run a sample cgi-script (from the CGI.pm
>homepage):
>
>[error] (2)No such file or directory: exec of
>/usr/lib/cgi-bin/cgitest.pl failed
>[error] [client xx.xx.xx.xx] Premature end of script headers:
>/usr/lib/cgi-bin/cgitest.pl
(snip)
>the file /usr/lib/cgi-bin/cgitest.pl exists, permissions are 755,
>/usr/lib/cgi-bin is my cgi-directory, and CGI.pm is in /usr/lib/perl5,
>and the perl path is also right.
>
>any ideas what's wrong?
1. If you are going to post to different newsgroups, post to all at the
same time, not individually (ie: comma separated list of newsgroups).
2. Your script has correct syntax (and runs on my Linux system), so this
is not a Perl problem, and it should NOT be posted to a perl newsgroup.
3. Do you get any error when you test it in the shell as ./cgitest.pl? If
it runs as 'perl cgitest.pl', but does not run as './cgitest.pl', you need
to learn how to use a Unix text editor instead of Windows notepad (try
pico from the pine package if you have not learned vi or emacs). The
problem in that case is that bash cannot find 'perl^M' (Unix does not use
carriage returns like DOS does).
4. If it passes test #3 you have a webserver configuration problem.
Normally CGI filename needs to end with .cgi. Did you enable .pl as
CGI in apache conf files?
>thanx
>*patrick*
--
David Efflandt efflandt@xnet.com http://www.xnet.com/~efflandt/
http://www.de-srv.com/ http://cgi-help.virtualave.net/
------------------------------
Date: Wed, 1 Sep 1999 00:09:12 -0400
From: "The News" <cshannon@mdo.net>
Subject: CGI question: CGI output being mixed with older output, how to avoid?
Message-Id: <IK1z3.11340$914.693745@typ11.nn.bcandid.com>
Hi,
I just made a script that sends mail to my address from a form.
When I originally made the script, I I wrote it so that the form page, the
thank you page, and the error page would all be generated by the script.
The code for each page were kept as here-docs in separate subroutines which
were called by the main program.
This is what happened:
(1) 2 e-mails, not one, were sent to my address. The first one was
completely blank, and the second one was the actual message.
(2) The thank you message or the error message would alwas be appended to
the bottom of the orginial form, which after pressing the submit button was
cleared of it's values. In short, I had both the submission form and the
thank you form on the same page!
What I did to get arround it was I deleted the code for generating the
responses and simply used
print $query->redirect('http://myurl/thankyou.htm');
or
print $query->redirect('http://myurl/nomail.htm');
and I also kept the original submission form on a static HTML document.
After keeping all the HTML code in documents rather than generated by the
script, my problem of double e-mail submissions and the thankyou/error pages
being juxtaposed with the original form page were gone.
Everything works the way it is supposed to now, but I would have prefered to
have had the script generate the HTML code for the form, thank you and error
pages.
Is there anyone out there who has encountered this problem and knows the
workaround?
Thanks in advance, Chris S.
------------------------------
Date: 01 Sep 1999 02:38:18 GMT
From: netdevilx@aol.com (Delarock)
Subject: Comparing lists
Message-Id: <19990831223818.01624.00000201@ng-fs1.aol.com>
Okay folks.. It's me, the lousy Perl programmer..
I think last time, I got mixed up about my version.. Doesn't really matter..
I need more help now. I have two lists of things.. Two columns each.. First
list is a standard list, second list is changing. I wanna compare them to see
which ones in the second list are different and print out a list of them, and
possibly email the list to someone. Anyone wanna give me help? Please send
responses via email.
------------------------------
Date: Wed, 01 Sep 1999 02:09:00 GMT
From: kinh@my-deja.com
Subject: Dos Perl System and Redirection
Message-Id: <7qi1rl$lis$1@nnrp1.deja.com>
I am trying to run a program inside a Perl script as:
...
system ("ftp <ftp.ans >ftp.out");
...
and it doesn't work. It does not read in the ftp.ans and does not
produce any output to ftp.out.
Thanks for any clue
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Tue, 31 Aug 1999 00:22:10 -0400
From: "kmonte" <kmonte@columbus.rr.com>
Subject: Re: Dos Perl System and Redirection
Message-Id: <RO1z3.3352$mo.94998@viper>
<kinh@my-deja.com> wrote in message news:7qi1rl$lis$1@nnrp1.deja.com...
> I am trying to run a program inside a Perl script as:
> ...
> system ("ftp <ftp.ans >ftp.out");
I am not sure why you want to do it this way, or what you are trying to do,
but ftp -n < ftp.ans will read the input file. the >ftp.out should then be
fine.
> and it doesn't work. It does not read in the ftp.ans and does not
> produce any output to ftp.out.
>
> Thanks for any clue
>
>
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.
------------------------------
Date: Tue, 31 Aug 1999 00:23:53 -0400
From: "kmonte" <kmonte@columbus.rr.com>
Subject: Re: editors??
Message-Id: <sQ1z3.3353$mo.95261@viper>
Caper <stevencNOSPAM@nbnet.nb.ca> wrote in message
news:7qhraa$1rn$1@garnet.nbnet.nb.ca...
> Any good Perl debuggers or editors to suggest?
also, if you are Linux, nedit is an X editor which uses colors to highlite
different syntax. It is useful in perl.
And free.
There are quite a few that are commercial in nature, but they cost money.
------------------------------
Date: Tue, 31 Aug 1999 22:51:14 -0400
From: "Ben Horowitz" <bzhaainc@erols.com>
Subject: example,beginner,if,elsif,else
Message-Id: <7qi4h3$45n$1@autumn.news.rcn.net>
am learning perl from a book,so,it gives an example you have to do,.to
modify tickets3,to give the user a choice,of two movies,it should ask which
movie the user wants to see, and then confirm that choice,.
THIS IS THE PROGRAM TICKETS3,
AN if... elsif... else statement,
print 'would you like to see the 11.00am showing of caper fear?';
$answer = <>;
chomp $answer;
if ($answer eq 'yes') {
print"that will be \8.50 please.\n";}
elsif(answer eq 'no'){print "okay but your missing a great movie\n";}
else{print"i"m sorry,i didn't understand that\n";}
I TRIED TO USE THE ELSIF ,IF THING TO MAKE IT CHOOSE BETWEEN TWO CHOICES
,BUT IT NEVER WORKS ,IT ALWAYS GOES TO ONE CHOICE,AM A REAL NEWBIE ,PLEASE
CAN SOMEONE HELP ME? 1) I ALSO DON'T UNDERSTAND WHAT THE DIFFRENCE
BETWEEN,CHOMP AND CHOP,AND WHATS ITS PURPOSE? 2)THANKS A MILLION,.YOU
PEOPLE HAVE HELPED ME BEFORE,MAY G-D BLESS YOU!PLEASE HELP ME AGAIN TO
BECOME A PERL PROGRAMMER,.
------------------------------
Date: 1 Sep 1999 04:07:41 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: example,beginner,if,elsif,else
Message-Id: <slrn7sp9sh.1f0.efflandt@efflandt.xnet.com>
On Tue, 31 Aug 1999 22:51:14 -0400, Ben Horowitz <bzhaainc@erols.com> wrote:
>am learning perl from a book,so,it gives an example you have to do,.to
>modify tickets3,to give the user a choice,of two movies,it should ask which
>movie the user wants to see, and then confirm that choice,.
>
>THIS IS THE PROGRAM TICKETS3,
>AN if... elsif... else statement,
>print 'would you like to see the 11.00am showing of caper fear?';
>$answer = <>;
>chomp $answer;
>if ($answer eq 'yes') {
>print"that will be \8.50 please.\n";}
>elsif(answer eq 'no'){print "okay but your missing a great movie\n";}
>else{print"i"m sorry,i didn't understand that\n";}
>I TRIED TO USE THE ELSIF ,IF THING TO MAKE IT CHOOSE BETWEEN TWO CHOICES
>,BUT IT NEVER WORKS ,IT ALWAYS GOES TO ONE CHOICE,AM A REAL NEWBIE ,PLEASE
>CAN SOMEONE HELP ME? 1) I ALSO DON'T UNDERSTAND WHAT THE DIFFRENCE
>BETWEEN,CHOMP AND CHOP,AND WHATS ITS PURPOSE? 2)THANKS A MILLION,.YOU
>PEOPLE HAVE HELPED ME BEFORE,MAY G-D BLESS YOU!PLEASE HELP ME AGAIN TO
>BECOME A PERL PROGRAMMER,.
DON'T SHOUT! Settle down. Try using perl -w when testing scripts. You
should have gotten a syntax errror for the bareword 'answer' in your elsif
statement which should have been a clue to change it to the variable
$answer.
There is also a common grammar error ("your missing" should be the
contraction "you're missing").
If you type 'perldoc -f chomp' and 'perldoc -f chop' in your shell, you
will see that chop, simply chops the last character in a string and chomp
limits itself to chopping trailing newlines or whatever is set in $/.
--
David Efflandt efflandt@xnet.com http://www.xnet.com/~efflandt/
http://www.de-srv.com/ http://cgi-help.virtualave.net/
------------------------------
Date: Tue, 31 Aug 1999 21:04:26 -0700
From: Peter Ziatek <pziatek@sgi.com>
Subject: Re: example,beginner,if,elsif,else
Message-Id: <37CCA5CA.DD80A111@sgi.com>
Ben Horowitz wrote:
>
> am learning perl from a book,so,it gives an example you have to do,.to
> modify tickets3,to give the user a choice,of two movies,it should ask which
> movie the user wants to see, and then confirm that choice,.
>
> THIS IS THE PROGRAM TICKETS3,
> AN if... elsif... else statement,
> print 'would you like to see the 11.00am showing of caper fear?';
> $answer = <>;
> chomp $answer;
> if ($answer eq 'yes') {
> print"that will be \8.50 please.\n";}
> elsif(answer eq 'no'){print "okay but your missing a great movie\n";}
> else{print"i"m sorry,i didn't understand that\n";}
you were missing the the '$' in front of the word answer on the elsif
if ($answer eq 'yes')
{
print "that will be \8.50 please.\n";
}
elsif($answer eq 'no')
{
print "okay but your missing a great movie\n";
}
else
{
print "i'm sorry,i didn't understand that\n";
}
> I TRIED TO USE THE ELSIF ,IF THING TO MAKE IT CHOOSE BETWEEN TWO CHOICES
> ,BUT IT NEVER WORKS ,IT ALWAYS GOES TO ONE CHOICE,AM A REAL NEWBIE ,PLEASE
> CAN SOMEONE HELP ME? 1) I ALSO DON'T UNDERSTAND WHAT THE DIFFRENCE
> BETWEEN,CHOMP AND CHOP,AND WHATS ITS PURPOSE? 2)THANKS A MILLION,.YOU
> PEOPLE HAVE HELPED ME BEFORE,MAY G-D BLESS YOU!PLEASE HELP ME AGAIN TO
> BECOME A PERL PROGRAMMER,.
chop - Chops off the last character of a string and returns the
character chopped. It's used primarily to remove the newline from the
end of an input record
chomp - This is a slightly safer version of chop (see below). It removes
any line ending that corresponds to the current value of $/ (also known
as $INPUT_RECORD_SEPARATOR in the English module). It returns the number
of characters removed. It's often used to remove the newline from the
end of an input record when you're worried that the final record may be
missing its newline.
you can always do a man -k KEYWORD (where KEYWORD is something your
searching for)
this will return a list of man pages that will explain the purpose and
function of the KEYWORD
example: man -k chomp
would find all pages that have a reference to chomp...
------------------------------
Date: Wed, 01 Sep 1999 03:00:52 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: gethosybyaddr
Message-Id: <EF0z3.185$qP5.8106@nsw.nnrp.telstra.net>
In article <Pine.LNX.4.04.9908311455120.1730-100000@admin.f-tech.net>,
Paul Farber <farber@admin.f-tech.net> writes:
> Can anyone spare a snippet of code that will get the hostname from an IP
> address? I looked in the camel book but the book dosen't really cover
> ADDRTYPE.. and the function will not work without it. So far I have:
>
> $hn=gethostbyaddr("207.44.65.67",AF_INET); # pg 350
That is not the address gethostbyaddr expects.
You probably want to read the Socket man page, and possibly the
perlipc man page:
# man Socket
# man perlipc
Martien
--
Martien Verbruggen |
Interactive Media Division | Failure is not an option. It comes
Commercial Dynamics Pty. Ltd. | bundled with your Microsoft product.
NSW, Australia |
------------------------------
Date: Wed, 01 Sep 1999 04:48:24 GMT
From: posting.account@lynxview.com (William Herrera)
Subject: Re: gethosybyaddr
Message-Id: <37ccaf70.253032262@news.rmi.net>
On Tue, 31 Aug 1999 15:00:05 -0400, Paul Farber <farber@admin.f-tech.net>
wrote:
>Can anyone spare a snippet of code that will get the hostname from an IP
>address? I looked in the camel book but the book dosen't really cover
>ADDRTYPE.. and the function will not work without it. So far I have:
>
>$hn=gethostbyaddr("207.44.65.67",AF_INET); # pg 350
>print("Checking: $hn\n");
>
>but it dosen't print anything out. The book also says that in scalar from
>the only returned value is the hostname... I get zilch.
read perlfunc. Then try:
perl -e "use Socket; print(scalar gethostbyaddr (inet_aton('192.168.1.1'),
AF_INET), 'with errno ', $?);"
---
The above from: address is spamblocked. Use wherrera (at) lynxview (dot) com for the reply address.
------------------------------
Date: Wed, 01 Sep 1999 04:55:55 GMT
From: "Leonid A. Elbert" <larc@writeme.com>
Subject: How to read webpages and post HTML forms with PERL
Message-Id: <vl2z3.11573$r92.135822@news2.rdc1.on.home.com>
Hi,
Can anybody give me an advice how to make a script that
1) connects to a webserver and read through the contents of a html page
2) posts a HTML form to a webserver
(All this without using a browser, of course.)
Thank you in advance for your reply.
SIncerely,
Leonid.
------------------------------
Date: Wed, 01 Sep 1999 03:05:46 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: is the mtime time between date1 and date2?
Message-Id: <eK0z3.188$qP5.8106@nsw.nnrp.telstra.net>
In article <MPG.1234dc1462531a19989ee7@nntp.hpl.hp.com>,
lr@hpl.hp.com (Larry Rosler) writes:
>> print "yeppers\n", if ( $x < $mtime && $mtime > $y );
>
> Small logic fluff in there. :-)
D'oH!! :)
>> Note that the mtime may not be meaningful or available on your system.
>
> Are there any such systems? I know there are issues about ctime, but
> mtime?
Neither do I, but then, I am not familiar with all the systems perl
runs on, and I do not want to read all the platform notes of all the
platforms :)
Martien
--
Martien Verbruggen |
Interactive Media Division |
Commercial Dynamics Pty. Ltd. | What's another word for Thesaurus?
NSW, Australia |
------------------------------
Date: Wed, 01 Sep 1999 03:12:22 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: perl equivalent of a Unix command line sort?
Message-Id: <qQ0z3.191$qP5.8106@nsw.nnrp.telstra.net>
In article <MPG.1234e12d95d5d449989ee8@nntp.hpl.hp.com>,
lr@hpl.hp.com (Larry Rosler) writes:
[Thanks to Uri and you for your article on sorting IP addresses, very
useful for many things, not just IP addresses :)]
> It 'works' rather better than I expected, in fact.
>
> Benchmark: timing 1 iterations of Naive, Packed...
> Naive: 35 wallclock secs (35.26 usr + 0.00 sys = 35.26 CPU)
> Packed: 11 wallclock secs (10.88 usr + 0.00 sys = 10.88 CPU)
That's a lot better than I expected as well. I often use the above
approach for our local hosts databases (Hey! I just demonstrated a use
for Perl that has _nothing_ to do with the web! [implicit grin]), but
have never actually looked at speed comparisons.
Martien
--
Martien Verbruggen |
Interactive Media Division | I'm just very selective about what I
Commercial Dynamics Pty. Ltd. | accept as reality - Calvin
NSW, Australia |
------------------------------
Date: 31 Aug 1999 23:20:15 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: perl equivalent of a Unix command line sort?
Message-Id: <x7aer7uxlb.fsf@home.sysarch.com>
>>>>> "MV" == Martien Verbruggen <mgjv@comdyn.com.au> writes:
MV> In article <MPG.1234e12d95d5d449989ee8@nntp.hpl.hp.com>,
MV> lr@hpl.hp.com (Larry Rosler) writes:
MV> [Thanks to Uri and you for your article on sorting IP addresses, very
MV> useful for many things, not just IP addresses :)]
you're welcome.
>> Benchmark: timing 1 iterations of Naive, Packed...
>> Naive: 35 wallclock secs (35.26 usr + 0.00 sys = 35.26 CPU)
>> Packed: 11 wallclock secs (10.88 usr + 0.00 sys = 10.88 CPU)
MV> That's a lot better than I expected as well. I often use the above
MV> approach for our local hosts databases (Hey! I just demonstrated a use
MV> for Perl that has _nothing_ to do with the web! [implicit grin]), but
MV> have never actually looked at speed comparisons.
i never saw the data set size for that benchmark. the difference should
get much better as the size grows since the inet_aton calls will be in
O(N*LogN) while the pack/unpack will be O(N). at small set sizes the
slowness of pack/unpack (compared to inet_aton) will show up. this is a
critical point in the paper. the larger overhead of our sort is only
saved with larger data sets. i am doing a sort on a very short (5-10
elements) set with a sort compare code containing a hash dereference and
numeric compare. that is the best choice for that problem.
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
uri@sysarch.com --------------------------- Perl, Internet, UNIX Consulting
Have Perl, Will Travel ----------------------------- http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
"F**king Windows 98", said the general in South Park before shooting Bill.
------------------------------
Date: Tue, 31 Aug 1999 20:42:44 -0700
From: moseley@best.com (Bill Moseley)
Subject: Re: Simulating Carriage Returns
Message-Id: <MPG.1236408d494ff4559896e3@nntp1.ba.best.com>
Stone Cold (paulm@dirigo.com) seems to say...
> Is there a way to simulate a carriage return in perl when calling an
> external DOS command.
Yes, but that's not your problem. (But, you can pipe open a program and
feed it whatever you like).
> For example, I'm pulling the system date from my
> machine by doing the following:
>
> $now=`date`;
> ($junk1,$junk2,$junk3,$junk4,$current) = split(/\s+/,$now);
> print $current;
> exit 0;
Oh. If you want the date use the built-in localtime(); perlfaq4 has a
bunch of stuff on dates.
> Because it gives other info as well, I'm splitting on the other
> stuff to not see it.
In general, try this:
> ($current) = (split(/\s+/,$now))[4];
> Does anyone know what I can do to correct this?
Yes, use another method to get your dates.
--
Bill Moseley mailto:moseley@best.com
pls note the one line sig, not counting this one.
------------------------------
Date: Wed, 01 Sep 1999 02:47:53 GMT
From: Lee.Lindley@bigfoot.com
Subject: Re: Sockets and Threads
Message-Id: <7qi44n$n4j$1@nnrp1.deja.com>
In article <x3yaer7x6je.fsf@tigre.matrox.com>,
Ala Qumsieh <aqumsieh@matrox.com> wrote:
>
> "Alex R.M. Turner" <musicmaker@armt.yi.org> writes:
>
> > Forking is all very well, but from what I've read, having each of
the
> > forked processes communicate with the parent, i.e. use the same
variable
> > set is a nightmare. Is there an easy way to have child processes
use
> > variable sets from the parent? If so, how does one do it. Most of
the
>
> It depends. Do these variables change all the time or are they fixed?
> Are children allowed to modify those variables?
>
> If they are fixed, then just pass them once to each child when it is
> created. If not, then a more complicated approach is needed.
>
> One way would be to send the children the references to those
> variables, and the children can look them up directly from memory. Of
> course this has a potential concurrency problem where more than one
> child (and possibly the parent) will attempt to read/write to the
> variable. In that case you need to be using semaphores which slightly
> complicates your design.
>
> Or maybe each child would send a request to the parent, and then the
> parent will handle those requests, giving each child its unique time
> to access the variable. But this is essentially the same as using
> semaphores.
>
> No one said IPC was elegant :)
>
> And, chapters 12 and 13 of the Panther might prove useful here.
>
> > stuff I've seen looks pretty gruesome, and I would prefer something
beta
> > like threads with which I've worked in Java at least.
>
> You can compile Perl to have thread support. It is still in beta
> though, so beware.
>
> > I also discovered the select() statement last night, which looks
like it
> > might help me build a sensible polling loop.
>
> Sure thing. You can't do anything useful without select(). Let me
> suggest that you look into using the IO::Select module (part of the
> standard distribution). It's simply an OO interface to the select()
> system call. This module made my life much easier several times. I
> recommend using it.
>
> HTH,
> --Ala
>
>
--
// Lee.Lindley@Bigfoot.com
// Be nice. It isn't that hard to do and it
// makes people happy.
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Wed, 01 Sep 1999 03:16:04 GMT
From: Lee.Lindley@bigfoot.com
Subject: Re: Sockets and Threads
Message-Id: <7qi5pd$oc3$1@nnrp1.deja.com>
In article <x3yaer7x6je.fsf@tigre.matrox.com>,
Ala Qumsieh <aqumsieh@matrox.com> wrote:
>
> "Alex R.M. Turner" <musicmaker@armt.yi.org> writes:
>
> > Forking is all very well, but from what I've read, having each of
the
> > forked processes communicate with the parent, i.e. use the same
variable
> > set is a nightmare. Is there an easy way to have child processes
use
> > variable sets from the parent? If so, how does one do it. Most of
the
[snip]
> One way would be to send the children the references to those
> variables, and the children can look them up directly from memory. Of
> course this has a potential concurrency problem where more than one
> child (and possibly the parent) will attempt to read/write to the
> variable. In that case you need to be using semaphores which slightly
> complicates your design.
[snip]
Huh? Do you mean shared memory? You can use IPC::Shareable and create
a tied hash (or array or scalar) to the shared memory (if the
OS supports it), but you cannot directly access regular memory in
another process (at least not in any OS with which I have any
experience).
P.S.
Sorry about the worthless quoted-text-only post that preceeded
this one. I'm in an unfamiliar environement.
--
// Lee.Lindley@Bigfoot.com
// Be nice. It isn't that hard to do and it
// makes people happy.
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Tue, 31 Aug 1999 23:34:52 -0400
From: gremlin <gremlin_NO_SPAM_@ix.netcom.com>
To: Matt Curtin <cmcurtin@interhack.net>
Subject: Re: SSN format
Message-Id: <37CC9EDC.98E9B186@ix.netcom.com>
Talk about an uphill battle! I agree that the use of SSN's has become
so prolific that it makes me want to hurl. Ironically, I believe that
people were terrified of just such a thing happening when the concept
was first brought forth. Its not like they just started using at and
then, as an afterthought said, "Hey, maybe this isn't a good idea?"
They knew! As for changing it, it'll never happen. I hope it does, but
it'll never happen. (Well, I guess it COULD happen if the law(s) were
enforced). What are the odds?
Mike
Matt Curtin wrote:
>
> >>>>> On Wed, 25 Aug 1999 16:35:44 -0400,
> "Blair Chesnut" <blair_chesnut@ncsu.edu> said:
>
> Blair> What's an "efficient" way to format an integer into an SSN
> Blair> string? For example, 12345 -> "000-01-2345".
>
> I know that you're probably the wrong person to whom to complain, but
> I'm going to do it anyway, especially since I see that you've gotten
> the information you need already. :-)
>
> Unless you're the social security administration, do not use social
> security numbers; you have no business doing so. Federally funded
> universities that do this might even be breaking the law by using SSNs
> as identifiers. (I recognize that you could be writing a program that
> uses them legitimately, i.e., for handling of tax credits for
> students--the IRS is really confusing this SSN-is-not-an-identifier
> business, but universities are very sloppy about this in general, so
> the chance that it's illegitimate use seems much greater.)
>
> http://www.faqs.org/faqs/privacy/ssn-faq/
>
> Don't ignore this advice because you work at a university where SSNs
> are used everywhere. Complain to your management that SSNs are used
> as identifiers. The university is taking a huge liability risk using
> these infernal numbers. Students are getting wise to this kind of
> thing and are pressuring university administrations to deal with it
> and quit invading their privacy needlessly. Ohio State has a student
> group trying to eliminate (to whatever extent legally possible) SSN
> use at OSU: http://www.osu.edu/students/privacy/.
>
> --
> Matt Curtin cmcurtin@interhack.net http://www.interhack.net/people/cmcurtin/
--
-----------------------------------------------------
To reply to me via email, remove the "__NO_SPAM__" in
the header email address.
-----------------------------------------------------
------------------------------
Date: Tue, 31 Aug 1999 20:33:03 -0700
From: moseley@best.com (Bill Moseley)
Subject: Re: subtraction error
Message-Id: <MPG.12363e472d4abeb9896e2@nntp1.ba.best.com>
hojo (i_tel@my-deja.com) seems to say...
> Trans Amount $curbal
> -59.75 -9.74
> 9.74 -1.77635683940025e-15 (should be 0)
>
> I would call this a bug. Has anybody run into/fixed this problem?
Does that amount get refunded by check or cash?
Check out the first question in perlfaq4 and see if that helps.
--
Bill Moseley mailto:moseley@best.com
pls note the one line sig, not counting this one.
------------------------------
Date: Tue, 31 Aug 1999 19:39:02 -0700
From: Peter Ziatek <pziatek@sgi.com>
Subject: tied hash
Message-Id: <37CC91C6.9FD64E1F@sgi.com>
How do I delete a record in a tied hash?
When I try delete "$DB->{$key}{$field};" it doesn't delete it. I don't
even get an error. I read in the camel book and it says it can't
guarantee that it the delete function will work on a tied hash.
Thanks in advance
--
Peter Ziatek
pziatek@sgi.com
Network Analyst
SGI
------------------------------
Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 1 Jul 99)
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" from
almanac@ruby.oce.orst.edu. The real FAQ, as it appeared last in the
newsgroup, can be retrieved with the request "send perl-users FAQ" from
almanac@ruby.oce.orst.edu. 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" from
almanac@ruby.oce.orst.edu.
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 V9 Issue 692
*************************************