[6451] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 76 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Mar 8 20:07:15 1997

Date: Sat, 8 Mar 97 17:00:20 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sat, 8 Mar 1997     Volume: 8 Number: 76

Today's topics:
     Re: 10 commandments (was re: Which one is the best (pat <dbenhur@egames.com>
     Re: Alphabetical Order (Michael McMillan)
     Re: Basic $ENV questions (I R A Aggie)
     Re: Basic $ENV questions (Michael McMillan)
     Re: Can you create file on the fly with perl? (Christopher Masto)
     Re: Creating NonExisting File with Perl (Michael McMillan)
     Re: Field Separators <fawcett@nynexst.com>
     Re: Filehandles and subroutines <billc@tibinc.com>
     Re: Filehandles and subroutines <tchrist@mox.perl.com>
     Re: Grabbing text of web pages using perl (I R A Aggie)
     Re: Help! Simple Question: Error 501: "Not Supported" (Tad McClellan)
     Looking for non-Unix Perl book <buehner@pfaffenhofen.netsurf.de>
     Re: Looking for non-Unix Perl book <tchrist@mox.perl.com>
     Re: Looking for non-Unix Perl book (Nathan V. Patwardhan)
     Re: Perl Sockets support on IRIX ? (I R A Aggie)
     Re: Possible bug in regular expression form /\d{x,x}/ <tchrist@mox.perl.com>
     Re: RAND/SRAND query (Abigail)
     Re: Reading from a file in an array arbitrary ???? <merlyn@stonehenge.com>
     Re: Regex searches in all files (or selected files) in  <tchrist@mox.perl.com>
     Re: Regex searches in all files (or selected files) in  (Nathan V. Patwardhan)
     Re: Regular Expression (Abigail)
     Re: Socket timeout implementation on PERL5/Win32 withou (Gary)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Fri, 07 Mar 1997 22:35:06 -0800
From: Devin Ben-Hur <dbenhur@egames.com>
Subject: Re: 10 commandments (was re: Which one is the best (pattern matching))
Message-Id: <3321089A.24BB@egames.com>

Todd Hoff wrote:
> Mike Heins wrote:
> > Todd Hoff (tmh@possibility.com) wrote:
> > : Devin Ben-Hur wrote:
> > : > 11) Thou shall use use strict;
> > : Jeeze, might as well start using C++ for everything again.
> > : Why turn perl into the no fun language?
> > That I disagree with -- I find it more fun to use strict.  Perhaps you
> > like debugging better than I do, though. 8-)
> 
> Nope, code usually works the first time. Not much debugging
> needed.

OK, for Todd, we'll change it to:
  11) Thou shalt use use strict on any code which doesn't 
      work the first time.

--
Devin Ben-Hur      <dbenhur@egames.com>
eGames.com, Inc.   http://www.egames.com/
eMarketing, Inc.   http://www.emarket.com/
"Sometimes you just have to step in it and see if it stinks"  O-
    -- Sonia Orin Lyris




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

Date: 8 Mar 1997 23:20:03 GMT
From: muse@news.vivanet.com (Michael McMillan)
Subject: Re: Alphabetical Order
Message-Id: <5fss73$l36$3@news>

I heard Joel Earl (earl@shadowfax.rchland.ibm.com) babbling:
:=> In article <331F37AA.3677@bangor.ac.uk> "G.Cheers" <mau006@bangor.ac.uk> writes:
:=> > if contents of $sitename have initial letter = "a"
:=> > ^^^^^^^^^^^^^^^^^^^^^^     ^^^^^^^^^^^^^^^^^^
:=> >    can do this bit!        can't do this bit!
:=> 
:=> look up "substr" in the man pages
:=> -- 

didn't get the whole original post, but:

	($sitename =~ /^aA/) && <command>;

or

	if ($sitename =~ /^aA/) {command;}

should work.

