[16928] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4340 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Sep 16 00:07:35 2000

Date: Fri, 15 Sep 2000 21:05:11 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <969077111-v9-i4340@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 15 Sep 2000     Volume: 9 Number: 4340

Today's topics:
    Re: Alternativer to SDBM? <bart.lateur@skynet.be>
        ANNOUNCE: Term::Getch v0.20 <jdb@wcoil.com>
    Re: binmode(): How is OS related with "\n"? <bart.lateur@skynet.be>
    Re: binmode(): How is OS related with "\n"? <bart.lateur@skynet.be>
        Copying Files <patrickjos@hotmail.com>
    Re: Copying Files gtown97@my-deja.com
        help please - error: Can't locate loadable object for m <zigouras@mail.med.upenn.edu>
    Re: HELP?? Perl script is not recognized in win98 ?? <bwalton@rochester.rr.com>
        how could I get a file by http path? <lucas@cplhk.com>
    Re: how could I get a file by http path? gtown97@my-deja.com
    Re: How do I sort a list of list by a certain column <ren.maddox@tivoli.com>
    Re: how to install perl in windows95? <bwalton@rochester.rr.com>
    Re: Lost libraries when upgrading from 5.005 to 5.6 <bwalton@rochester.rr.com>
    Re: Module for CGI Session Management? <timewarp@shentel.net>
    Re: Newbie - Should I learn Perl or Javascript <timewarp@shentel.net>
    Re: Password protecting a script <timewarp@shentel.net>
    Re: Question about Overloading "=" <bwalton@rochester.rr.com>
    Re: Question to the Wise - Writing Spaces <ren.maddox@tivoli.com>
    Re: Question: windows system() crash detection <jhelman@wsb.com>
    Re: Regular Expression for matching with email addresse <timewarp@shentel.net>
    Re: Segmentation Fault <bwalton@rochester.rr.com>
    Re: Shortest code for Fibonacci? <ren.maddox@tivoli.com>
    Re: Shortest code for Fibonacci? <bart.lateur@skynet.be>
    Re: Timeout while socket opened (Charles DeRykus)
        tutorial for advanced experimental regex  features? <bart.lateur@skynet.be>
        Unicode <laoxiu100@hotmail.com>
    Re: uninitialized variables <ren.maddox@tivoli.com>
    Re: uninitialized variables <ren.maddox@tivoli.com>
    Re: uninitialized variables <bwalton@rochester.rr.com>
        Variables <sammis1@hotmail.com>
    Re: Variables <bwalton@rochester.rr.com>
    Re: Variables (David Wall)
    Re: Which environment var can I use? (Eric Bohlman)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Sat, 16 Sep 2000 03:09:41 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Alternativer to SDBM?
Message-Id: <25o5ssgp0t21qgbibcj1g4jdrcqk1c1vrn@4ax.com>

Paul Leduc wrote:

>Is there an alternate DBM I can use, with the same functionality as
>SDBM, that does not have this limit?

Check out the source (and the docs) of the standard module AnyDBM_File.
The @ISA line contains the alternatives that are functionally
equivalent.

Not all are included with Perl, or they may even not exist for your
platform.

They do produce incompatible files, though. Even the file sizes for the
same data may vary a lot.

-- 
	Bart.


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

Date: 16 Sep 2000 02:33:44 GMT
From: "Josiah Bryan" <jdb@wcoil.com>
Subject: ANNOUNCE: Term::Getch v0.20
Message-Id: <8pum68$12j$0@206.230.71.38>

Greets Perlfolk,

Announcing the release of:
    Term::Getch v0.20


Recomended download URL:
    http://www.josiah.countystart.com/modules/get.pl?getch:misc


This file has also entered CPAN as:

  file: $CPAN/authors/id/J/JB/JBRYAN/Term-Getch-0.20.zip
  size: 2862 bytes
   md5: cec17837772afa2f943669025fd030cd

==================================================================

NAME

Term::Getch - A simple alternate ReadKey()-like interface for MSWin32

==================================================================

SYNOPSIS

 use Term::Getch;

 while(1) {
  my $c = getch();
   print "Input: $c\r";
 }

==================================================================

DESCRIPTION

This module is for all those Win32 users who can't get Term::ReadKey to work
with ActiveState's Perl. I don't know if anybody else can, or can't get it
to
work, but I know I had a heck of a time today trying to get Term::ReadKey to
work. So, finally, out of desperation, I hacked out this small attempt at
a portable solution to the delima. Behold, Term::Getch;

This exports a single function, getch(). Optional export is ascii(), which
returns the ASCII character code of any character passed. (getch() returns
the ASCII character as given by chr()).

getch() requires Win32::Console to be installed *_IF_* you are a MSWin32
user.
If you are not a MSWin32 user, then it will default to Term::ReadKey in an
eval() statement.

