[12568] in Perl-Users-Digest
Perl-Users Digest, Issue: 6168 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jun 29 17:07:37 1999
Date: Tue, 29 Jun 99 14:00:25 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest           Tue, 29 Jun 1999     Volume: 8 Number: 6168
Today's topics:
    Re: Apples and Oranges (doug edmunds)
    Re: Associative array of a two dimensional array <swiftkid@bigfoot.com>
    Re: Associative array of a two dimensional array <peter_jones@my-deja.com>
    Re: fastest DBI module? <chris.ice@cisco.com>
    Re: Filehandles, appending a file..why dosn't this work <swiftkid@bigfoot.com>
    Re: Filehandles, appending a file..why dosn't this work <rootbeer@redcat.com>
    Re: Filehandles, appending a file..why dosn't this work <peter_jones@my-deja.com>
    Re: Force Refresh for SSI <rootbeer@redcat.com>
    Re: Humbled with command completion <rootbeer@redcat.com>
    Re: I need help on easy topic <cassell@mail.cor.epa.gov>
        killing a proccess from another program amidalla@my-deja.com
    Re: MKTEMP <rootbeer@redcat.com>
    Re: MKTEMP <jim@*nospam*network-2001.com>
    Re: module for WWW servers <rootbeer@redcat.com>
    Re: My First Perl error...I'm just learning. <upsetter@ziplink.net>
    Re: newbie refs | uninitialised data prob (Rory C-L)
        Newbie?: Is FreeBSD OK with Perl & Apache? (will)
    Re: Nobody to help? (How to understand DBM types?) <swiftkid@bigfoot.com>
    Re: Nobody to help? (How to understand DBM types?) <rootbeer@redcat.com>
    Re: Object persistence -- how to? (Damian Conway)
    Re: parsing for loop (Damian Conway)
        Perl and modems ()
        regexp riddle <msoulier@americasm01.nt.com>
        regular expresion HELP!!! evargas@my-deja.com
    Re: Server side issues... terencekh_leung@my-deja.com
    Re: Starting asynchronous process from Perl <rootbeer@redcat.com>
    Re: Starting asynchronous process from Perl <peter_jones@my-deja.com>
    Re: Term::ReadLine <cassell@mail.cor.epa.gov>
    Re: There is a smarter way, but i dont know how. (John Boswick)
    Re: upload script <rootbeer@redcat.com>
    Re: Using WindowsNT and ActivePerl and Job Scheduling ( <rootbeer@redcat.com>
    Re: win32 file access <swiftkid@bigfoot.com>
    Re: win32 file access flounder99@my-deja.com
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 29 Jun 1999 20:28:11 GMT
From: edmundsMUNGED@pacifierMUNGED.com (doug edmunds)
Subject: Re: Apples and Oranges
Message-Id: <37792b27.7619723@news.pacifier.com>
On 29 Jun 1999 13:14:56 -0000, anno4000@lublin.zrz.tu-berlin.de (Anno
Siegel) wrote:
>
>In fact, in her infinite magnanimity, perl has
>allowed you to create a variable with a blank in its name.
But wait! theres more! How about parentheses, curly brackets, 
some exclamation points and even a new line?.
#---code starts-------
#! perl -w  
use Data::Dumper;
print "test 1 \n";
undef $a;
$$a = "Two apples";
print "Before assignment to \$a\n";
print "\$\$a is $$a  \$a is $a \n";
print "Dumper \$\$a: ". Dumper ($$a);
print "Dumper \$a : ".  Dumper ($a);
print  "\n";
$a = "Three thousand, wormy!\n(buggy) {Golden Delicious} apples";
print "After assignment to \$a\n";
print "\$\$a is $$a  \$a is $a \n";
print "Dumper \$\$a: ". Dumper ($$a);
print "Dumper \$a : ".  Dumper ($a);
print  "\n";
$$a = "Two apples";
print "Reassign to \$\$a\n";
print "\$\$a is $$a  \$a is $a \n";
print "Dumper \$\$a: ". Dumper ($$a);
print "Dumper \$a : ".  Dumper ($a);
#here it comes
print ${"Three thousand, wormy!\n(buggy) {Golden Delicious} apples"};
print  "\n";
#------code ends-----
------------------------------
Date: Wed, 30 Jun 1999 00:50:15 +0500
From: "Faisal Nasim" <swiftkid@bigfoot.com>
Subject: Re: Associative array of a two dimensional array
Message-Id: <7lcba6$57d8@news.cyber.net.pk>
<hollanderm@my-deja.com> wrote in message
news:7lb5k2$omp$1@nnrp1.deja.com...
> I am starting to go beyond my understanding of arrays. . .
>
> I am making an associative array, each value of which contains a 2-D
> array.  This is what it looks like
<snip>
> later, I say
> @array = $line{$temp}, but perl doesn't seem to recognize @array as a
> 2-D array.  I don't really understand why.  Any insight would be
> wonderful.  Thanks a million.
Check out this example (pass the array as a reference)
@array = [ 'whizkid' , 'cool' ]; # $array [ 0 ] [ 0 ] is "whizkid"
$hash { 'key' } = \@array;
@x = @ { $hash { 'key' } };
print $x [ 0 ] [ 0 ];
#prints whizkid
--
Faisal Nasim (the Whiz Kid)
Web: http://wss.hypermart.net/
AOL: Whiz Swift  ICQ: 4265451
FAX: (815) 846-2877
------------------------------
Date: Tue, 29 Jun 1999 20:26:41 GMT
From: Peter Jones <peter_jones@my-deja.com>
Subject: Re: Associative array of a two dimensional array
Message-Id: <7lba5i$qk3$1@nnrp1.deja.com>
In article <7lb5k2$omp$1@nnrp1.deja.com>,
  hollanderm@my-deja.com wrote:
> I am starting to go beyond my understanding of arrays. . .
>
> I am making an associative array, each value of which contains a 2-D
> array.  This is what it looks like
>
> for $temp (@temps) {
> 	open FILE, "$file";
>
> 	splics @ln, 0   # this is to clear the array before I use it 					#
> again
> 	while (<FILE>) {
>                     	push @ln, [ split ];
>         }
>
>         $line{$temp} =  @ln;
>         close FILE;
> }
> (NOTE :  FILE contains multiple columns of data :
> abc	123	234	324
> fds	123	321	234
> fdk	123	54	34
> )
>
> later, I say
> @array = $line{$temp}, but perl doesn't seem to recognize @array as a
> 2-D array.  I don't really understand why.  Any insight would be
> wonderful.  Thanks a million.
>
> mike.
>
You can only store a scalar as a value to a hash key. You need to take a
reference to the array before you put it in the hash like so...
$line{$temp} =  \@ln;
now to get that array back you can...
$array_reference = $line{$temp};
@array = @$array_reference;
-- or --
@array = @{$line{$temp}};
one problem that this will cause is that whenever you make a change to
@ln it will change the array in $line{$temp} because you are using
references. A way to get around this is to do...
$line{$temp} =  [@ln];
which will create a new anonymous array and fill it with @ln and put a
reference to it in $line{$temp}.
also see "perldoc perlref"
also, instead of using splice @ln, 0; you can say @ln = () or @ln =
undef;
Just a thought that does not matter :-)
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Tue, 29 Jun 1999 13:31:42 -0700
From: Chris Ice <chris.ice@cisco.com>
Subject: Re: fastest DBI module?
Message-Id: <37792D2E.94021500@cisco.com>
Kevin Howe wrote:
> 
> Which of the DBI:: Modules are the fastest?
Do you mean the database drivers (DBDs)??  There is only one DBI module
that I know of (other than the Win32 vs. Unix variants of DBI)...and
it's very fast.
The speed differences come in when you're connecting to different
flavors of database...and in the commercial database space, you pick the
database first (features, price, support, tools, etc), and the drivers
are a consequence of that decision (not the other way around).
Of the database drivers, ODBC tends to be a poor choice performance
wise, but the most portable.  Native drivers tend to be the fastest (ie.
DBD::Oracle, rather than running an ODBC listener on Oracle, and the
talking to it with ODBC).
Of course, I have no numbers to back this up...so take it for what it's
worth.
Chris
-- 
                               --------
 +----------------------------| _   /| |-----------------------------+
 | Chris Ice, Web Programmer  | \`o_O' | Cisco Systems, Inc.         |
 | http://www.trub.com/       |   ( )  | http://www.cisco.com/       |
 | mailto:chris.ice@cisco.com |    U   | 170 W. Tasman Dr., SJ-05/1  |
 | 408.525.7373               |  Syn,  | San Jose, CA 95134-1706 USA |
 +----------------------------|  Ack!  |-----------------------------+
  My opinions may not reflect  --------  the views of my employer.
------------------------------
Date: Wed, 30 Jun 1999 00:42:22 +0500
From: "Faisal Nasim" <swiftkid@bigfoot.com>
Subject: Re: Filehandles, appending a file..why dosn't this work?
Message-Id: <7lcare$5if4@news.cyber.net.pk>
> open (ORDERLOG, ">>orderlog") or die "Can't open orderlog.\n";
> print ORDERLOG $adjective2, \n;
> print ORDERLOG $adjective3, \n;
> print ORDERLOG "***********************************************\n";
> close ORDERLOG;
>
> incidently, I am asuming that it is priniting the variables correctly
> because the variables are parsed from a form.The scripts writes the
> following to the ORDERLOG file:
> SCALAR(0x80c06b4)SCALAR(0x80c06cc)
You have to wrap \n in quotations
print ORDERLOG "$adjective2\n$adjective3\n" , "*" x 70;
#covers all print lines in your snippet
--
Faisal Nasim (the Whiz Kid)
Web: http://wss.hypermart.net/
AOL: Whiz Swift  ICQ: 4265451
FAX: (815) 846-2877
------------------------------
Date: Tue, 29 Jun 1999 13:32:43 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Filehandles, appending a file..why dosn't this work?
Message-Id: <Pine.GSO.4.02A.9906291330130.4425-100000@user2.teleport.com>
On Wed, 30 Jun 1999, Jeremiah and Veronica wrote:
> I can get the script to append just fine through telnet but cannot get
> it to work from a browser.
When you're having trouble with a CGI program in Perl, you should first
look at the please-don't-be-offended-by-the-name Idiot's Guide to solving
such problems. It's available on CPAN.
   http://www.perl.com/CPAN/
   http://www.perl.org/CPAN/
   http://www.perl.org/CPAN/doc/FAQs/cgi/idiots-guide.html
   http://www.perl.org/CPAN/doc/manual/html/pod/
> I've chomoded all the files to 777 out of shere frustration
Don't do that before you post your password to misc.test. :-)
> open (ORDERLOG, ">>orderlog") or die "Can't open orderlog.\n";
Do you know what directory your program is running in? Any CGI program
which uses relative paths before a chdir to a non-relative path is in a
state of sin.
Good luck with it!
-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 29 Jun 1999 20:35:43 GMT
From: Peter Jones <peter_jones@my-deja.com>
Subject: Re: Filehandles, appending a file..why dosn't this work?
Message-Id: <7lbamu$qq9$1@nnrp1.deja.com>
In article <7lb4vo$iuk$1@bgtnsc01.worldnet.att.net>,
  "Jeremiah and Veronica" <adams1015@worldnet.att.net> wrote:
> I'm a newbie having a hardtime getting a script to append a file. I
can get
> the script to append just fine through telnet but cannot get it to
work from
> a browser. I've chomoded all the files to 777 out of shere frustration
and
> still cannot get the script to append the file. Here is the file
handle
> lines I am using
>
> open (ORDERLOG, ">>orderlog") or die "Can't open orderlog.\n";
> print ORDERLOG $adjective2, \n;
> print ORDERLOG $adjective3, \n;
> print ORDERLOG "***********************************************\n";
> close ORDERLOG;
>
> incidently, I am asuming that it is priniting the variables correctly
> because the variables are parsed from a form.The scripts writes the
> following to the ORDERLOG file:
> SCALAR(0x80c06b4)SCALAR(0x80c06cc)
>
>
I am a little confused here, is your script able to apend to your file
when run from the browser? If it is putting
SCALAR(0x80c06b4)SCALAR(0x80c06cc) at the end of the file then I would
say yes you are appending and your problem is that you have references
to scalars stored in the variables that you are printing. Try...
print ORDERLOG $$adjective2, \n;
and see what happens.
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Tue, 29 Jun 1999 13:05:52 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Force Refresh for SSI
Message-Id: <Pine.GSO.4.02A.9906291304550.4425-100000@user2.teleport.com>
On Tue, 29 Jun 1999 3will3@my-deja.com wrote:
> So I have used a random text CGI script in a SSI, and the problem is
> that when you go back to the question page again and ask another
> question, you will get the same quote again!
It sounds as if you want the server (which processes the Server-Side
Includes) to do something differently. Do you already know where to find
the docs, FAQs, and newsgroups about your server? Cheers!
-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 29 Jun 1999 13:02:59 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Humbled with command completion
Message-Id: <Pine.GSO.4.02A.9906291257300.4425-100000@user2.teleport.com>
On Mon, 28 Jun 1999, Joan Richards wrote:
> Okay, so now I'm trying to
> use the Term::Complete module by doing something like this:
> 
> $_ = Complete($term->readline($prompt), @complete);
That's not how it's shown in the docs. Maybe that's your problem?
> But, if I quote it like this:
> 
> $_ = Complete("$term->readline($prompt)", @complete);
Those quote marks don't seem to be doing what you think they're doing. But
what did you think they were doing? (Forcing scalar context?)
-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 29 Jun 1999 13:34:09 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: I need help on easy topic
Message-Id: <37792DC1.CB8A285A@mail.cor.epa.gov>
Butcher wrote:
> 
> OK i am dumb.  most of it was in the documentation that comes with the
> distribution.
People who search for and then read the documentation are *not*
dumb.  You're already doing better than most new posters here.
Congrats.  Don't forget to look over the FAQ too.
>  The only problem i am having now is that it is saying that I
> should use a module called Mail.pm that is supposed to come with the win32
> distrib but didnt seem to.
Errm, my copy refers to these modules: 
Net::SMTP
Mail::Sender
Mail::Sendmail
No Mail.pm module.  But the docs include a section on using ppm,
which will tell you about several repositories other than
the ActiveState where you can search for modules.  Go to 
Jenda's repository and get his Mail::Sender module using ppm.
HTH,
David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Tue, 29 Jun 1999 20:21:56 GMT
From: amidalla@my-deja.com
Subject: killing a proccess from another program
Message-Id: <7lb9sn$qg0$1@nnrp1.deja.com>
I'm trying to test that these programs run to completion. In these
examples, child1.pl works fine but hey3.pl runs forever. I would like
to be able to close them both after, say, 5 seconds regardless. Using
the following code, the print statement is displayed but the close
statements are never executed.
#$success1 = open(HANDLE1, "hey3.pl |") or die "Can't open file: $!\n";
#$success2 = open(HANDLE2, "child1.pl |") or die "Can't open file: $!
\n";
#sleep 5;
#print "Done the tests.\n";
#close HANDLE1;
#close HANDLE2;
How can I gain more control over the processes that I open? I have
tried Win32::Process (kill function works great) but it limits me in
other areas.
Thanks for any help.
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Tue, 29 Jun 1999 13:17:36 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: MKTEMP
Message-Id: <Pine.GSO.4.02A.9906291313461.4425-100000@user2.teleport.com>
On Tue, 29 Jun 1999, Jim wrote:
> I don't know if there is one... but here's what I use.. never had any
> trouble with it if only for a temp file...
> 
>   srand;
>   $filename = rand(10000);
>   open (TMP,">$filename");
Even when your script is "just an example" (and perhaps especially in that
case!) you should _always_ check the return value after opening a file.
On many systems, this will produce a filename collision around one time in
32768 (not one time in 10000, but still bad).
Cheers!
-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 29 Jun 1999 15:57:52 -0500
From: "Jim" <jim@*nospam*network-2001.com>
Subject: Re: MKTEMP
Message-Id: <7lbbvl$uql$1@news3.infoave.net>
but for a temp file that's deleted after a second or two, it's not very
likely but note taken nonetheless :-)
hope I canceled the other reply to you before a harvestor got it...
--
-Jim- syt.at.email.dot.com
----------------------------------
-I don't suffer from insanity, I enjoy every minute of it.
-So what if I'm paranoid? It doesn't hurt anybody
and makes life interesting for me.
----------------------------------
- Get Paid For Staying Online -
http://www.alladvantage.com/go.asp?refid=ANT424
Tom Phoenix <rootbeer@redcat.com> wrote in message
news:Pine.GSO.4.02A.9906291313461.4425-100000@user2.teleport.com...
| On Tue, 29 Jun 1999, Jim wrote:
|
| > I don't know if there is one... but here's what I use.. never had
any
| > trouble with it if only for a temp file...
| >
| >   srand;
| >   $filename = rand(10000);
| >   open (TMP,">$filename");
|
| Even when your script is "just an example" (and perhaps especially in
that
| case!) you should _always_ check the return value after opening a
file.
|
| On many systems, this will produce a filename collision around one
time in
| 32768 (not one time in 10000, but still bad).
|
| Cheers!
|
| --
| Tom Phoenix       Perl Training and Hacking       Esperanto
| Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/
|
------------------------------
Date: Tue, 29 Jun 1999 13:09:22 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: module for WWW servers
Message-Id: <Pine.GSO.4.02A.9906291306380.4425-100000@user2.teleport.com>
On Tue, 29 Jun 1999 lhollman@my-deja.com wrote:
> Hi all:I'm trying to build a light-weight WWW server using Perl.  
> I've pokedaround CPAN, but wasn't able to find a module of methods to
> helpwrite WWW servers (like the LWP modules for writing clients).  
> Hassuch a module already been written?
Yes, and it's part of LWP. Look for HTTP::Daemon. Cheers!
-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 29 Jun 1999 20:20:08 GMT
From: Scratchie <upsetter@ziplink.net>
Subject: Re: My First Perl error...I'm just learning.
Message-Id: <YT9e3.257$6M6.86757@news.shore.net>
av8tor@flash.net wrote:
: I'm just starting to learn perl and CGI.
: I'm getting the following error when trying to call my program from
: Netscape:
[snip]
What happens when you run it from the command line? If your web host
doesn't give you telnet access, you should probably find a different host
if you're planning to do much web development.
: #!/bin/perl
: print ("It Works!\n");
You need to return a "Content-type" header.
--Art
-- 
--------------------------------------------------------------------------
                    National Ska & Reggae Calendar
                  http://www.agitators.com/calendar/
--------------------------------------------------------------------------
------------------------------
Date: Tue, 29 Jun 1999 21:44:52 +0100
From: campbell-lange@easynet.co.uk (Rory C-L)
Subject: Re: newbie refs | uninitialised data prob
Message-Id: <campbell-lange-2906992144520001@campbell-lange.easynet.co.uk>
In article <7lb54k$bue$1@lublin.zrz.tu-berlin.de>,
anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote:
>>   $ar = {%alphanum};                             #: 9
>>   $na = {%numalpha};                             #:10
>
>You are unnecessarily copying %alphanum and %numalpha.  If
>you want a reference (though I don't quite see why) just
>use \%alphanum and \%numalpha.
I was simply practising with references!
(although I didn't realise I was copying, I'd better look at the pod
pages on references again). Thanks for the pointer
>
>>       if ($enc =~ /[a-z]/i) {                    #:27
>>       $codenum = $codenum % $code_last;          #:28 all the 
>>        $enc = $na->{($ar->{$enc}                 #:29 encoding done
>>       + $ar->{$code->[$codenum]}) % 26};         #:30 here!
>
>Without looking too deeply into the code, I notice you never assign
>anything to key 0 in %numalpha.  Yet you calculate a subscript into
>(a reference to a copy of) that hash via ... % 26.  This is bound
>to come out zero one day, and my guess is that's what perl is
>kvetching about.
>
>Anno
Anno, you are quite right
alphabet_hash{number_in_alphabet} was coming up with
an uninitialised value because the remainder function (line 29-30) didn't 
'remainder' correctly.
Thanks for your comments
Rory
-- 
--
Rory Campbell-Lange
The Campbell-Lange Workshop, London
------------------------------
Date: Tue, 29 Jun 1999 19:38:44 GMT
From: wganz~ZZZZ~@texoma.net (will)
Subject: Newbie?: Is FreeBSD OK with Perl & Apache?
Message-Id: <37791db9.21922232@news.texoma.net>
I am putting together a Pentium 90Mhz/16RAM/625meg box from the misc
that I have accumulated to set up a UNIX clone. This machine will be
used as an Apache server on my home network for my Scripting Languages
class(CSCI 2383). The first half of the semester will be learning the
basics of PERL and the last half will be integrating PERL and Apache. 
I was given a 4 disk set of FreeBSD ver3.1. My network presently
consists of a W95 and W3.11 box with my Mac to be added RSN. The
network load will be minimal and only that required to query the
Apache server from the W95 box. 
My question is there an advantage for loading Linux5.2 in favor of
FreeBSD that I already have? 
This is not flame war troll but I want to find out which OS would be
best for PERL & apache. 
------------------------------
Date: Wed, 30 Jun 1999 00:53:28 +0500
From: "Faisal Nasim" <swiftkid@bigfoot.com>
Subject: Re: Nobody to help? (How to understand DBM types?)
Message-Id: <7lcbg8$5if5@news.cyber.net.pk>
> I have a set of dbm files created with perl 5. The problem is,
> they are created on a SUN machine and I have no chance to
> contact the admin. or to connect the machine itself. The question:
> How can I understand which dbm is used (Berkeley, NDBM, etc.)
> for those files, using perl (I need the info, because when I try to
> open them on my Windows machine, operation failed. Why? Because
> I try to open them using SDBM, which seems not to be their type.)
<snip>
I don't know the actual solution to this, but it would be easy
if you could get an access to a SUN machine for just 5 min.
You can convert the dbm into csv format and later import it
into windows. I am a Linux guy :)
It failed because the dbm structure is different on Windows and *n[iu]x,
not sure if its same on Solaris and Linux though. A windows dbm cannot
be read in *n[iu]x and a *n[iu]x cannot be read in Windows!
--
Faisal Nasim (the Whiz Kid)
Web: http://wss.hypermart.net/
AOL: Whiz Swift  ICQ: 4265451
FAX: (815) 846-2877
------------------------------
Date: Tue, 29 Jun 1999 13:36:39 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Nobody to help? (How to understand DBM types?)
Message-Id: <Pine.GSO.4.02A.9906291333490.4425-100000@user2.teleport.com>
On Tue, 29 Jun 1999, blueman wrote:
> From: blueman <blueman@?.?>
> Subject: Nobody to help? (How to understand DBM types?)
If nobody felt like helping you the first time, maybe you should try to
figure out why not. For example, some might have wanted to send you e-mail
responses rather than posting to the newsgroup.
> How can I understand which dbm is used (Berkeley, NDBM, etc.)
> for those files, 
Try all possible, until one works. Or, look up the docs on the different
file formats and try to identify the one you have. Or, do it the same way
you would if you were a C programmer, since there's nothing about this
problem which makes it specific to Perl. 
Good luck with it!
-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 29 Jun 1999 20:31:18 GMT
From: damian@cs.monash.edu.au (Damian Conway)
Subject: Re: Object persistence -- how to?
Message-Id: <7lbaem$cu9$1@towncrier.cc.monash.edu.au>
"David L. Nicol" <david@kasey.umkc.edu> writes:
>Steve Leibel wrote:
> 
>> if I define a class and then create an instance of that
>> class, can I store the instance on disc for later retrieval?
You've already been offered some very good suggestions. 
But if you want more guidance on implementing persistence, Sriram
Srinivasan's "Advanced Perl Programming" (published by O'Reilly)
has a good discussion of the theory and practicalities of persistence.
My forthcoming book "Object Oriented Perl" (published by Manning
in August) also describes a range of OO persistence techniques.
Damian
------------------------------
Date: 29 Jun 1999 20:22:43 GMT
From: damian@cs.monash.edu.au (Damian Conway)
Subject: Re: parsing for loop
Message-Id: <7lb9uj$s0q$1@towncrier.cc.monash.edu.au>
Brian Pribis <pribis@together.net> writes:
> Me eyes! me bloody eyes! Wow, that is a lot of code...Some one else
> gave me a shorter solution (yep, I am the typical lazy
> programmer.....guess that is why I find perl so attractive:), but if
> that doesn't work I will give this a shot. Thanks for the direction.
No problem. Whether it's a lot of code depends on what you want to
achieve. If you're happy to live with Perl syntax then, compared to
eval, it certainly *is* overkill.
On the other hand, if you wanted a non-Perl syntax or semantics --
perhaps one more consistent with traditional mathematical usages -- for
your bc replacement (e.g. use '^' for exponentiation, eschew $'s before
variables, use '=' for comparison and '<-' for assignment, use 'x' and
'.' as outer and inner vector products, use postfix '%' as percentage,
etc.), then it's remarkably little code to achieve what it does. :-)
Damian
------------------------------
Date: 29 Jun 1999 20:11:29 GMT
From: rdawes@mariska.rogan.org ()
Subject: Perl and modems
Message-Id: <slrn7nia44.f6.rdawes@mariska.rogan.org>
Hi folks,
A few days ago, I posted looking for information on controlling a modem
from Perl.  I didn't find much existing code, so I ended up working it
out for myself.
To save others from having to do that, here is the result, a bit
mangled, but showing the gist.  I'm sure that the way that I am talking
to the modem, and recognising the responses could be improved
dramatically.  ANy suggestions would be appreciated.
Here it is:
#!/usr/bin/perl -w
use IO::File;
use IO::Handle;
use Fcntl ':flock';
require "sys/ioctl.ph";
my %modem_responses=('OK' => 'OK', 
                     'ERROR' => 'ERROR',
                     'CARRIER' => 'NO CARRIER',
                     'BUSY' => 'BUSY',
                     'RINGING' => 'RINGING',
# This next one should positively identify a FAX machine - Check this
                     'FAX' => '+FNSF', 
                     'CONNECT' => 'CONNECT');
$sighup=0;
$SIG{HUP}=sub {print "Caught HUP\n"; $sighup++;};
$modem=open_modem("/dev/modem");
reset_modem($modem);
flock($modem,LOCK_UN) or die "Couldn't unlock the modem: $!";
$modem->close;
exit;
# This subroutine checks to see if the reply that we have received from the
# modem is one of the known MODEM responses
sub is_modem_reply {
  my $string=shift;
  if (!defined $string) { 
    ($package, $filename, $line) = caller;
    die "No string received from $package $filename $line\n";
  }
  
  foreach $i (keys %modem_responses) {
    if ($string =~ /\Q$modem_responses{$i}/) {return $i;}
  }
  return 0;
}
sub read_modem {
  my $modem=shift;
  my $timeout=shift;
  my $return_on_modem=shift;
  my $rin=''; my $rout='';
  vec($rin,fileno($modem),1)=1;
  # if $return_on_modem is not set to non-zero, we read until the timeout
  if (!defined $return_on_modem) {$return_on_modem=0;}
  if (!defined $timeout) { die "Must specify a timeout for read_modem\n";}
  if ($timeout<=0) {die "Can't have a non-positive timeout\n";}
  # do the loop until we get a reply from the modem or $timeout occurs
  eval {
    local $SIG{ALRM} = sub { die "alarm\n" };       # NB \n required
    alarm $timeout;
    $response='';
    do {
      select($rout=$rin,undef,undef,undef);
      $chars=$modem->sysread($charsread,1000);
      if (!defined $chars) { die "Couldn't read from the modem: $!"; }
      elsif ($chars == 0) { warn "Nothing read from the modem";}
      else {
        $response=$response.$charsread;
      }
      if ($return_on_modem and is_modem_reply($response)) { 
        alarm 0;
        return; 
      }
      if ($sighup) {
        $sighup=0;
        alarm 0;
        return;
      }
    } while (1);
  };
  die if $@ && $@ ne "alarm\n";
  if ($@ eq "alarm\n") { 
    print STDERR "read_modem: Timed out after $timeout seconds\n";
  }
  return $response;
}
sub write_modem {
  my $modem=shift;
  my $command=shift;
  my $chars=0;
  my $win=''; my $wout='';
  vec($win,fileno($modem),1)=1;
  # is the modem ready to receive commands ? We'll wait up to 2 seconds
  if (!select(undef,$wout=$win,undef,2)) { 
    die "Timed out waiting to write to the modem\n";
  }
  # Send the string to the modem
  $chars=$modem->syswrite($command,length($command));
  if (!defined $chars or ($chars < length($command))) { 
    die "Couldn't write to the modem: $!";
  } 
}
sub modem_command {
  my $modem=shift;
  my $command=shift;
  my $modem_timeout=shift;
  my $response='';
  if (!($command =~ /\r/)) { warn "No CR in command '$command'\n";}
  write_modem($modem,$command);
  
  # Wait for the response from the modem
  # We are waiting for the modem to give us a recognised response
  #  e.g. OK, No Dialtone, busy, ERROR, etc
  #  set the third parameter to non-zero to terminate the read when
  # the modem has responded
  $response=read_modem($modem,$modem_timeout,1);
  return (is_modem_reply($response),$response);
}
sub reset_modem {
  my $modem=shift;
  # Hang up cleanly under most all circumstances
  drop_DTR;
  # Loop while Carrier Detect is set
  while (get_serial_flags($modem) & &TIOCM_CAR) {
    select(undef,undef,undef,0.25);
  }
  # Clear the serial buffer
  $in=read_modem($modem,2,1);
  print "Received ($in) after hanging up\n";
  # sleep a bit
  select(undef,undef,undef,1);
  # reset the modem to default state - we can probably optimise this
  ($resp,$in)=modem_command($modem,"ATZ\n\r",2);
  if ($resp ne 'OK') {
    die "Expected OK, received ($in) resp=$resp\n";
  }
  ($resp,$in)=modem_command($modem,"ATV1E0\n\r",2);
  if ($resp ne 'OK') {
    die "Expected OK, received ($in) resp=$resp\n";
  }
}
sub open_modem {
  my $device=shift;
  my $lockfile=$device; 
  $lockfile =~ s/\/.*\///;
  $lockfile="/var/lock/LCK.." . $lockfile;
  if (-f $lockfile ) {
    die "$device is locked: $lockfile exists!\n";
  }
  $modem=new IO::File "$device", O_RDWR | O_NONBLOCK;
  if (!defined $modem) { die "Couldn't open $device : $!"; }
  flock($modem,LOCK_EX|LOCK_NB) or die "Couldn't lock the modem: $!";
  $modem->autoflush(1);
  return $modem;
}
sub drop_DTR {
  my $modem=shift;
  clear_serial_flags($modem,&TIOCM_DTR);
}
sub raise_DTR {
  my $modem=shift;
  set_serial_flags($modem,&TIOCM_DTR);
}
sub get_serial_flags {
  my $modem=shift;
  $function=&TIOCMGET;
  $flags='';
  $flags_t='I';
  if (ioctl($modem,$function,$flags)) {
    $flags = unpack($flags_t,$flags);
  } else { die "Error in ioctl TIOCMGET: $!\n"; }
  return $flags;
}
sub set_serial_flags {
  my $modem=shift;
  my $set_flags=shift;
  my $current_flags=get_serial_flags($modem);
  my $function=&TIOCMSET;
  my $flags_t='I';
  my $flags=pack($flags_t,$current_flags | $set_flags);
  if (ioctl($modem,$function,$flags)) {
    $flags = unpack($flags_t,$flags);
  } else { die "Error in ioctl TIOCMSET: $!\n"; }
  return $flags;
}
sub clear_serial_flags {
  my $modem=shift;
  my $clear_flags=shift;
  my $current_flags=get_serial_flags($modem);
  my $function=&TIOCMSET;
  $clear_flags=$current_flags & (0xFFFF ^ $clear_flags);
  my $flags_t='I';
  my $flags=pack($flags_t,$clear_flags);
  if (ioctl($modem,$function,$flags)) {
    $flags = unpack($flags_t,$flags);
  } else { die "Error in ioctl TIOCMSET: $!\n"; }
  return $flags;
}
-- 
Rogan Dawes  rdawes@intekom.co.za
Given infinite time, 100 monkeys could type out the complete works of
Shakespeare.
Win 98 source code? Eight monkeys, five minutes. Tops.
 
------------------------------
Date: Tue, 29 Jun 1999 16:24:48 -0400
From: "Soulier, Michael [SKY:1Z22:EXCH]" <msoulier@americasm01.nt.com>
Subject: regexp riddle
Message-Id: <37792B90.ED90B57D@americasm01.nt.com>
        For the gurus here, this is probably simple, but I have a regexp
question. 
        I need to match a string consisting of the characters d, x, b
and e,
in any order, and any length from 1 to 4 characters long. The regexp for
my
specifications so far is
        [dxbe]{1,4}   
        Simple. However, I need to add one more condition. The
characters are
not permitted to repeat. 
        Can someone help me out here? 
	Please note, a single regexp is my desired option here. I'm aware that
additional code can accomplish this, but I want to use a single regexp
for design reasons. 
        Mike
-- 
Michael P. Soulier
1Z22, SKY
Tel: 613-765-4699 (ESN: 39-54699)
Email: msoulier@nortelnetworks.com
Carrier Packet Solutions
Nortel Networks Corporation
"...the word HACK is used as a verb to indicate a massive amount
of nerd-like effort."
   -Harley Hahn, A Student's Guide to UNIX
------------------------------
Date: Tue, 29 Jun 1999 20:30:03 GMT
From: evargas@my-deja.com
Subject: regular expresion HELP!!!
Message-Id: <7lbabr$qlj$1@nnrp1.deja.com>
I'm trying to capture all the subject lines of an
email using regular expression but I'm only able
to  catch the first lines. All email systems brake
the subject line when it is to long.
Here is my code:
while (<STDIN>) {
 m/^Subject:\s(.*|\n)/g && ($cap1 = $1, next);
}
Does any body has any idea?
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Tue, 29 Jun 1999 20:32:34 GMT
From: terencekh_leung@my-deja.com
Subject: Re: Server side issues...
Message-Id: <7lbah2$qnu$1@nnrp1.deja.com>
Try http://www.mcp.com. You can sign up for their personal bookshelf
for free and there're a lot of books to choose from.
In article <3777435A.18F0B310@yahoo.com>,
  Anders Johansson <dr_avalanche1959@yahoo.com> wrote:
> Is there a book available on
> server part, like the Web client
> programming - for server?
>
> pointers to urls with the information
> would be appriciated.
>
> /Anders
>
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Tue, 29 Jun 1999 13:26:27 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Starting asynchronous process from Perl
Message-Id: <Pine.GSO.4.02A.9906291325480.4425-100000@user2.teleport.com>
On Tue, 29 Jun 1999, Philip Weingart wrote:
> I want to fire off a subprocess from a Perl script and continue with
> the script without waiting for the subprocess to finish.
I think you want perlfaq8: "How do I start a process in the background?"
-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 29 Jun 1999 20:40:42 GMT
From: Peter Jones <peter_jones@my-deja.com>
Subject: Re: Starting asynchronous process from Perl
Message-Id: <7lbb08$qu3$1@nnrp1.deja.com>
In article <377915D8.21118806@worldnet.att.net>,
  pweingart@worldnet.att.net wrote:
> Hi, all,
>
> I think perhaps I'm having a brain hiccup, and there's a simple
answer, but I
> can't think of it for the life of me.
>
> I want to fire off a subprocess from a Perl script and continue with
the script
> without waiting for the subprocess to finish. In the Korn shell
something like
> this is simple; you just enclose the call in parenthesis, invoking a
subshell.
> How do I do it in Perl?
>
> Email replies especially welcome, and thanks in advance.
>
> Phil Weingart
> pweingart@worldnet.att.net
>
if you are doing this...
system('subprogram');
then do this...
system('subprogram &');
take a look at the Perl FAQ, it's in there.
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Tue, 29 Jun 1999 13:45:47 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Term::ReadLine
Message-Id: <3779307B.8239E98A@mail.cor.epa.gov>
3/06)z Miriam Chan wrote:
> 
> Hi all,
> 
>         Sorry if FAQ.
If it's a FAQ, then don't you think it would be faster to
read the FAQ and other docs that are already on your machine, 
than to wait around while some smug Perlite decided to answer 
your question?  Please check the FAQ before posting, to make
sure.
>         I am using Win32, but I do not have a C compiler also. I wondered why
If you have ActiveState Perl, you don't need a C compiler
most of the time.
> there is no precompiled binaries for the module Term::ReadLine ?? If there is
> one, where in the Earth can I download it ?
>From ActiveState.  Read your HTML docs (they're on your
Start Menu) and find out how to use the ppm program.  Then
just use the install option to get any module in the 
ActiveState repository.  It's surprisingly easy, and after-
ward your HTML docs will have the new documentation in them
as well.
 
HTH,
David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Tue, 29 Jun 1999 20:21:32 GMT
From: John.Borwick@sas.com (John Boswick)
Subject: Re: There is a smarter way, but i dont know how.
Message-Id: <37792a59.115315314@newshost.unx.sas.com>
<snip>
>> print "%Urls{@SortedUrls[$i]}           @SortedUrls[$i]\n";
 ...
>Your print statement syntax has an error; it should be "%Urls{$SortedUrls[$i]}."
>Dollar sign ($) in front of the array variable, not At sign (@). I would use tab
>characters or formats to separate the two fields in the print statement, to make
>the columns line up. And, you must put a conditional "last" statement inside the
>for loop, against the condition that there are fewer than ten Urls in the list.
I believe the line should read $Urls{$SortedUrls[$i]}.  In other
words, both the at sign and the percent sign should be dollar signs.
John Borwick
------------------------------
Date: Tue, 29 Jun 1999 13:13:18 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: upload script
Message-Id: <Pine.GSO.4.02A.9906291310460.4425-100000@user2.teleport.com>
On Tue, 29 Jun 1999, Joe Warakomski wrote:
> I am currently using this script
> (http://www.terminalp.com/scripts/file_upload.shtml) for uploading via
> the web.  The script runs great, although I added another field for a
> description of the file.  When script runs and displays the output it
> does not display the description, although all other field names are
> displayed.  I doubled checked all variable names between the HTML and
> CGI and everything matches.  If anyone could help, it would be
> appreciated.
There's a bug in your program. I'm not sure what other help you are
expecting, though, since you didn't include any code. Wait! Don't post
your whole program. Cut it down to the smallest example which shows the
behavior you're seeing. By posting something with no more than a dozen
lines, you'll have a good chance that someone will spot the error. Maybe
it'll even be you! 
Good luck with it!
-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 29 Jun 1999 13:20:21 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Using WindowsNT and ActivePerl and Job Scheduling (at command)
Message-Id: <Pine.GSO.4.02A.9906291319150.4425-100000@user2.teleport.com>
On Tue, 29 Jun 1999, Joe Devine wrote:
> When I run the PERL program from the command line
> (DOS) it works just fine. But the readdir() function in
> my script returns nothing when it runs under AT.
It sounds as if your environment is different when running under AT (at?).
Perhaps you need to set an environment variable differently. Good luck!
-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Wed, 30 Jun 1999 01:04:06 +0500
From: "Faisal Nasim" <swiftkid@bigfoot.com>
Subject: Re: win32 file access
Message-Id: <7lcc47$57d9@news.cyber.net.pk>
Kenneth Massey <kpmasse@cs.sandia.gov> wrote in message
news:377914E4.E3BDE87@cs.sandia.gov...
> I've tried the .tmp solution, but unlink does not delete the file.  What
> is the command to delete a file for NT.  I read previously that flock()
> should work on NT, but I wrote a test script that simply
> {opened,locked,delayed 20 seconds,closed,unlocked} in that order (is
> that the correct order?).  I then was able to run the script a second
> time while the first run supposedly had the file locked for 20 seconds.
> Thanks for your help.
>
> Kenneth
You may have a old version of Perl!
unlink should work, provide full path name to it.
--
Faisal Nasim (the Whiz Kid)
Web: http://wss.hypermart.net/
AOL: Whiz Swift  ICQ: 4265451
FAX: (815) 846-2877
------------------------------
Date: Tue, 29 Jun 1999 20:42:31 GMT
From: flounder99@my-deja.com
Subject: Re: win32 file access
Message-Id: <7lbb3k$qv9$1@nnrp1.deja.com>
flock-ing file blocks on the flock() not the open()
try running something like this:
use Fcntl ':flock';
$filename = "file.txt";
open(FILE, ">>$filename") || die "could not open $filename";
print "Opened\n";
flock (FILE, LOCK_EX);
print "Locked\n";
#seek to end of FILE in case someone else changed
#the file's length between open() and flock()'s return
seek(FILE, 0, 2);
print FILE "opened at " .  localtime() . "\n";
print "Sleeping\n";
sleep 20;
flock (FILE, LOCK_UN);
print "Unlocked\n";
close FILE;
print "Closed\n";
in in separate dos boxes.  The second one will print "Opened" and
wait until the first one unlocks the file.
In article <377914E4.E3BDE87@cs.sandia.gov>,
  Kenneth Massey <kpmasse@cs.sandia.gov> wrote:
> I've tried the .tmp solution, but unlink does not delete the file.
What
> is the command to delete a file for NT.  I read previously that
flock()
> should work on NT, but I wrote a test script that simply
> {opened,locked,delayed 20 seconds,closed,unlocked} in that order (is
> that the correct order?).  I then was able to run the script a second
> time while the first run supposedly had the file locked for 20
seconds.
> Thanks for your help.
>
> Kenneth
>
> Faisal Nasim wrote:
> >
> > flock() should work on NT.
> >
> > Anyway you can always create a .tmp file and delete it after
close(),
>
> >
> >
>
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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 6168
**************************************