--M
-- 
+-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+-=-=-=-=-=-=-=-=-=-=-=-=-+
| Michael McMillan         e-mail us        |       ~~|~~~|~~~\       |
| Technical Director          at:           |         |   |___/       |
| Chicago, Illinois   ipi@internetpros.com  |       __|___|_          |
| (312)432-1665 Voice   (312)432-0022 Fax   | Internet  Professionals |
+-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+-=-=-=-=-=-=-=-=-=-=-=-=-+


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

Date: Wed, 05 Mar 1997 15:21:39 -0500
From: fl_aggie@hotmail.com (I R A Aggie)
Subject: Re: Basic $ENV questions
Message-Id: <fl_aggie-ya02408000R0503971521390001@news.fsu.edu>

In article <5fkipd$6nc@news.cyberenet.net>, ebabin@cyberenet.net (Eddie
Babin) wrote:

+ I don't know why I can't get all ( or any) of the enviroment
+ settings written to a file.  The only fields written are the
+ date and the REMOTE_ADDR.  I've accessed the page through
+ several different servers with the same result.  Any help
+ would be appreciated.

Uh, you can't get blood from a stone? If it isn't set, you can't
get it. Here's a somewhat useful (useless?) CGI script:

#!/usr/bin/perl -- -*-perl-*-
print "Content-Type text/html\n\n<HTML>
<HEAD>
<TITLE>Environmental Variables in CGI</TITLE>
</HEAD>
<BODY>
<strong>Variable</strong>:<em>Value</em><p>
";
foreach $key (sort keys %ENV){
    print "<strong>$key</strong>:<em>$ENV{$key}</em><br>";
}
print "</body>\n";

----

In theory, it should print out the entire %ENV variable in a nice
format. Inspect the output to verify if things are being set the
way you think they are.

Many of the list you made will NOT be available, like REMOTE_IDENT.
You realize that HTTP_USER_AGENT is sometimes lied to, like Internet
Explorer identifies itself as Mozilla...

James

-- 
Consulting Minster for Consultants, DNRC

To cure your perl CGI problems, please look at:
<url:http://www.perl.com/perl/faq/idiots-guide.html>


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

Date: 8 Mar 1997 23:15:52 GMT
From: muse@news.vivanet.com (Michael McMillan)
Subject: Re: Basic $ENV questions
Message-Id: <5fsrv8$l36$2@news>

I heard Eddie Babin (ebabin@cyberenet.net) babbling:
:=> Nathan V. Patwardhan (nvp@shore.net) wrote:
:=> : Eddie Babin (ebabin@cyberenet.net) wrote:
:=> : : Thanks for your help.  This gave some of the environment variables.
:=> : : How can I access the rest?
:=> : That *was* all the environment variables.  Which others were you
:=> : looking for?
:=> I guess I'm mistaken but I've seen references to the following which I
:=> also thought were environment variables:
:=> 
:=> HTTP_PROXY_CONNECTION 
:=> HTTP_REFERER 
:=> HTTP_USER_AGENT 
:=> HTTP_CACHE_CONTROL
:=> HTTP_X_FORWARDED_FOR
:=> HTTP_VIA
:=> PATH 
:=> QUERY_STRING
:=> REMOTE_ADDR 
:=> REMOTE_HOST 
:=> REQUEST_METHOD 
:=> SCRIPT_NAME 
:=> SERVER_ADMIN 
:=> SERVER_NAME 
:=> SERVER_PORT 
:=> SERVER_PROTOCOL
:=> 
:=> 
:=> Is there anyway to retrieve these values?  Thanks again for your help.
:=> 

Most if not all of these $ENV's are passed from the incoming STDIN fork 
*assuming your perl script is doing something like:

	read(STDIN,$buffer,$ENV{'CONTENT_LENGTH'});

or some other perl function that uses an $ENV variable*.  Easiest way to 
access them would probably be through STDIN reading.