getch() is a non-blocking read call. If there are no characters waiting, it
returns
undef. Otherwise, it returns the ASCII character (on key up.)

=> NOTE

Note: This has only been tested on by the author with ActiveState on Windows
98. I'm not sure
how well this preforms on other systems. If this doesn't work on your system
and you
aren't a MS Windows user, go download Term::ReadKey and compile it for your
system. Chances
are, it will work MUCH better than this ever will. Thankyou very much. Good
day!

==================================================================

Regards,

--
Josiah Bryan
jdb@wcoil.com
Tel: 937.316.6256





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

Date: Sat, 16 Sep 2000 02:49:31 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: binmode(): How is OS related with "\n"?
Message-Id: <ukn5ss83hsdr34dufolqkhsqcs76o58lll@4ax.com>

Tim Hammerquist wrote:

>It's apparently inaccurate to say "all" open files.  However, we know
>*nix won't care one way or another because of the perldoc quote above.

No, you forget about the side effect on PC.

Text files contain CR+LF as line terminators. However, a text string in
Perl usually just ends in "\n", which is a single character (LF).
Therefore, CR+LF ("\r\n") is converted to "\n" while reading a text
file, and "\n" converted is converted to CR+LF on print to a text file.
binmode() on a handle disables this special feature. binmode() is a noop
on Unix.

Therefore: it is best to always use binmode() on binary files, even on
Unix that doesn't care. Do not unnecessarily apply binmode on a text
file, unless you want to cope with the CR+LF thing yourself,
explicitely, or are ready to accept the consequences. For example, using
binmode() on an output text file allows you to create Unix compatible
text files in Perl on PC.

-- 
	Bart.


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

Date: Sat, 16 Sep 2000 02:51:13 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: binmode(): How is OS related with "\n"?
Message-Id: <jvn5ss4f1jprj7uvjbgsvnotltre0ooonr@4ax.com>

Alan J. Flavell wrote:

>> To sum up: if it's a binary file, a common guideline is to binmode it,
>
>But how does a newbie know what a "binary file" is?

If you plan to read and use it one a byte by byte basis, without any
conversion, then it's best to treat it as a binary file.

-- 
	Bart.


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

Date: Fri, 15 Sep 2000 19:32:31 -0700
From: Patrick Connolly <patrickjos@hotmail.com>
Subject: Copying Files
Message-Id: <39C2DBBF.A7D3A993@hotmail.com>


I'm trying to develop a perlscript to copy files (on windows nt)  from
one directory to another.  The simple requirements are:
1.  The timestamp of the file must NOT be modified.
2.  There must be no "noise" output to the screen.
3.  There should be a way to verify that the copy was successful.

The problem:
1. I've tried the copy() function from File::Copy module. On windows
NT,  it modifies the timestamp to current time.
2. I've tried using  system("copy sourcefile destfile")  but it prints
out noise to the screen for every file it copies.

    Any suggestions ?

Patrick






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

Date: Sat, 16 Sep 2000 03:27:02 GMT
From: gtown97@my-deja.com
Subject: Re: Copying Files
Message-Id: <8pup9n$hi4$1@nnrp1.deja.com>

In article <39C2DBBF.A7D3A993@hotmail.com>,
  Patrick Connolly <patrickjos@hotmail.com> wrote:
>
> I'm trying to develop a perlscript to copy files (on windows nt)  from
> one directory to another.  The simple requirements are:
> 1.  The timestamp of the file must NOT be modified.
> 2.  There must be no "noise" output to the screen.
> 3.  There should be a way to verify that the copy was successful.
>
> The problem:
> 1. I've tried the copy() function from File::Copy module. On windows
> NT,  it modifies the timestamp to current time.
> 2. I've tried using  system("copy sourcefile destfile")  but it prints
> out noise to the screen for every file it copies.

If it's just a matter of copying files on NT, you may want to see NT's
copy documentation.  It's probably got something in there about making
it silent.

copy /?

Lauren
--
Call today for your copy of my latest book, "Giving off-topic answers".


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Fri, 15 Sep 2000 21:52:40 -0400
From: Nico F Zigouras <zigouras@mail.med.upenn.edu>
Subject: help please - error: Can't locate loadable object for module.
Message-Id: <Pine.OSF.4.10.10009152151590.13522-100000@dolphin.upenn.edu>

I am wondering if some one can help.  I just installed DBD::DB2 and got
this error:

