[8427] in Perl-Users-Digest
Perl-Users Digest, Issue: 2044 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Mar 6 20:07:46 1998
Date: Fri, 6 Mar 98 17:00:27 -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 Fri, 6 Mar 1998 Volume: 8 Number: 2044
Today's topics:
Re: "Or" Operator? (Abigail)
Re: [Q] Connecting Win32 Perl and a DLL? <foygel@shrug.isdn.uiuc.edu>
Re: [Q] Connecting Win32 Perl and a DLL? <mattdb@syntrillium.com>
Re: Formatting telephone numbers - How to? (David Wall)
Re: Help on sockets <jdf@pobox.com>
Help: avoiding eval() on a grep() function. <tkho@technologist.com>
http 1.0/500 Server Error (Why?) <shitonme@school.com>
Re: Length of an array? <hf@aia.com>
multi word unix commands and exec <jkessler@austx.tandem.com>
Re: Need BMP to GIF converter <hf@aia.com>
Re: Newbies question for Win32 (Jim Michael)
Re: Newbies question for Win32 <cybergiggy@home.com>
Re: Newbies question for Win32 <cybergiggy@home.com>
Re: Non Perl Question - Re: Newbies question for Win32 (Jim Michael)
Re: Non Perl Question - Re: Newbies question for Win32 <cybergiggy@home.com>
Re: Perl 4/5 <spp@colltech.com>
Re: Perl 4/5 <jason@primal.ucdavis.edu>
Perl code behaving badly on NT (dave)
Perl Interface to SSH? (Eric Hagen)
perl <rickesr@pamco.com>
Re: perl <jdf@pobox.com>
Re: PerlW32 on NT, cannot use > or | why? <jschell@uswest.net>
Re: problems with one-liners on the command line (Joe McMahon)
Re: Q: obscuring Perl scripts? <spp@colltech.com>
Re: Quoting ^M? <hf@aia.com>
Re: removing new line (\n) <quentin@jihad.amd.com>
rsh hanging... (Kim Kiat Tan)
Re: safe file modification strategy (w/flock, new_tmpfi (O'Shaughnessy Evans)
Re: Using pod2html.pl on Win32 <rthorne@netscape.com>
Win32 help request, rename problem <jackal@fastlane.net>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 6 Mar 1998 23:35:12 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: "Or" Operator?
Message-Id: <6dq17g$j4j$1@client2.news.psi.net>
David Wall (dkw0@cdc.gov) wrote on 1648 September 1993 in
<URL: news:6dpq08$mkl7@cdc4.cdc.gov>:
++ In article <34F5D10C.291C0B5F@uswest.com>, rxruck2@uswest.com wrote:
++ >I'm new to programming in general and perl specifically. Here's a basic
++ >statement I'm having a problem with.
++ >
++ [snip]
++ > if ($var1 ne 'value1' || $var1 ne 'value 2') {
++
++ Isn't this *always* true?
#!/usr/local/bin/perl -w
use strict;
sub MyScalar::TIESCALAR {bless \(my $bogus = 0), shift}
sub MyScalar::FETCH {($$_[0] = !$$_[0]) ? "value1" : "value2"}
tie my $var1, 'MyScalar';
if ($var1 ne 'value1' || $var1 ne 'value2') {print "True\n";}
else {print "False\n";}
__END__
That will print "False".
Abigail
--
perl -we '%_ = map {local $_ = $_; y/a-z/n-za-m/; ($_, $_)} @_ = map {lc} <>;
print grep {$_{$_}} @_' < /usr/dict/words
------------------------------
Date: 6 Mar 1998 22:16:16 GMT
From: Fnord Prefect <foygel@shrug.isdn.uiuc.edu>
Subject: Re: [Q] Connecting Win32 Perl and a DLL?
Message-Id: <6dpsjg$rvo$1@vixen.cso.uiuc.edu>
In comp.lang.perl.misc Eric Bohlman <ebohlman@netcom.com> wrote:
> Go over to CPAN and look for a module called Win32::API which, IIRC,
> should let you call functions in any DLL. There may be different
> versions for the ActiveState port and the Sarathy port, so make sure you
> get the appropriate version.
Perhaps I'm just being dense, but I can't find that module. :)
I looked through all the Win32 modules and I didn't see any explicit
mention of being able to call DLL's.
Anyone know what I'm missing?
-Dan
------------------------------
Date: 6 Mar 1998 16:32:00 -0700
From: "Matt Bieber" <mattdb@syntrillium.com>
Subject: Re: [Q] Connecting Win32 Perl and a DLL?
Message-Id: <01bd4957$fb457ee0$153ff5cc@matt_nt>
Eric Bohlman <ebohlman@netcom.com> wrote in article
<ebohlmanEpF02K.Fn5@netcom.com>...
> Fnord Prefect <foygel@shrug.isdn.uiuc.edu> wrote:
> : I've been entirely stumped by something that seems like it
> : would be easy to do - how do I connect a Win32 Perl script
> : to a generic DLL? Dynaloader stuff is Perl-specific,
> : whereas I need something that will link to a DLL compiled
> : from C code.
>
> Go over to CPAN and look for a module called Win32::API which, IIRC,
> should let you call functions in any DLL. There may be different
> versions for the ActiveState port and the Sarathy port, so make sure you
> get the appropriate version.
>
Yes, it does let you work with any DLL, and works great.
------------------------------
Date: Fri, 06 Mar 1998 23:28:54 GMT
From: dkw0@cdc.gov (David Wall)
Subject: Re: Formatting telephone numbers - How to?
Message-Id: <6dq157$mkl8@cdc4.cdc.gov>
In article <34FED818.6B4662CB@meta3.com>, Ken Holm <rets@meta3.com> wrote:
>Joanne James wrote:
>>
>> Hi. I'm helping out on a project using Perl and am learning as I go. I've
>> been trying to show telephone numbers (numbers only are stored on database
>> -no
>> dashes) on an html page with dashes inserted. The database contains both
>> US and international phone numbers. I want to put in dashes as in the
>> following:
>> 999-999-9999 in all cases. I just need an example. Assume you are
>
>Here's how I'd do something like that:
[snip code]
Just for kicks, I played with it a bit, and I wonder why you can't just do
something like
sub PhoneCheck {
my $Item = shift;
my $pn=0;
$Item =~ tr/0-9//cd; # just the numbers, ma'am
my $length = length $Item;
for ($length) {
/7/ and do { $pn = substr($Item,0,3) . '-' .
substr($Item,3,4);
last; };
/10/ and do { $pn = substr($Item,0,3) . '-' .
substr($Item,3,3) . '-' . substr($Item,6,4);
last; };
return(0);
}
return $pn;
}
This only works for 7 and 10-digit U.S. numbers, though.
David Wall
------------------------------
Date: 06 Mar 1998 17:01:31 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: Help on sockets
Message-Id: <vhtrv5qc.fsf@news.concentric.net>
DjPaul <djpaul@fnet.gr> writes:
> I'm writing an application where a socket accepts connections and forks
> child process to handle the connection.Father process must be warned
> when the connection drops from the client so it can logs disconnection
> time etc.
> What is the way to do this?
The perlipc document contains the source code for a multithreaded
server that works just as you describe.
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
------------------------------
Date: Fri, 06 Mar 1998 15:04:59 -0800
From: Tommy <tkho@technologist.com>
Subject: Help: avoiding eval() on a grep() function.
Message-Id: <3500811B.A680577@technologist.com>
Generally, my task is to write a subroutine to grep the list of the
@Array which contains all the words in @Pattern.
For example:
@Array= (001..999);
@Pattern= ("12", "3");
@ANS= &Search(ARRAY => \@Array, PATTERN => \@Pattern, CONDITION =>
"AND");
and it returns
312, 123
I have a workable subroutine AndMatch(); however, it is very slow. The
major problem is the function eval().
grep(/$STR1/i&&/$STR2/i, @Array);
# this take only 0.3 sec for 600k records.
grep( eval(/$STR1/i&&/$STR2/i) , @Array);
# this take about 10 sec for 600k records.
Does anyone how to do the same task without using eval()?
#Start of Script ---------------------------------
my ($start, $end, @ANS);
my @Array= (ABC..IJK);
my @Pattern= (A, B, C);
$start= time+ times[0];
@ANS= &AndMatch(ARRAY => \@Array, PATTERN => \@Pattern);
printf "No of hits (AND)= %.0f\n", $#ANS;
print join(", ", @ANS), "\n";
$end= time+ times[0];
printf "time taken %.2f\n", $end- $start;
########################
sub AndMatch {
# Syntax: = &AndMatch(ARRAY => \@Array, PATTERN => \@Pattern);
my %Q= @_;
my @PATTERN= @{$Q{PATTERN}};
my ($COND);
for ($i= 0; $i<= $#PATTERN; $i++) {
$PATTERN[$i]= "/".$PATTERN[$i]."/i";
}
$COND= join("&&", @PATTERN);
print "Matching: $COND...\n";
return grep(eval($COND), @{$Q{ARRAY}});
}
#End of Script ---------------------------------
--
Tommy Ho
Email: tkho@technologist.com
------------------------------
Date: 6 Mar 1998 22:18:23 GMT
From: "Seb" <shitonme@school.com>
Subject: http 1.0/500 Server Error (Why?)
Message-Id: <01bd494d$fb6bd720$3eae65cc@real.50carleton.com>
I get an http 1.0/500 Server Error everytime I try to run a .cgi. I'm
hosted on a win95 machine with pws. I'm running Perl for Win32. Does
anyone know what this error is? Please reply via email at:
seb@cyberdream.net
Seb
------------------------------
Date: Fri, 06 Mar 1998 23:38:29 +0100
From: Hermann Fass <hf@aia.com>
Subject: Re: Length of an array?
Message-Id: <35007AE5.3DC33546@aia.com>
Keith L. Miller wrote:
> how can I know what the length of the array ....
@myArray = split (.....);$length=$#myArray;
>
>
>
>
------------------------------
Date: Fri, 06 Mar 1998 16:52:40 -0600
From: Josh Kessler <jkessler@austx.tandem.com>
Subject: multi word unix commands and exec
Message-Id: <35007E38.64880EEB@austx.tandem.com>
I have run into a problem when trying to get a multi word system UNIX
command to work via an 'exec' command. I am working on a sun4 platform
with Perl 5.004. I am trying to alter the prompt using the 'set prompt='
command. How is this feat accomplished?
Works:
exec (date);
Does Not Work:
exec (set prompt=$some_string);
exec (set prompt=, "some_string_contents")
exec {'set prompt='} $some_string;
exec {'set prompt='}, $some_string;
exec ({'set prompt='} $some_string);
exec ("set prompt=$host");
Error message recieved on most of these is this:
Can't exec "set": No such file or directory at test.prl line 5.
The entire program is:
#! /usr/local/bin/perl5 -w
use Sys::Hostname;
$host = hostname();
print "$host\nhelp me out here!!\n";
exec ("set prompt=$host");
die "horrible death.\n";
--
Joshua Kessler, Tandem Computers - A Compaq Company,
jkessler@austx.tandem.com
"How do you know if a satellite is a moon?"
"If you approach it with a feather duster and it laughs, it's a moon.
:)"
------------------------------
Date: Fri, 06 Mar 1998 23:55:33 +0100
From: Hermann Fass <hf@aia.com>
Subject: Re: Need BMP to GIF converter
Message-Id: <35007EE5.18F2F0BD@aia.com>
What about ImageMagick?
------------------------------
Date: Fri, 6 Mar 1998 22:30:32 GMT
From: genepool@netcom.com (Jim Michael)
Subject: Re: Newbies question for Win32
Message-Id: <genepoolEpF56w.2z@netcom.com>
cyber giggy (cybergiggy@home.com) wrote:
: Hi
: I have just downloaded Perl for Win32. and successfully installing it.
: I beginning practicing writing in Perl in Notepad. afterward when I try to
: save it with a ".pl" . Notepad then save this as a ".txt" file. Example:
: hello.pl.txt
: Question #1. How can I save a file in Notepad with the .pl extension
Rename one of the files to get rid of the .txt so you just have myfile.pl,
then double-click on the file in the exploder, select Notepad as the
application to open it with, and check the box "always use this app to
open files of this type". Now you can save as .pl, and anytime you
double-click the file it will open in Notepad for editing. To run the
script use the syntax -
c:\perl myfile.pl argv_0 argv_etc
and make sure perl.exe is in your path. If you get a better editor such
as PFE32, just substitute that program for Notepad.
Cheers,
Jim
------------------------------
Date: Fri, 6 Mar 1998 18:23:34 -0500
From: "cyber giggy" <cybergiggy@home.com>
Subject: Re: Newbies question for Win32
Message-Id: <6dq0j7$im3@camel20.mindspring.com>
Thank Q Patrick Timmins & syrnyk
Ricky37@mindspring.com
------------------------------
Date: Fri, 6 Mar 1998 19:03:18 -0500
From: "cyber giggy" <cybergiggy@home.com>
Subject: Re: Newbies question for Win32
Message-Id: <6dq2tm$9mh@camel20.mindspring.com>
Thank Q Jim Michael.
CyberGiggy
ricky37@mindspring.com
------------------------------
Date: Fri, 6 Mar 1998 22:44:57 GMT
From: genepool@netcom.com (Jim Michael)
Subject: Re: Non Perl Question - Re: Newbies question for Win32
Message-Id: <genepoolEpF5ux.w9@netcom.com>
John Moreno (phenix@interpath.com) wrote:
: For everybody else - moderation? self-moderation (headers and killfile
: if the header is absent)? Flame away?
Everybody keeps talking about it but no RFD has been posted to
news.announce.newgroups, which is the proper place to discuss issues
relating to a reorg. Perhaps a couple of the most vocal proponents would
draft an RFD and post it?
Cheers,
Jim
------------------------------
Date: Fri, 6 Mar 1998 18:29:49 -0500
From: "cyber giggy" <cybergiggy@home.com>
Subject: Re: Non Perl Question - Re: Newbies question for Win32
Message-Id: <6dq0uu$k4r@camel20.mindspring.com>
Sorry John Moreno Please don't bit my head off. i'm a newbies at
this.(first time posting in Perl groupe) Promise to ONLY post Perl Question
in the future.
>
>For cyber giggy - this has nothing to do with perl. Ask elsewhere.
>
>For everybody else - moderation? self-moderation (headers and killfile
>if the header is absent)? Flame away?
>
>--
>John Moreno
------------------------------
Date: 06 Mar 1998 16:17:11 -0600
From: Stephen Potter <spp@colltech.com>
Subject: Re: Perl 4/5
Message-Id: <uu4t1b8nx4.fsf@psasolar.private.psa.pencom.com>
Geert Roovers <Geert.Roovers@POBoxes.com> writes:
> Hi All!
>
> I'm making my first steps on the Perl path, and sofar, I have one major
> problem. I can only find books teaching me Perl 5, but my system manager
> has only Perl 4 installed, and won't install the newest version. And I
> think there is where some of my problems are.
Actually, your problems are in your manager's head. Why in the name of God
is he interested in running a version of the language that has not been
actively supported for four years?
Oh boy... let's see. If you are lucky, you may be able to find first
edition copies of "Learning Perl", "Programming Perl", "Teach Yourself Perl
in 21 Days", or (if you are unlucky) "Perl by Example", all of which were
perl 4.0XX based. I wouldn't bet on it though, unless you get really lucky
in a used book store.
As for online documentation, we've been careful to mention how things that
worked in perl 4 work differently in perl 5 in the perltrap man page (of
course, you need perl 5 for this), but we've been pretty bad about saying
"This perl5 function wasn't available in perl 4."
I've seen a couple of "Quick Reference" type books out there that have 4/5
compatibility charts, but they may not help you much. I'd suggest talking
to your manager again, and seeing if you can convince him to upgrade. Feel
free to have him talk to us if he has questions.
-spp
--
Stephen P Potter |~~~~| |~~~~| spp@colltech.com
Ph: 312-781-1111 |____| C o l l e c t i v e |____| Team "OH, Yeah!"
Pg: 800-759-8888, |_______ _______| Webstreet Securities
571-1869 [] technologies [] jthome.jthome.com/~spp
a pencom company
------------------------------
Date: Fri, 6 Mar 1998 15:13:08 -0800
From: Jason Christian <jason@primal.ucdavis.edu>
Subject: Re: Perl 4/5
Message-Id: <Pine.OSF.3.95.980306150140.1609O-100000@primal.ucdavis.edu>
On 6 Mar 1998, Stephen Potter wrote:
> Geert Roovers <Geert.Roovers@POBoxes.com> writes:
> > Hi All!
> >
> > I'm making my first steps on the Perl path, and sofar, I have one major
> > problem. I can only find books teaching me Perl 5, but my system manager
> > has only Perl 4 installed, and won't install the newest version. And I
> > think there is where some of my problems are.
>
> Actually, your problems are in your manager's head. Why in the name of God
> is he interested in running a version of the language that has not been
> actively supported for four years?
If anyone got close enough to look, they would see that my scripts all have
the first line,
#!/home/jason/bin/perl
Waitaminnit, no they don't. It reads
#!/home/jason/bin/perl -w
(and I always always *always* check the values returned by open().)
I offer this tidbit to illustrate two points:
1. One needn't always pester the system manager with small matters like
upgrading from software that will not be made y2k compliant;
and
2. Even an innumerate and logic-challenged hayseed economist can figure
out how to successfully build a functional and up-to-date perl. If
such a differently-abled individual can do it, so can a trained and
intelligent person, like a system manager.
---------------------------------------------------------------------------
Jason Christian University of California, Davis
jason@primal.ucdavis.edu Agricultural and Resource Economics
Office:(530)752-1357 FAX:(530)752-5614 Davis, CA 95616
------------------------------
Date: Fri, 06 Mar 1998 23:12:56 GMT
From: meet@the.zoo (dave)
Subject: Perl code behaving badly on NT
Message-Id: <35008207.553334@news.isoc.net>
Hi,
Here is some code I'm trying to get working on NT: It just keeps
printing "I did not block!". What's wrong?
Thanks,
Dave
-- code begins here---
#/user/bin/perl -w
use IO::Select;
$sel = IO::Select->new();
$sel->add( \*STDIN );
for(;;)
{
if( @ready = $sel->can_read() )
{
print "Got some input.\n";
for $fh ( @ready )
{
if( $fh == STDIN )
{
print $inp if defined( $inp = <STDIN> );
}
}
}
print "I did not block!\n"; sleep 1;
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dlripberXisoc.net (sub X with shunned char)
http://www.isoc.net/dlripber
/--\./==\./ee\./oo\./--\
------------------------------
Date: 7 Mar 1998 00:41:06 GMT
From: ehagen@Hawaii.Edu (Eric Hagen)
Subject: Perl Interface to SSH?
Message-Id: <6dq532$i1l@news.Hawaii.Edu>
Hello all.
Has anyone put together scripts for perl to interact with ssh for remote
commands and file transfer? I would really like to move some of my telnet
and ftp scripts over to a ssh setup.
Any pointers?
Thank you.
--
Eric Hagen "Sometimes we get lost in the darkness,
ehagen@Hawaii.Edu the dreamers learn to steer by the stars..."
"You fight for something because it is good.
Not because it stands to succeed."
------------------------------
Date: Fri, 6 Mar 1998 15:09:58 -0700
From: Ralph Rickes <rickesr@pamco.com>
Subject: perl
Message-Id: <Pine.LNX.3.95.980306145530.13463C-100000@pooh.pamco.com>
Help. I have never used perl before, but I have to write a small program
to re-format an inventory file. The file has five fields right now. I
have to cut it down to three fields with different spec's. The first
second nd fourth fields are needed. Right now they are seperated by
tabs, and the second field has some single spaces. The 1st field is the
parts number, 2nd is description, 3rd is the price. I have looked through
a book I have on perl, but I can't find anything to help me copy, seperate
it and then print it out. Thank you.
Ralph R Rickes
Calgary, Alberta
rickesr@pamco.com
------------------------------
Date: 06 Mar 1998 18:23:46 -0500
From: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: perl
Message-Id: <g1kvwghp.fsf@news.concentric.net>
Ralph Rickes <rickesr@pamco.com> writes:
> Help. I have never used perl before, but I have to write a small program
> to re-format an inventory file.
> I have looked through
> a book I have on perl, but I can't find anything to help me copy, seperate
> it and then print it out. Thank you.
You'll have to do one of two things:
1) Hire someone who knows Perl.
2) Do a bit more than "look through a book." I'd recommend that you
buy and read _Learning Perl_. This newsgroup cannot teach you Perl.
--
Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
------------------------------
Date: Fri, 06 Mar 1998 16:11:02 -0700
From: Joe Schell <jschell@uswest.net>
To: Tze Weng Foong <tfoong@patrick.com.au>
Subject: Re: PerlW32 on NT, cannot use > or | why?
Message-Id: <35008286.8D0F0CD0@uswest.net>
You might want to try
C:> perl hello.pl >text.txt
This works for me under NT 4.0 workstation.
(I am guessing that without 'perl' NT shells
the command and redirecting picks up the shell
output not the script output. That is only
a guess however.)
---Joe
------------------------------
Date: Fri, 06 Mar 1998 19:48:22 -0500
From: joe.mcmahon@gsfc.nasa.gov (Joe McMahon)
Subject: Re: problems with one-liners on the command line
Message-Id: <joe.mcmahon-0603981948220001@prtims.stx.com>
>perl -p -e /ea.{1,3}/ && print $_; lexicon.txt
>perl -p -e m/ea.{1.3}/ && print $_; lexicon.txt
>perl -p -e if(m/ea.{1,3}/) {print $_; } lexicon.txt
>perl -p -e if(m/ea{1,3}/) {print $_ }; lexicon.txt
>perl -p -e if(m/ea{1,3}/) {print $_; }; lexicon.txt
>perl -p -e if(m/ea{1,3}/) {print $_ } lexicon.txt
>
>so, those are my attempts at one-liners...
Single-quote these to prevent the shell from wreaking havoc:
perl -p -e '/ea.{1,3}/ && print $_;' lexicon.txt
You get the idea. The program goes in single quotes; escape single quotes
if you have to use them (to prevent premature quotation).
--- Joe M.
------------------------------
Date: 06 Mar 1998 17:03:29 -0600
From: Stephen Potter <spp@colltech.com>
Subject: Re: Q: obscuring Perl scripts?
Message-Id: <uuzpj3777i.fsf@psasolar.private.psa.pencom.com>
markw@markwatson.com (Mark Watson) writes:
> Sorry if this is a FAQ (I looked), but are there any
> tools for (slightly) obscuring Perl scripts; something
> simple like converting variable names to a1, a2, etc.?
> Thanks for any info,
> Mark
Give it to Randal, he's really good at this kind of thing. ;-)
-spp
--
Stephen P Potter |~~~~| |~~~~| spp@colltech.com
Ph: 312-781-1111 |____| C o l l e c t i v e |____| Team "OH, Yeah!"
Pg: 800-759-8888, |_______ _______| Webstreet Securities
571-1869 [] technologies [] jthome.jthome.com/~spp
a pencom company
------------------------------
Date: Fri, 06 Mar 1998 23:41:01 +0100
From: Hermann Fass <hf@aia.com>
Subject: Re: Quoting ^M?
Message-Id: <35007B7D.A745885D@aia.com>
\r
>
------------------------------
Date: 06 Mar 1998 17:13:56 -0600
From: Quentin Fennessy <quentin@jihad.amd.com>
Subject: Re: removing new line (\n)
Message-Id: <ximsoovxvij.fsf@jihad.amd.com>
Zylbersztejn Nathan <nathan@imagine.be> writes:
> when I put the lines of a text in an @array how do i remove the "new
> line "(\n).
> s/\\n/ / doesn't work
Try
perldoc -f chomp
perldoc -f chop
--
Quentin Fennessy AMD, Austin Texas
------------------------------
Date: Fri, 06 Mar 1998 23:40:23 GMT
From: kktan@concentric.net (Kim Kiat Tan)
Subject: rsh hanging...
Message-Id: <6dq1ra$80o@examiner.concentric.net>
I have the following code :
#! /usr/bin/perl
$out = `rsh rmthost .\test`;
...
the problem is that if the remote program test hung for some reason, the
perl script will never exit. Is there setting to set the time out period for
rsh command ? or is there a way to set the maximum time the perl script can
run ?
what I like is to kill the rsh command after certain time and print out time
out message, if not, jsut kill the perl script will do as well.
I have similar problem if instead of using the backtick, I am piping the
output of the rsh command..
thanks...
------------------------------
Date: 6 Mar 1998 22:33:27 GMT
From: shaug@gromit.callamer.com (O'Shaughnessy Evans)
Subject: Re: safe file modification strategy (w/flock, new_tmpfile, and syscopy?)
Message-Id: <6dptjn$f5$1@ha1.rdc1.occa.home.com>
[ courtesy copy cc'd to Randal ]
In article <8c1zwh40ex.fsf@gadget.cscaper.com>,
Randal Schwartz 's keyboard spewed forth thus:
>
> open file for read/write
> flock file exclusive
> compare dev/ino of file to dev/ino of handle, if not same, loop back
> read from file, writing to file2
> rename file2 to file (deleting file)
> close handle (releasing the flock)
So... a couple of other questions:
1) Since I'm doing the rename, I shouldn't close(TMP), right?
Or should I close TMP and not FILE, since (I think) I've lost
my inode entry for $file by doing the rename? But that might
give me trouble with the lock, unless Perl or the kernel knows
to release it when the inode disappears.
Sketchy ... understanding ... of Unix ... filesystem ...
internals. Must ... resist.
2) rename() doesn't accept a file handle, does it? If not, as I
suspect from the POD, then I can't use IO::File::new_tmpfile().
If that's the case, then does everyone agree that $file.$$ is
the best temporary name? It seems that I could muck around,
trying /tmp/`basename $file` and awkward stuff like that, but
$file.$$ just seems simpler.
Again, thanks for the I/O.
--
- O'Shaughnessy Evans
- http://www.callamerica.net/shaug/
------------------------------
Date: Fri, 06 Mar 1998 15:14:38 -0800
From: Rob Thorne <rthorne@netscape.com>
To: Harald Joerg <Harald.Joerg@mch.sni.de>
Subject: Re: Using pod2html.pl on Win32
Message-Id: <3500835D.D12FF56@netscape.com>
Harald,
Much thanks to you and to the others who replied!
pod2html.bat worked pretty well. I had to munge the HTML a little bit, but
in all, it saved me a lot of work.
Thanks,
Rob
Harald Joerg wrote:
> [mailed and posted]
>
> Rob Thorne wrote:
> >
> > I have written some Perl modules, in which I've included POD
> > documentation. The modules now work, but I'm having trouble getting
> > HTML out of the .PM files.
> >
> > I've gone through the Perlpod page, and I've also read the stuff inside
> > pod2html.pl. It looks like I should be able to do something like this,
> > and get out HTML:
> >
> > perl pod2html.pl < MyModule.pm > MyModule.html
>
> Usually I say
> pod2html --infile=MyModule.hm --outfile=MyModule.html
> to my computer, which works on many operating systems and on Win32.
> You can find out more about the various switches by typing
> pod2html --help
> or, still more, with
> perldoc pod2html
> With 5.004 for Win32, start exercising with:
> pod2html --infile=pod2html.bat --outfile=pod2html.html
> (Gurusamy Sarathy's binary distribution for Win32 has
> pod2html.bat, but no pod2html.pl)
> --
> Oook,
> --haj--
------------------------------
Date: Fri, 6 Mar 1998 16:08:19 -0600
From: "Jack Lavender" <jackal@fastlane.net>
Subject: Win32 help request, rename problem
Message-Id: <6dps63$91d@news.cybernews.net>
I am running the ActiveState port of perl 3.15 on a NT box with MS Personal
Web Server.
I have a problem using the rename function. If I run the following script
from the command line and the destination file exists, then rename fails.
If I run the script
from the Server, it fails every time.
Anyone else have this kind of problem? I am just learning, so I am not sure
about the expected behaviors.
Thanks
jack lavender
jackal@fastlane.net
----------------------------------------------------
$lock='C:/temp/';
$temp_file = "$lock$$.tmp";
$stem = 'temp1';
$lock_file = "$lock$stem.tmp";
print "Content-type: text/html\n\n";
if (!open(TEMP, ">$temp_file")) {
$Error_Message = "Could not create $temp_file ($!).";
print "$Error_Message";
exit;
}
print TEMP $$;
close(TEMP);
if ((-e $lock_file) && (-M $lock_file < 0))
{
print "Exists?\n";
}
else
{
$temp = rename("$temp_file","$lock_file");
print "$temp_file ($temp) -> $lock_file\n";
}
------------------------------
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 2044
**************************************