--M
-- 
+-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+-=-=-=-=-=-=-=-=-=-=-=-=-+
| Michael McMillan         e-mail us        |       ~~|~~~|~~~\       |
| Technical Director          at:           |         |   |___/       |
| Chicago, Illinois   ipi@internetpros.com  |       __|___|_          |
| (312)432-1665 Voice   (312)432-0022 Fax   | Internet  Professionals |
+-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+-=-=-=-=-=-=-=-=-=-=-=-=-+


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

Date: 8 Mar 1997 22:44:53 GMT
From: exidor@nimbus.superior.net (Christopher Masto)
Subject: Re: Can you create file on the fly with perl?
Message-Id: <5fsq55$jjt@news.webspan.net>

In article <JASON.97Mar6115349@wisteria.cs.odu.edu>,
Jason C Austin <austin@visi.net> wrote:
>In article <5fes7m$e6f@news.webspan.net> exidor@nimbus.superior.net (Christopher Masto) writes:
>=> In article <331A3BC8.FB37ADB@uconect.net>,
>=> Bill Kuhn  <wkuhn@uconect.net> wrote:
>=> >> >system("touch $filename")
>=> >> 
>=> >> $filename = "harmless; rm -rf /";
>=> >
>=> >Are you telling me that whatever I pass to system() will be executed, so
>=> >I shouldn't pass it anything that I don't want executed?  It will do
>=> >exactly what I ask it to?
>=> 
>=> Actually, I'm pointing out that the use of the one-argument system()
>=> is very dangerous.  Consider what could happen if the user were
>=> prompted for that filename.  It would do exactly what THEY ask it to.
>=> 
>=> There is the option of system("touch", $filename), which avoids the
>=> /bin/sh, and this this particular problem.
>=> 
>=> You may be aware of this, but the gentleman who asked the original
>=> question may not be, and since we don't know whence he gets his
>=> filename, caution is indicated.
>
>	Not a big deal unless the program is setuid.  Without setuid,
>they can't damage anything they couldn't damage without the scripts.
>Could possible be some danger with CGI is you are unwise and set some
>file ownership to the CGI uid.
>
>	Despite claim I've heard that perl is an exception, it's
>always a bad idea to make a script setuid.  You've just have shown one
>reason why.

Well, at least we have taint checks.

splat:~$ perl -Te '$filename = $ARGV[0]; open FILE, ">$filename";' testing
Insecure dependency in open while running with -T switch at -e line 1.

I don't know about you, but I write a lot of perl software that has to
run setuid.  From CGI scripts that allow people to change their
passwords, to the RADIUS modules I'll be releasing next week.  Perl's
"scripts" aren't inherently less secure than C programs - you have to
be careful no matter what language is used.
-- 
Our unification of thought is more powerful a weapon than any fleet or
army on earth. We are one people. With one will. One resolve. One
cause. Our enemies shall talk themselves to death, and we will bury
them with their own confusion. We shall prevail!


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

Date: 8 Mar 1997 23:07:46 GMT
From: muse@news.vivanet.com (Michael McMillan)
Subject: Re: Creating NonExisting File with Perl
Message-Id: <5fsrg2$l36$1@news>

I heard $Bill Luebkert (dbe@wgn.net) babbling:
:=> Arnout Symoens wrote:
:=> > Following problem :
:=> > 
:=> > I'm writing a little CGI in perl (works perfectly..). But one of the
:=> > things I need is to create a none existing new file (a new one for
:=> > each new user). I can't do this with the open command, which will die
:=> > when I open a none existing file..
:=> > Ok, how do I create a new file from within perl ? It's running on an
:=> > UNIX server...Would this mean I have to send an UNIX command like ? If
:=> > yes, what command ? I can't find one..
:=> > 
:=> > Anyone can help me out with this one...Source (small) wouldl be
:=> > appreciated..

system("touch $filename");

--M
-- 
+-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+-=-=-=-=-=-=-=-=-=-=-=-=-+
| Michael McMillan         e-mail us        |       ~~|~~~|~~~\       |
| Technical Director          at:           |         |   |___/       |
| Chicago, Illinois   ipi@internetpros.com  |       __|___|_          |
| (312)432-1665 Voice   (312)432-0022 Fax   | Internet  Professionals |
+-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-+-=-=-=-=-=-=-=-=-=-=-=-=-+


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