Can't locate loadable object for module DBD::DB2::Constants in @INC (@INC
contains: /usr/local/lib/perl5/5.00503/sun4-solaris /usr/local/lib/perl5/5.00503
/usr/local/lib/perl5/site_perl/5.005/sun4-solaris
/usr/local/lib/perl5/site_perl/5.00
5 .) at /usr/local/lib/perl5/site_perl/5.005/sun4-solaris/DBD/DB2.pm line
25
BEGIN failed--compilation aborted at
/usr/local/lib/perl5/site_perl/5.005/sun4-s
olaris/DBD/DB2.pm line 25.
BEGIN failed--compilation aborted at -e line 1.

Does anyone have a suggestion as to what I could do?
Thanks in advance.





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

Date: Sat, 16 Sep 2000 01:17:40 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: HELP?? Perl script is not recognized in win98 ??
Message-Id: <39C2CA52.AF0A2175@rochester.rr.com>

"Altaf A. Ladhani" wrote:
 ...
>  I am facing a small problem. I have just installed Per 5.004 in my
> win98 machine. An index.html if pointing at .pl file
> 
> <FORM METHOD="post" ACTION="c:\winshare\wwwroot\cgi-bin\quote.pl">
> 
> and quote.pl looks something like this
> 
> ----------------  begin ----------------------------
> #!  c:\perl\bin\perl.exe
> 
> print("just testing the script\n");
> ---------------------------------------------------------
> 
> --------------------------  error --------------------
> HTTP Error 405
> 
> 405 Method Not Allowed
> 
> The method specified in the Request Line is not allowed for the resource
> identified by the request. Please ensure that you have the proper
> MIME type set up for the resource you are requesting.
> 
> Please contact the server's administrator if this problem persists.
> ---------------------------------------------------------
> 
> shows up. can someone please help me why is it doing this to me.
> 
> will appreciate all the help.
> 
> Altaf

You have a couple of items not right.  First, the ACTION= value in HTML
should be a URL, like
"http://www.xyz.com/path/from/server/root/to/cgi/program.pl", using
forward slashes, not backslashes.  Second, your Perl script *must* emit
a valid HTTP header, like:

    Content-type: text/html

for example.  You need to read up on CGI.  Type Perl CGI into Amazon.  I
also *strongly* recommend you use Perl's CGI module, as that will take
care of much stuff automagically and make your life much easier (by
doing things like giving you an off-line method of testing your script,
automatically sending Perl errors to the brower, etc).

Also, look over the docs for your web server, and see if they have a
test CGI script you can try.
-- 
Bob Walton


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

Date: Sat, 16 Sep 2000 10:59:25 +0800
From: "Lucas Tsoi" <lucas@cplhk.com>
Subject: how could I get a file by http path?
Message-Id: <8pung7$qpo2@imsp212.netvigator.com>

Hi how could I get a image file that by direct
http path liked http://www.domain.com/image.gif ?




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

Date: Sat, 16 Sep 2000 03:22:23 GMT
From: gtown97@my-deja.com
Subject: Re: how could I get a file by http path?
Message-Id: <8pup11$h89$1@nnrp1.deja.com>

In article <8pung7$qpo2@imsp212.netvigator.com>,
  "Lucas Tsoi" <lucas@cplhk.com> wrote:
> Hi how could I get a image file that by direct
> http path liked http://www.domain.com/image.gif ?
>

Using the LWP module, most likely.  Check out the documentation for it
by typing "perldoc LWP" into your command prompt.

Lauren
--
On vacation, away from my beloved Outlook Express, posting from Deja...


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 15 Sep 2000 19:45:42 -0500
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: How do I sort a list of list by a certain column
Message-Id: <m3d7i5cgg9.fsf@dhcp11-177.support.tivoli.com>

Malte Ubl <ubl@schaffhausen.de> writes:

> Thanks,
> 
> I figured this code should do the work, but it does nothing:
> 
> sub sort {
>  my $self   = shift;
>  my $column = shift; # the column's index
> 
>  @{$self->{DB}} = CORE::sort {
>   $a->[$column] cmp  $b->[$column]
>  } @{$self->{DB}};
> }
> 
> Hope somebody can get it right!

Change the subroutine name and it works fine.  You're running into the
prototype for CORE::sort, and I couldn't figure out how to override it.


-- 
Ren Maddox
ren@tivoli.com


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

Date: Sat, 16 Sep 2000 02:42:42 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: how to install perl in windows95?
Message-Id: <39C2DE40.59704497@rochester.rr.com>

Eric wrote:
> 
> "tim" <catman77@ar51.net> wrote in message
> news:ss4n21psdc6125@corp.supernews.com...
> > Downed active perl "617, and 5xx". They do not come with a install for
> > windows. <<snip>>
> 
> if you download the intel package from activestate.com it comes as a .msi
> (windows installer) file...just double click it and it installs itself like
> a charm.
> 
> hth
> Eric
But Windoze 95 (and 98 and NT for that matter) don't come with Windoze
Installer.  So if you don't have it, you have to download it first, as
clearly instructed by the ActiveState site.
-- 
Bob Walton


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

Date: Sat, 16 Sep 2000 02:47:19 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Lost libraries when upgrading from 5.005 to 5.6
Message-Id: <39C2DF55.C5046F86@rochester.rr.com>

bluearchtop@my-deja.com wrote:
> 
> I just upgrade from 5.005 to 5.6 and I can no longer access all my
> modules installed under 5.005. Did I miss something in the Configure
> script? Or is the only way to re-install all modules from CPAN?  Thanks.
 ...
I recall reading somewhere that any C-interface routines have to be
recompiled for Perl 5.6 .  So you'll need to reinstall such modules
(many modules use C-code routines) from CPAN anyway.
-- 
Bob Walton


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

Date: Fri, 15 Sep 2000 22:45:02 -0400
From: Albert Dewey <timewarp@shentel.net>
Subject: Re: Module for CGI Session Management?
Message-Id: <39C2DEAE.FAA9DFA5@shentel.net>

> > Makes logical sense to me. This wouldn't be too difficult, really. Just
> > takes time. If anyone has already written it, please let me know. Also, I
> > know that CGI.pm does some sort of session management, but it doesn't really
> > do what I would like, or in a way I would like to do it.
> >
> > Thanks!
> >
> > Matt Kruse
> > mkruse@netexpress.net
> > http://www.mattkruse.com/

I made my own routines to do precisely this. I generate a session number upon the
user entering the site using rand( ) and put this value into a cookie. I also
store this same number, as well as a number of other factors, in a data file and
when the user navigates the site, I retrieve his cookie and compare it with his
session entry in the datafile and act accordingly. Then I use crontab once every
24 hours to clean up old sessions based on their time of creation. Really quite
simple to setup and manage.

Albert Dewey




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

Date: Fri, 15 Sep 2000 22:38:52 -0400
From: Albert Dewey <timewarp@shentel.net>
Subject: Re: Newbie - Should I learn Perl or Javascript
Message-Id: <39C2DD3B.68031442@shentel.net>

Jim Verzino wrote:

> I am going to spend some time learning some programming for the web.  I am
> not sure if I should invest in learning perl or javascript first.  I have a
> business need that would make perl a little smarter from a practicality
> perspective but that can be avoided if need be.
>
> I am not new to programming and know some programming languages, but those
> are a few years out of date.  I do know that learning a new language is
> considerable investment though and I want to make the right choice.
>
> Are these competitors or complimentary.  What are the pros and cons of one
> over the other.  Any help would be appreciated.
>
> Jim Verzino

Learn both without question. I found that there are many operations that can
only be performed on the server which I obviously code in Perl. Then there are
the many functions that can best be handled on the client's machine and
javascript is what you need for this. I have yet to make a dynamic site or even
a single web page where I am not using Perl and Javascript to complement one
another.

Albert Dewey




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

Date: Fri, 15 Sep 2000 23:20:02 -0400
From: Albert Dewey <timewarp@shentel.net>
Subject: Re: Password protecting a script
Message-Id: <39C2E6E2.8E708BFB@shentel.net>

Geoff Soper wrote:

> I would like a script to be only used once having entered a password. What
> would the best way of achieving this be? The script is running on an
> Apache server if that helps at all. The script should only ever be used by
> a single (the same) person so a single password would be acceptable. In
> use the script is called several times in a row, passing itself different
> parameters each time but I don't really want the user to have to re-enter
> the password within a single session.
>
> Any advice or suggestions will be most appreciated.
>
> Thanks
>
> --
> Geoff Soper
> g.soper@soundhouse.co.uk
> Take a look at the Soundhouse page http://www.soundhouse.co.uk/

This is really an Apache issue. You will have to generate a small file called
 .htaccess (the entire name is really a long file extension) with content
similar to the following - (this file will live in the folder that you would
like to password protect. If you are using more than one folder, you will have
to create duplicate files inside each of these folders. A better way would be
to group all the protected folders under a single protected folder and
password protect just the one parent folder.)

AuthUserFile /usr/local/mysite/htpasswd
AuthGroupFile /dev/null
AuthName MySite
AuthType Basic
<Limit GET PUT POST>
require user admin
require user joe
require user steve
</Limit>

Then you will need to encrypt a password for the user and store the encrypted
result in a file called htpasswd (no file extension) as such -

admin:WoMVYCoFYxLss
joe:BKMrAG6N3WLTs
steve:3cjmzqw9wXnLE

A sample of code I use (stripped down to just the essentials) to automate this
process is as follows -

#!/usr/bin/perl
print "Content-type: text/html\n\n";
use CGI qw/:standard/;

## Initialize the variables (you are getting the following info from a web
form, duh!)
$Password = param('password');
$UserName = param('username');