Date: 08 Mar 1997 14:09:32 -0500
From: Tom Fawcett <fawcett@nynexst.com>
Subject: Re: Field Separators
Message-Id: <8jiv322ob7.fsf@nynexst.com>

Terry Robison <trobison@erols.com> writes:
> I have data in the form:
> 
> "248347554","90834598","This is a comment, sometime with multiple commas
> inside","dategd","4545","transaction type","7459087"~
> 
> I am trying to set the FS equal to ",", including the quotes.
> 
> I set FS="\",\"" and print FS. It appears to be ",", but fields break on
> a single ".
> 
> Can I set a multiple character FS?

Sure, try this:

use English;
$INPUT_RECORD_SEPARATOR = '","';
while (<DATA>) {  
   chomp;
   print "Read: $_\n";
}
__END__
"248347554","90834598","This is a comment, sometime with multiple commas inside","dategd","4545","transaction type","7459087"


Note that you'll have to clean up beginning and ending quotes.

-Tom


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

Date: Sat, 08 Mar 1997 15:59:47 -0500
From: Bill Cowan <billc@tibinc.com>
To: tph@rmii.com
Subject: Re: Filehandles and subroutines
Message-Id: <3321D343.1DDD@tibinc.com>

Tom Harrington wrote:
> 
> How can I return a filehandle from a subroutine?
> 
> I have a subroutine which does this:
> 
>         open(LOGFILE,">$logfile_name");
> 
> I want to be able to use the subroutine like this (or something similar):
> 
>         $filehandle = &openlog(.....);
> 
> So that $filehandle will be an indirect file handle, which would
> allow me to have statements like this in the calling function:
> 
>         print $filehandle "Log timestamp: ",$date,"\n";
> 
> I've tried just returning the filehandle that open() creates, but it
> doesn't work, and I'm not sure why:
> 
>         return LOGFILE;
> 
> With this and a few other semi-random things I've tried, perl -w
> tells me that the filehandle was never opened when I try to print
> from the calling function.
> 
> --
> Tom Harrington ------- tph@rmii.com ------- http://rainbow.rmii.com/~tph
>   "Boy, you look tough in your black leather jacket! Bring your head
>            closer, I'll be the first to smack it!" -Fishbone
> -> Fractal Kit:  http://rainbow.rmii.com/~tph/fractalkit/fractal.html <-

Page 248 of Camel II book on "Filehandle References" for passing
filehandles to function, i.e. &openlog(\*LOGFILE).

To return the filehandle (vs as parameter), try returning as a reference
to the filehandle.  Simple test out of debugger:

  DB<43> $FileHandleRef = \*STDOUT; # as if returned from function.

  DB<44> print $FileHandleRef "Hello world\n";
Hello world

  DB<45> print ${FileHandleRef} "Hello world\n";
Hello world

I am little surprised that <44> worked without dereferencing. 

-- Bill
-----------------------------------------------------------------------
Bill Cowan <billc@tibinc.com>    Voice:919-490-0034   Fax:919-490-0143
Tiburon, Inc./3333 Durham-Chapel Hill Blvd Suite E-100/Durham, NC 27707


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

Date: 8 Mar 1997 23:56:24 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Filehandles and subroutines
Message-Id: <5fsub8$n55$2@csnews.cs.colorado.edu>

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

In comp.lang.perl.misc, 
    billc@tibinc.com writes:
:  DB<44> print $FileHandleRef "Hello world\n";
:Hello world

:I am little surprised that <44> worked without dereferencing. 

See the daggered footnote on page 245.

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com
I believe in the waterbed theory of linguistics.
If you push down here, it pops up there.
        -- <1993Jan20.181244.8680@netlabs.com>


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