## Create the new user
&New_User;

sub New_User
 {
 if($Password eq "") || ($UserName eq "")
  {
  &Error;
  }

 ## Let's make $UsrPwdString
 $UsrPwdString = $UserName;
 $UsrPwdString .= "\:";
 $UsrPwdString .= &generate_pw($Password);

 ## Write to the password file in encrypted form
 open(POST,">>/usr/local/mysite/htpasswd");
 print POST ("$UsrPwdString\n");
 close(POST);

 ## Add the new user to the .htaccess file
 $new_entry = "require user $UserName";
 open(FILE,"../mysite/management/.htaccess"); ## Make this the folder where
you will have the protected script
 while(<FILE>)
  {
  $AccessFile .= $_ if $. >= 0
  }
 close(FILE);

 $Limit = "</Limit>";
 $AccessFile =~ s/$Limit/$new_entry/g;
 open(POST,">../mysite/management/.htaccess");
 print POST ("$AccessFile\n");
 print POST ("</Limit>");
 close(POST);

## You are done so print out a success page
 &Success;
 }

## Encrypt The Password
sub generate_pw
 {
 local ($mypw) = @_;
 local @atoms,$n,$enc,@s,$salt;
 @atoms = split
//,"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./";

 ## Seed the random number generator
 srand(time ^ $$);
 $n = int(rand 64);
 $s[0] = $atoms[$n];
 $n = int(rand 64);
 $s[1] = $atoms[$n];
 $salt = $s[0].$s[1];
 $enc = crypt($mypw, $salt);

 return($enc);
 }

## Print Out A Success Page
sub Success
 {
 print ("<html><body bgcolor=dddddd link=000000 vlink=000000><title>New User
Added</title></head>\n");
 print ("<center><br><b><u>New User Added</u></b><br><br>\n");
 print ("<b>Username Added:</b><br>\n");
 print ("<b><font color=blue>$UserName</font></b><br><br>\n");
 print ("<b>User Password:</b><br>\n");
 print ("<b><font color=blue>$Password</font></b><br><br>\n");
 print ("</body></html>\n");
 exit;
 }

## Error Message
sub Error
 {
 print ("<html><body bgcolor=dddddd link=000000
vlink=000000><title>Error</title></head>\n");
 print ("<center><br><br><b>Form Not Properly Filled Out!</b><br><br>\n");
 print ("</body></html>\n");
 exit;
 }

I also have routines to change a user's password as well as deleting a user
from the system which you might consider using.

To any Perl Gods out there full of sharp comments and criticizms - I am aware
that there are a number of ways to do this so try and keep your comments to
presenting your own routine or pointing out glaring syntax errors in mine. The
code I have here does work so it should be good enough as an example for Geoff
to get started with.

Albert Dewey



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

Date: Sat, 16 Sep 2000 03:04:58 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Question about Overloading "="
Message-Id: <39C2E377.E3F2D1@rochester.rr.com>

alphazerozero@my-deja.com wrote:
> 
> In article <39C22296.E19DC6D4@flash.net>,
>   Thom Harp <thomharp@flash.net> wrote:
> > To my knowledge you can't do that, but you might want to look into the
> > "tie" function.  It allows you to associate a variable with a class,
> and
> > you can create methods which handle the usual actions of that
> variable,
> > such as fetching and storing...
> 
> Yeah I do know about that, but actually I meant about a copy
> constructor (which use overload considers to be the "=" operator.) and
> its use with other overloaded operators.
> 
> If you look at the doc that goes with overload its very confusing..
> So i might be confused as well... :-)
> 
> yves
 ...
There is an excellent discussion about use overload in the book "Object
Oriented Perl".  It thoroughly discusses overloading the = operator.
-- 
Bob Walton


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

Date: 15 Sep 2000 18:04:48 -0500
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: Question to the Wise - Writing Spaces
Message-Id: <m3wvgdxnn3.fsf@dhcp11-177.support.tivoli.com>

"Eric" <eric.kort@vai.org> writes:

> HTML recognizes &nbsp as a "hard" space--you can put as many as you like,
> and it will print them all.  So have your script replace each space with
> &nbsp.  As for capitalizing like to LIKE that's a different matter  =)

Don't forget the trailing semicolon: &nbsp;

-- 
Ren Maddox
ren@tivoli.com


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

Date: Sat, 16 Sep 2000 01:37:46 GMT
From: Jeff Helman <jhelman@wsb.com>
Subject: Re: Question: windows system() crash detection
Message-Id: <39C2CF50.96B5100@wsb.com>

Robert Hooper wrote:
> 
> Here's my problem, I'm running a perl script on a Win98 machine and using system() to
> call another program, repeatedly. Sometimes the other program crashes and a
> window comes up with a details and cancel button ( we've all seen this window before ;) )
> Anyway I don't care that it died, but I do care that its stopped on this window
> until I click cancel, I just want it to end and the perl script to continue without my
> intervention. Is there anyway to have perl catch this event and keep going?

Have you looked into the Win32::Process module?  Since you're using W98,
I assume you are using the ActiveState distribution of Perl. 
Win32::Process is included.  Explore the Win32::Process::Create
subroutine.  I don't know if it will help with your particular problem
since you haven't given us any information about the process you are
spawining.  If this is something that fails consistently, you might
consider rewriting it in Perl for better error reporting.

Hope this helps,
JH


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

Date: Fri, 15 Sep 2000 22:35:38 -0400
From: Albert Dewey <timewarp@shentel.net>
Subject: Re: Regular Expression for matching with email addresses
Message-Id: <39C2DC7A.AA48A18@shentel.net>

Rafael Garcia-Suarez wrote:

> James Adams wrote in comp.lang.perl.misc:
> >I want to verify that strings conform to a typical email address
> >format.  I have some code which can use Perl regular expressions as
> >verification masks, but I'm not the world's best at Perl regular
> >expressions so I'm hoping that someone can provide me with some example
> >Perl regular expressions that I could use for this verification mask.
> >
> >I want to match with something like
> >my.address_is-ugly@some.place.com (dashes, underscores, and digits are
> >ok, only one @ sign, etc.)
> >and fail to match with garbage such as this: bad%*)addres@isp@isp2.it

Try this - works for me -

if ($Email =~ /[\w\-]+\@[\w\-]+\.[\w\-]+/)
    {
    Do stuff
    }

Albert Dewey





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

Date: Sat, 16 Sep 2000 01:38:55 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Segmentation Fault
Message-Id: <39C2CF4D.1796EB55@rochester.rr.com>

Bob Jones wrote:
> 
> Ok, I'm having a problem here that I hope you all can help me out with.
> I'm trying to authenticate against an LDAP database using the Mozilla C
> SDK.  I have included my program at the bottom for you to check out.
> Whenever I try to use it I'm getting a Segmentation Fault (core dumped)
> error.  I have no idea what could be causing this and would appreciate
> any help.
> 
> Thanks in advance
> Bob Jones
> Bob.Jones@WKU.EDU
 ...
I've had good luck using Net::LDAP to connect to a Netscape LDAP
server.  Maybe that would get you out of trouble?
-- 
Bob Walton


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

Date: 15 Sep 2000 19:24:05 -0500
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: Shortest code for Fibonacci?
Message-Id: <m3itrxchga.fsf@dhcp11-177.support.tivoli.com>

tjla@guvfybir.qlaqaf.bet (Gwyn Judd) writes:

> I was shocked! How could Ren Maddox <ren.maddox@tivoli.com>
> say such a terrible thing:
> >tjla@guvfybir.qlaqaf.bet (Gwyn Judd) writes:
> >
> >> >> perl -le 'print length while ($ / =~ s|(.*)|s ,. *,$ /,ex, $ / . $ &|e)'
> >> 
> >> perl -le 'print length while ($" =~ s|(.*)|s c. *c$ "cex, $ ". $ &|e)
> >
> >Took me a long time to catch the fact the $& was not referring to what
> >I thought it was referring to, but now I still don't see why the
> >previous one doesn't work.
> 
> (Hint) I think it has something to do with the '.'

Doh!  Thanks!

-- 
Ren Maddox
ren@tivoli.com


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

Date: Sat, 16 Sep 2000 01:17:05 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Shortest code for Fibonacci?
Message-Id: <vei5ss8t9g4276erg0860scur2kkngnuul@4ax.com>

Clint Mario Cleetus wrote:

>I am looking for a concise and elegant way to calculate the Fibonacci
>Number corresponding to a given number. But it should also avoid recursion
>in order to be efficient.

No need to avoid recursion. All you need to do is cache the results.

See the Memoize module at CPAN. Fibonacci is even an example in the
docs!

-- 
	Bart.


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

Date: Sat, 16 Sep 2000 03:12:37 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Timeout while socket opened
Message-Id: <G0yM91.7HA@news.boeing.com>

In article <8ps6m0$gj3$1@news1.kornet.net>,
Park, Jong-Pork\)" <okletsgo@NOSPAM.hitel.net (remove NOSPAM. <okletsgo@NOSPAM.hitel.net (remove NOSPAM.)> wrote:
>I tried to get a html file from other site. And I wanna make more powerful web Robot.
>
>But I can't control timeout while buffering data from the site.
>Here is LWP example. LWP::UserAgent can define timeout before connect to the site.
>
>But, Unhappiness, I can't define timeout while connected and getting data from the site.
>If object site have lowest bandwidth and have a large file(but small than buffer),
>my robot wait for a long time.
>
>Here is LWP example and my wroted source. Help me....
>
>------
>
>$ua = LWP::UserAgent->new;
>$ua->timeout(10);
>$ua->max_size(10000);
>
>$request = HTTP::Request->new('GET', 'http://slnms.snu.ac.kr');
>$response = $ua->request($request);
>
>print $response->content;