Date: Wed, 05 Mar 1997 09:55:47 -0500
From: fl_aggie@hotmail.com (I R A Aggie)
Subject: Re: Grabbing text of web pages using perl
Message-Id: <fl_aggie-ya02408000R0503970955470001@news.fsu.edu>

In article <autopen-0403971542190001@l72.d22.quake.net>, autopen@quake.net
(Laurel Shimer) wrote:

+ > Timothy B. Hutchinson  wrote:
+ > : Is there a relatively easy way -- or a publicly available script --

How about: ridiculously easy? your dog could do it. :) Your dog may have
done it. :> Consult your dog!

+ > : which would allow me to grab the text of a web page and append it 
+ > : to a file?  In other words, the input for a filehandle would be the
+ > : web page -- is this possible?

+ I have the impression it might be a CPAN thing. 
+ Does that ring a bell w/ anyone else?

Yep. Try 'perldoc LWP::Simple'. If you don't have LWP, then get it from
your friendly neighborhood CPAN. Here's what 'perldoc LWP::Simple' told
me:
          get($url)
             This function will get the document identified by the
             given URL.  The get() function will return the document
             if successful or 'undef' if it fails.  The $url argument
             can be either a simple string or a reference to a
             URI::URL object.

So you might have something like:

use LWP::Simple;
@file=get('http://some.web.site/some/particular/web/page.html');

# append the results of the http getting to a file here, which is left
# as an exercise for the student... ;)

James

-- 
Consulting Minster for Consultants, DNRC

To cure your perl CGI problems, please look at:
<url:http://www.perl.com/perl/faq/idiots-guide.html>


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

Date: Sat, 8 Mar 1997 13:57:18 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Help! Simple Question: Error 501: "Not Supported"
Message-Id: <uagsf5.s62.ln@localhost>

--- (bailey766@aol.com) wrote:
: I have the Perl interpreter installed on my NT 4.0 server running IIS
: 3.0.  I wrote a simple Perl script that simply writes a string to a
: file when it is run (so that I know it was executed).  I put together
: a simple HTML file with a submit button that runs the Perl program
: using the syntax:

: <FORM METHOD=POST ACTION="filetest.pl">
: <INPUT TYPE="SUBMIT">
: </FORM>

: etc etc.

: When I load this page from my CLIENT machine, a Win95 box with
: Internet Explorer 3.0, I get "Error 501- Not Supported".  If I load it
                                ^^^^^^^^^^^^^^^^^^^^^^^^

That is not a perl error message.

Looks like some kind of HTTP message or something...


: using IE3.0 locally, from the SERVER, it thinks I want to download the
: file.

: Can anyone help out?  Also, can anyone tell me where I can look up
  ^^^^^^^^^^^^^^^^^^^

Not suprisingly, you can find help for WWW questions in the
WWW newsgroups:

comp.infosystems.www.advocacy
comp.infosystems.www.announce
comp.infosystems.www.authoring.cgi
comp.infosystems.www.authoring.html
comp.infosystems.www.authoring.images
comp.infosystems.www.authoring.misc
comp.infosystems.www.browsers.mac
comp.infosystems.www.browsers.misc
comp.infosystems.www.browsers.ms-windows
comp.infosystems.www.browsers.x
comp.infosystems.www.misc
comp.infosystems.www.servers.mac
comp.infosystems.www.servers.misc
comp.infosystems.www.servers.ms-windows
comp.infosystems.www.servers.unix
comp.infosystems.www.providers
comp.infosystems.www
comp.infosystems.www.users


: these error messages myself?  I waded through much of the online docs
: and could not find the error codes listed.  Is this an IE3.0 error or
: a Server error?


We wouldn't know. 

IE and servers are not perl. 

This is the perl newsgroup ya know  ;-)


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


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

Date: Sat, 08 Mar 1997 21:45:53 +0100
From: Thomas Buehner <buehner@pfaffenhofen.netsurf.de>
Subject: Looking for non-Unix Perl book
Message-Id: <VA.00000026.00fa2bf0@tbuero1>