>...

>   my $sock = IO::Socket::INET->new(PeerAddr => $host,
>                                    PeerPort => $port,
>                                    Proto    => 'tcp',
>                                    Timeout  => 10) || return;
>   $sock->autoflush;
>   print $sock join("\015\012" =>
>                    "GET $path HTTP/1.0",
>                    "", "");
>
>   my $buf = "";
>   my $n;
>   1 while $n = sysread($sock, $buf, 8*1024, length($buf));
>   return undef unless defined($n);
>
>    print $buf;
>

An underlying IO::Socket version 1.20 or greater will correct 
problems with LWP's timeout. This worked on the intial connect(3N) 
call but not after that that I could determine.

I did get a timeout to work by wrapping your do-it youself 
calls, e.g. sysread with a block eval and an alarm. 
Take a look the alarm example in perlipc... for an example 
of how to do this.


hth,
--
Charles DeRykus


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

Date: Sat, 16 Sep 2000 03:20:14 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: tutorial for advanced experimental regex  features?
Message-Id: <g4p5ssgk7ml4jfvljhckrhq0hlc01gdhd8@4ax.com>

I cannot make mluch sense of the advanced experimental regex features
that are documented in perlre: 

	(?{...})
	(?(cond)patyes|patno)
	(??{...})

perlre is just a refrence manual, and that's precisely the problem. Does
anybody have any idea on for example an online tutorial with lots of
examples?

The feature I'd like to implement, is executing some Perl code at
certain times in the matching process, which would optionally make the
regex fail and backtrack, searching for alternatives. I just don't know
where to start. I'm not yet even convinced it can be done.

-- 
	Bart.


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

Date: Sat, 16 Sep 2000 11:03:34 +0900
From: "sang" <laoxiu100@hotmail.com>
Subject: Unicode
Message-Id: <8puk7u$e1t$1@nn-os105.ocn.ad.jp>

Hi,alls

How can i access unicode file in Perl?

Thanks in advance



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

Date: 15 Sep 2000 18:12:22 -0500
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: uninitialized variables
Message-Id: <m3u2bhxnah.fsf@dhcp11-177.support.tivoli.com>

Mark Eggers <mdeggers@earthlink.net> writes:

> The following snippet of code produces a warning along with the correct
> results in both Perl 5.005 and 5.6.0.
> 
> #!/usr/bin/perl -w
> {
>     use diagnostics;
>     my @dirlist = ();
>     opendir(LDIR, ".");
> #
> # get only the Perl files
> #
>     @dirlist = grep/$\.pl/, readdir(LDIR);
                      ^^--- this is the problem
>     closedir(LDIR);
>     foreach my $file (@dirlist)
>     {
> 	print "$file\n";
>     }
> }
> 
> The error is in Perl 5.6.0
> Use of uninitialized value in concatenation (.) at ./dirread.pl line 11 (#1)
> 

Your RE, /$\.pl/ is not correct.  I assume you meant /\.pl$/ (though
you might want to be a tiny bit paranoid and make that /\.pl\z/).  I'm
not sure why the error references concatenation though -- must be
because string interpolation is really just concatenation, and an RE
goes through string interpolation first.  It is not parsing as you
expect -- instead, $\ is taken as a scalar, which is undefined by
default, thus the error.

-- 
Ren Maddox
ren@tivoli.com


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

Date: 15 Sep 2000 19:34:15 -0500
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: uninitialized variables
Message-Id: <m3g0n1cgzc.fsf@dhcp11-177.support.tivoli.com>

Larry Rosler <lr@hpl.hp.com> writes:

> In article <Eauw5.12526$%p2.535946@newsread03.prod.itd.earthlink.net> on 
> Fri, 15 Sep 2000 18:49:08 GMT, Mark Eggers <mdeggers@earthlink.net> 
> says...
> >     @dirlist = grep/$\.pl/, readdir(LDIR);
> 
> What string matches an end-of-string at the beginning of the string?  An 
> error like this indicates that you typed this in instead of copy-and-
> pasting your real code, so everything else becomes suspicious.

Except that this RE parses as:
/ $\ . pl /x

which leads to the warning (though the concatenation message is
misleading and doesn't have anything to do with the ".").

-- 
Ren Maddox
ren@tivoli.com


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

Date: Sat, 16 Sep 2000 02:29:55 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: uninitialized variables
Message-Id: <39C2DB3D.183E1E72@rochester.rr.com>

Mark Eggers wrote:
> 
> The following snippet of code produces a warning along with the correct
> results in both Perl 5.005 and 5.6.0.
> 
> #!/usr/bin/perl -w
> {
>     use diagnostics;
>     my @dirlist = ();
>     opendir(LDIR, ".");
> #
> # get only the Perl files
> #
>     @dirlist = grep/$\.pl/, readdir(LDIR);

You have misplaced the $ above.  Because when a $ is found anywhere but
at the end of a pattern (or subpattern, with $| $( or $) ), the regex
evaluator attempts interpolation, finding variable $\.  Apparently $\ is
considered uninitialized -- but I'm not sure why the . is being
interpreted as an operator -- maybe that was the closest error message? 
If you put the $ after the pl, it will work.  And BTW, your program as
you wrote it doesn't work -- it includes in its output such files as:

    junk.plxxx
    junk.pl.txt

etc.

>     closedir(LDIR);
>     foreach my $file (@dirlist)
>     {
>         print "$file\n";
>     }
> }
> 
> The error is in Perl 5.6.0
> Use of uninitialized value in concatenation (.) at ./dirread.pl line 11 (#1)
> 
> I don't mind the error so much except that this script will be run by
> people not familiar with the environment.  Therefore the code should
> be clean.
> 
> Any ideas as to how to get around this (I've tried various combinations
> of my $file="foo"; and for $::file with no luck) would be greatly
> appreciated.
> 
> Thanks - /mde/
-- 
Bob Walton


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

Date: Fri, 15 Sep 2000 21:26:01 -0400
From: "Sam Smith" <sammis1@hotmail.com>
Subject: Variables
Message-Id: <8pui4j$eqj$1@news.cc.ucf.edu>

Whats the difference between a variable declared like ${variable} and
$variable ???




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

Date: Sat, 16 Sep 2000 01:56:36 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Variables
Message-Id: <39C2D372.5668E7DE@rochester.rr.com>

Sam Smith wrote:
> 
> Whats the difference between a variable declared like ${variable} and
> $variable ???

There is no difference (other than an extra { and }).  But in an
interpolated string like:

     "xxx$variablexxx"

Perl will attempt to substitute variable $variablexxx, whereas in:

     "xxx${variable}xxx"

the value of $variable will be substituted.  Without that, you'd be
"stuck" if you needed to embed a variable followed by alphanumerics in
an interpolated string.  It is also needed for cases like:

     "xxx${variable}::not_a_package_variable"

or

     "xxx${variable}'not_a_package_variable_either"

See

     perldoc perldata

-- 
Bob Walton


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

Date: 15 Sep 2000 23:16:28 -0400
From: darkon@one.net (David Wall)
Subject: Re: Variables
Message-Id: <8FB0EEFD3darkononenet@206.112.192.118>

sammis1@hotmail.com (Sam Smith) wrote in <8pui4j$eqj$1@news.cc.ucf.edu>:

>Whats the difference between a variable declared like ${variable} and
>$variable ???

The first one is two characters longer.  More seriously, the first form is 
useful in interpolated strings, when you want to make sure the variable 
name is not confused with the text you're printing.  For example, if you 
had a variable named $var, then

print "This is the contents of a variable surrounded by X's: XXX${var}XXX";

would do what you expect.  (assuming you expect the right thing) If you 
wrote

print "This is the contents of a variable surrounded by X's: XXX$varXXX";

then perl would try to print a variable named $varXXX, which probably 
doesn't exist.

HTH.

-- 
David Wall
darkon@one.net


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

Date: 16 Sep 2000 02:43:15 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Which environment var can I use?
Message-Id: <8pumo3$93e$1@nntp9.atl.mindspring.net>

bill@bitco.com wrote:
: I have two domain names pointing to the same IP address.  It doesn't
: matter which one I type in from my browser, I will get the same index
: page.  I would like to set up a perl redirect script that my index page
: will call.  This redirect needs to find out which domain name was used
: to call the script so it can then redirect to the correct page for that
: domain name.
: 
: Does anybody know which environment var I could use to deturmine which
: domain name was used to get to the IP address?  If somebody has already
: done somthing like this could you tell me how you did it?  Thank You

Well, it's set in $ENV{HTTP_HOST}, but normally you wouldn't use a CGI 
script to handle this, you'd configure the Web server to do it for you; 
this goes by the name of "virtual hosts."  I'd suggest you look at your 
server's documentation and, if you're still confused, post to the 
appropriate comp.infosystems.www.servers.* group (though only after 
checking that group's FAQ to make sure your question hasn't already been 
answered).  It's not really a Perl question.



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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 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.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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.

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


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