Is there a good book / online reference for Perl 5 which does *not* look 
at Perl from the Unix side of life (Windows NT preferred)?

As a non-Unix person, it took me an hour to find the Perl command for 
deleting a file: No reference to delete, erase, remove, etc. in the 
index of any Perl book I looked at. Too many hits on a search through 
the HTML docs. Only when I asked a Unix crack, he suggested unlink.

I would appreciate any suggestions for books that do not approach Perl 5 
from the Unix perspective, be it basic or advanced, OO or non-OO, 
tutorial-style or reference.

If you think about suggesting a dozen titles, I would prefer:

 - Perl 5
 - book or online
 - reference-style or how-to-solutions-style
 - extensive descriptions (as opposed to "unlink: delete list of files."
 - examples
 - NT-specific
 - OO covered
 
Thanks,

Thomas Buehner




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

Date: 8 Mar 1997 23:53:38 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Looking for non-Unix Perl book
Message-Id: <5fsu62$n55$1@csnews.cs.colorado.edu>

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

In comp.lang.perl.misc, 
    buehner@pfaffenhofen.netsurf.de writes:
:Is there a good book / online reference for Perl 5 which does *not* look 
:at Perl from the Unix side of life (Windows NT preferred)?

No.

:As a non-Unix person, it took me an hour to find the Perl command for 
:deleting a file: No reference to delete, erase, remove, etc. in the 
:index of any Perl book I looked at. 

Boy, you must not have looked very hard.

1) The standard online reference documenting Perl functions,
   perlfunc(1), contains such things.  If you had searched for
   "delete", you would have found out about unlink:

    unlink LIST
	Deletes a list of files.  Returns the number of files 
	successfully deleted.

    Was that so hard?

2) The standard printed reference documenting Perl, the second
   edition of Programming Perl, has both delete (of files, amongst
   toher things) and remove (which says to see delete) in
   its index.  

:I would appreciate any suggestions for books that do not approach Perl 5 
:from the Unix perspective, 

Considering that both the two standard references would have readily
answered your query, I don't know what you're complaining about.

Anyway, a little bit of Unix mindset is good for any programmer's
soul.   And a bit of education never hurt anyone.  

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


    "Sometimes I wish I could put an expiration date on my quotes." --Larry Wall


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

Date: 9 Mar 1997 00:30:28 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Looking for non-Unix Perl book
Message-Id: <5ft0b4$f87@fridge-nf0.shore.net>

Thomas Buehner (buehner@pfaffenhofen.netsurf.de) wrote:

: As a non-Unix person, it took me an hour to find the Perl command for 
: deleting a file: No reference to delete, erase, remove, etc. in the 
: index of any Perl book I looked at. Too many hits on a search through 

I just looked at three Perl books (from separate publishers/authors),
and they both had "delete" (in the sense of deleting files) listed under
_f_ile in the index.  I'll venture a guess that delete (file) isn't listed
under _d_elete in the index because delete() and unlink() have unrelated
meanings ... just a guess. tho.

: I would appreciate any suggestions for books that do not approach Perl 5 
: from the Unix perspective, be it basic or advanced, OO or non-OO, 
: tutorial-style or reference.

There are several books (Perl 5 -> Unix/non-Unix) listed at
http://www.perl.com/perl in the book review section.

--
Nathan V. Patwardhan
nvp@shore.net



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

Date: Wed, 05 Mar 1997 10:29:47 -0500
From: fl_aggie@hotmail.com (I R A Aggie)
Subject: Re: Perl Sockets support on IRIX ?
Message-Id: <fl_aggie-ya02408000R0503971029470001@news.fsu.edu>

In article <jon-0403971105500001@amx11.amxdigital.com>, jon@amxdigital.com
(Jonathan Peterson) wrote:

+ So does Perl simply not support sockets on Irix, end of story?

No. Try 'perldoc socket' and take a look at the manpage, which states:

     DESCRIPTION
          This module is just a translation of the C socket.h file.
          Unlike the old mechanism of requiring a translated socket.ph
          file, this uses the h2xs program (see the Perl source
          distribution) and your native C compiler.  This means that
          it has a far more likely chance of getting the numbers
          right.  This includes all of the commonly used pound-defines
          like AF_INET, SOCK_STREAM, etc.

James

-- 
Consulting Minster for Consultants, DNRC

To cure your perl CGI problems, please look at:
<url:http://www.perl.com/perl/faq/idiots-guide.html>


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

Date: 8 Mar 1997 20:08:08 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Possible bug in regular expression form /\d{x,x}/
Message-Id: <5fsgv8$d0i$1@csnews.cs.colorado.edu>

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

In comp.lang.perl.misc, 
    ebohlman@netcom.com (Eric Bohlman) writes:
:Actually, \D...\D would be more general, since the digit string might be 
:embedded in alphabetics.

Nope, then it would fail "1234".  Saying "word boundary" is not
the sameas saying "followed and preceded by a non-digit", since
if there's nothing after it, you fail the require non-digit.

--tom

-- 
	Tom Christiansen	tchrist@jhereg.perl.com
    It won't be covered in the book.  The source code has to be useful for
    something, after all...  :-)
            --Larry Wall in <10160@jpl-devvax.JPL.NASA.GOV>


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

Date: Sat, 8 Mar 1997 19:02:12 GMT
From: abigail@ny.fnx.com (Abigail)
Subject: Re: RAND/SRAND query
Message-Id: <E6qnJo.L5s@nonexistent.com>

On Fri, 07 Mar 1997 21:50:57 -0500, Ron & Mary Stephens wrote in comp.lang.perl.misc:
++ I'm writing a script which needs to generate several random
++ integers.  Here's the problem which I hope someone will have
++ an answer to.
++ 
++ The first random number works fine.  I call it using the standard
++ srand time () seed.
++ 
++ srand;
++ $numberone = int (rand ($range) + 1);
++ 
++ How then do I call a second random number that is truly random?  So far
++ I've been using the first random number as the SRAND seed for the second
++ call, the second number for the third SRAND seed and so on.  But this
++ only results in a pattern that isn't truly random.  i.e. the first 
++ number determines the second etc.


You should only call srand once in your program (unless you know what
you are doing).

$ /usr/local/bin/perl -w
use strict;
my $range = 10;
srand (time ^ ($$ + $$ << 15));
map {print int (rand ($range) + 1), "\n";} (1 .. 10);
__END__
6
5
8
5
6
10
8
9
4
9



Abigail



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

Date: 08 Mar 1997 12:55:09 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: John Strickler <jstrick@mindspring.com>
Subject: Re: Reading from a file in an array arbitrary ????
Message-Id: <8csp26jh0i.fsf@gadget.cscaper.com>


[Even though you beat me hands down at pool Wednesday, I'll still reply... ]

>>>>> "John" == John Strickler <jstrick@mindspring.com> writes:

John> Oops. Mea culpa. This method works, but of course <F> reads in the
John> _NEXT_ whatever lines, not the
John> ones selected by the subscripts of stuff. You can populate arbitrary
John> elements of @stuff, but
John> the lines come out of $file in normal order, no matter what. Thus,

John>      @stuff[20..29] = <F> 

John> still reads in the first 10 lines.

Except....
you've just thrown away the entire rest of F.  Did you really wanna do that?

In other words, F is now at EOF, possibly ignoring tens, hundreds,
even *thousands* of lines.

The only way to read just a little at a time is to do something like:

	for (20..29) {
		$stuff[$_] = <F> or last;
	}

Scalar context is your friend.  Use scalar context.

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,495.69 collected, $182,159.85 spent; just 541 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: 8 Mar 1997 20:15:42 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Regex searches in all files (or selected files) in a directory
Message-Id: <5fshde$d0i$2@csnews.cs.colorado.edu>

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

In comp.lang.perl.misc, 
    nvp@shore.net (Nathan V. Patwardhan) writes:
:$dir = "C:\\FOO\\BAR";

Nathan, please please please please stop that.  It's "C:/foo/bar".

    =head2 Why can't I use "C:\temp\foo" in DOS paths?  What doesn't `C:\temp\foo.exe` work?

    Whoops!  You just put a tab and a formfeed into that filename!
    Remember that within double quoted strings ("like\this"), the
    backslash is an escape character.  The full list of these is
    in L<perlop/"Quote and Quote-like Operators">.  Unsurprisingly,
    you don't have a file called "c:(tab)emp(formfeed)oo" or
    "c:(tab)emp(formfeed)oo.exe" on your DOS filesystem.

    Either single-quote your strings, or (preferably) use forward slashes.
    Recent kernels from Microsoft don't care which slash you use,
    so you might as well use the one that doesn't clash with Perl --
    or the POSIX shell, ANSI C and C++, awk, Tcl, Java, or Python,
    just to mention a few.

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

    s = (char*)(long)retval;                /* ouch */
        --Larry Wall in doio.c from the perl source code


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

Date: 8 Mar 1997 21:27:36 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Regex searches in all files (or selected files) in a directory
Message-Id: <5fslk8$3k6@fridge-nf0.shore.net>

Nathan V. Patwardhan (nvp@shore.net) wrote:

: $dir = "C:\\FOO\\BAR";
: opendir(DIR, "$dir") || die("dir error: $!");
: @entries = grep(/\.txt$/, sort(readdir(DIR))); #grab only .txt, not .txty
: closedir(DIR);

Error!

It should be: C:/FOO/BAR, instead.

Tom. C. pointed out (and I agree) that $dir = "C:\\FOO\\BAR"; is an awful, 
and nasty way to declare this variable.  I'd been using this hackish
workaround with NTPerl 5.003_07, since opening a dir '/' and 'C:/' seems 
to fail, but "C:\\" seems to work.  Opening a directory '/temp', or 
'C:/TEMP' DOES work, however.  I didn't notice this problem in NTPerl 5.001m,
where I could do '/', 'C:/', and (the dreaded) "C:\\".

--
Nathan V. Patwardhan
nvp@shore.net



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

Date: Sat, 8 Mar 1997 19:05:59 GMT
From: abigail@ny.fnx.com (Abigail)
Subject: Re: Regular Expression
Message-Id: <E6qnpz.LLr@nonexistent.com>

On Sat, 08 Mar 1997 10:22:36 -0500, Charles Ng wrote in comp.lang.perl.misc:
++ What regular expression will match control-L?  I don't have a perl book
++ handy. :(

/./ :)

But if you want it to only match if there's a control-L, use:

/\cL/



Abigail



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

Date: Sat, 08 Mar 1997 21:32:00 GMT
From: gniemcew@dti.net (Gary)
Subject: Re: Socket timeout implementation on PERL5/Win32 without alarm() (since it's not implemented ) ?
Message-Id: <3321d8dc.1433150@news.alt.net>

On 8 Mar 1997 18:37:09 GMT, nvp@shore.net (Nathan V. Patwardhan)
wrote:

>: Say I am connecting to a server as a client, I create a socket, bind
>: and connect successfully, but the server sends nothing for a long
>: while. My client is of course stuck at
>
>: $var = <SOCKET>;
>
>What are you sending the server?  It might be waiting for you to send 
>something back to it, or even an additional \r\n.

My script queries multiple POP servers, it works just fine with many
(going through my list of POP accounts) but sometimes a server is down
or not responding quickly enough (even well after the connection is
established) so I want my script to bypass it and get the rest of the
work done before coming back to it. It is supposed to be run without
supervision (overnight) so ^C skip is not what I want either. 

Any ideas ?

ActiveWare does not implement alarm(), but maybe some other
implementation does ?

Thanks for responding,

Gary



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

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

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