[23906] in Perl-Users-Digest
Perl-Users Digest, Issue: 6108 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Feb 10 18:05:58 2004
Date: Tue, 10 Feb 2004 15:05:11 -0800 (PST)
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, 10 Feb 2004 Volume: 10 Number: 6108
Today's topics:
Re: A non-loop block early exit? <bmb@ginger.libs.uga.edu>
Re: A non-loop block early exit? <dwall@fastmail.fm>
Re: Array size (Anno Siegel)
Re: Comparing a string to filenames in a directory (nj_perl_newbie)
Re: Comparing a string to filenames in a directory <remorse@partners.org>
Re: Comparing a string to filenames in a directory <tadmc@augustmail.com>
Re: Comparing a string to filenames in a directory <usenet@morrow.me.uk>
Does anyone have the unpack template for wtmp on HPUX? <nobody@nowhere.com>
Re: Does anyone have the unpack template for wtmp on HP <usenet@morrow.me.uk>
Re: Does anyone have the unpack template for wtmp on HP (Walter Roberson)
Re: file size OT <Joe.Smith@inwap.com>
generate a list of file extensions? <me@privacy.net>
Re: Include data in a perl program? <me@privacy.net>
Launching an .exe <>
Re: Launching an .exe <usenet@morrow.me.uk>
Re: memory profiling ctcgag@hotmail.com
Re: Perl usage these days? <xxala_qumsiehxx@xxyahooxx.com>
Re: Perl usage these days? <Joe.Smith@inwap.com>
Proc::Background killing parent process when child dies (Paul Clements)
Re: return status for nonexistent command run in backti (Jeff)
Re: return status for nonexistent command run in backti <usenet@morrow.me.uk>
Term::Prompt broken? Or am I misreading documentation? (Daniel M. Drucker)
Re: trying to create a network script: <Nex6@nospam.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 10 Feb 2004 11:40:01 -0500
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: A non-loop block early exit?
Message-Id: <Pine.A41.4.58.0402101136250.27212@ginger.libs.uga.edu>
On Tue, 10 Feb 2004, Gunnar Hjalmarsson wrote:
> Sara wrote:
> > Can I exit a block early, as "last" operator does in a loop?
> > Such as:
> >
> > unless ($catsHaveWings)
> > {..do stuff
> > "escape" if $dogsHaveFins;
> > .. do more stuff
> > }
> > # I want "escape" to reenter HERE
>
> You can do:
>
> unless ($catsHaveWings) {
> MYBLOCK: {
> ..do stuff
> last MYBLOCK if $dogsHaveFins;
> .. do more stuff
> }
> }
And FWIW, the extra block need not be named, though it's arguably clearer
that way ...
my $catsHaveWings = 0;
my $dogsHaveFins = 1;
unless ($catsHaveWings) {{
#..do stuff
print "doing stuff\n";
#"escape" if $dogsHaveFins;
last if $dogsHaveFins;
#.. do more stuff
print "doing more stuff\n";
}}
# I want "escape" to reenter HERE
print "I'm HERE now.\n";
__END__
doing stuff
I'm HERE now.
Regards,
Brad
------------------------------
Date: Tue, 10 Feb 2004 20:20:49 -0000
From: "David K. Wall" <dwall@fastmail.fm>
Subject: Re: A non-loop block early exit?
Message-Id: <Xns948B9C1DC1020dkwwashere@216.168.3.30>
Sara <genericax@hotmail.com> wrote:
> Can I exit a block early, as "last" operator does in a loop? Such as:
>
>
> unless ($catsHaveWings)
> {..do stuff
> "escape" if $dogsHaveFins;
> .. do more stuff
> }
> # I want "escape" to reenter HERE
You're already using one 'unless' block. Why not two?
unless ($catsHaveWings) {
# do stuff here
print "Doing stuff\n";
unless ($dogsHaveFins) {
print "Doing more stuff\n";
}
}
If you *really* need it, Perl does have goto, although I wouldn't use it to
jump more than a few lines if I used it at all. More explicitly: goto can
turn code into a mass of spaghetti and so should be used sparingly at most.
("You have entered a maze of twisty GOTOs, all alike...")
unless ($catsHaveWings) {
print "2 Doing stuff\n";
goto DOGS_HAVE_FINS if $dogsHaveFins;
#.. do more stuff
print "2 Doing more stuff\n";
}
DOGS_HAVE_FINS:
--
David Wall
------------------------------
Date: 10 Feb 2004 19:51:08 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Array size
Message-Id: <c0bcnc$mqb$2@mamenchi.zrz.TU-Berlin.DE>
David Dyer-Bennet <dd-b@dd-b.net> wrote in comp.lang.perl.misc:
[perlreftut and perlref]
> Yes, read them, too. None of the man pages give a clue about how to
> apply $# to a reference. At least not a clue that can be *found*.
That would in part depend on who does the searching, wouldn't it?
Anno
------------------------------
Date: 10 Feb 2004 11:29:36 -0800
From: aotoole@optonline.net (nj_perl_newbie)
Subject: Re: Comparing a string to filenames in a directory
Message-Id: <d7fb9254.0402101129.6b9130a1@posting.google.com>
Thanks for the quick feedback.
I have made some edits based on your suggestions, and I have a better
unserstanding of what was happening in the script. I still do not
understand how the script knows that it should compare the second
field in the file to the filenames in the limbo dir.
# Opens limbodir and reads the filenames for later comparison
&log_entry($logfh,"About to open limbodir") if $debug;
opendir(DIR, $limbodir);
chdir("$limbodir") or die "Could not cd into $limbodir: $!\n";
&log_entry($logfh,"Opening Limbo Directory") if $debug;
#@files = grep { /\.csv$/ } readdir(DIR);
#&log_entry($logfh, "Files in limbodir read") if $debug;
#closedir(DIR);
open (FILE, "$input_file") or die("Cannot open file $dnfrm_file
because
$!\n");
while (<FILE>) { #not sure if the while is needed
#my @line = split /\,/, $_;
#my($firstfield, $filename, $junk) = @line;
my (undef, $filename, undef) = split /,/;
unless ( $firstline ) {
#attempts to match the filename submitted in the confirm file with
an already existing input file in the limbo directory
if (-e $filename) {
&log_entry($logfh, "Confirm submitted by $username for input
file $path/$basename ");
move ("$_", "$transdir/$basename") or die "move failed: $!";
&log_entry($logfh, "$_ moved to $transdir");
chown 23456,23458, "$transdir/$_" or warn $!;
}
undef $firstline;
------------------------------
Date: Tue, 10 Feb 2004 17:16:34 -0500
From: Richard Morse <remorse@partners.org>
Subject: Re: Comparing a string to filenames in a directory
Message-Id: <remorse-FBC0E3.17163410022004@plato.harvard.edu>
In article <d7fb9254.0402101129.6b9130a1@posting.google.com>,
aotoole@optonline.net (nj_perl_newbie) wrote:
> Thanks for the quick feedback.
>
> I have made some edits based on your suggestions, and I have a better
> unserstanding of what was happening in the script. I still do not
> understand how the script knows that it should compare the second
> field in the file to the filenames in the limbo dir.
>
> # Opens limbodir and reads the filenames for later comparison
> &log_entry($logfh,"About to open limbodir") if $debug;
> opendir(DIR, $limbodir);
> chdir("$limbodir") or die "Could not cd into $limbodir: $!\n";
> &log_entry($logfh,"Opening Limbo Directory") if $debug;
> #@files = grep { /\.csv$/ } readdir(DIR);
> #&log_entry($logfh, "Files in limbodir read") if $debug;
> #closedir(DIR);
>
> open (FILE, "$input_file") or die("Cannot open file $dnfrm_file
> because
> $!\n");
>
> while (<FILE>) { #not sure if the while is needed
>
> #my @line = split /\,/, $_;
> #my($firstfield, $filename, $junk) = @line;
> my (undef, $filename, undef) = split /,/;
> unless ( $firstline ) {
> #attempts to match the filename submitted in the confirm file with
> an already existing input file in the limbo directory
> if (-e $filename) {
> &log_entry($logfh, "Confirm submitted by $username for input
> file $path/$basename ");
> move ("$_", "$transdir/$basename") or die "move failed: $!";
> &log_entry($logfh, "$_ moved to $transdir");
> chown 23456,23458, "$transdir/$_" or warn $!;
> }
> undef $firstline;
How about this:
use strict;
use warnings;
opendir(my $dir, $limbodir) or die("could not opendir $limbodir: $!");
my @files = grep { /\.csv$/ } readdir($dir);
closedir($dir);
open(my $file, "<", $dnfrm_file) or die("could not open $dnfrm_file:
$!");
while(<$file>) {
chomp;
my ($firstfield, $filename, $rest) = split /,/;
if (defined($filename) and ($filename ne '') and
(-e "$limbodir/$filename") {
move("$_", "$transdir/$basename") or die("move failed: $!");
}
}
I'm not too sure about some of the steps you are taking -- that move
call seems a bit complicated -- but this might be a bit clearer...
HTH,
Ricky
------------------------------
Date: Tue, 10 Feb 2004 16:01:31 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Comparing a string to filenames in a directory
Message-Id: <slrnc2il5r.5jk.tadmc@magna.augustmail.com>
nj_perl_newbie <aotoole@optonline.net> wrote:
> I apologize for posting such a basic question...I have spent a
> substantial ammount of time reading thick books trying to figure out
> how to do this.
Have you seen the Posting Guidelines that are posted here frequently?
> Here's what I have:
>
> opendir(DIR, $limbodir);
> &log_entry($logfh,"Opening Limbo Directory"); if $debug;
^^^^
That is not Perl code.
If you need help with your Perl program, then you should post
the actual Perl program.
If your question is about the syntax error, then you should ask
a question about the syntax error.
> my @line = split /\,/, $_;
> my($firstfield, $filename, $junk) = @line;
The @line temporary variable is not needed:
my($firstfield, $filename, $junk) = split /\,/, $_;
or even
my($firstfield, $filename) = split /\,/, $_;
> chown 23456,23458, "$transdir/$_" || warn $!;
It is easier to work with permissions if you think in octal
rather than in decimal...
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 10 Feb 2004 22:42:27 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Comparing a string to filenames in a directory
Message-Id: <c0bmoj$q2k$1@wisteria.csv.warwick.ac.uk>
tadmc@augustmail.com wrote:
> nj_perl_newbie <aotoole@optonline.net> wrote:
> > chown 23456,23458, "$transdir/$_" || warn $!;
>
> It is easier to work with permissions if you think in octal
> rather than in decimal...
chown, not chmod... :)
It's likely to be more future-proof if you get the [ug]id using
get{pw,gr}nam.
Ben
--
perl -e'print map {/.(.)/s} sort unpack "a2"x26, pack "N"x13,
qw/1632265075 1651865445 1685354798 1696626283 1752131169 1769237618
1801808488 1830841936 1886550130 1914728293 1936225377 1969451372
2047502190/' # ben@morrow.me.uk
------------------------------
Date: 10 Feb 2004 17:20:37 GMT
From: Christian Lair <nobody@nowhere.com>
Subject: Does anyone have the unpack template for wtmp on HPUX?
Message-Id: <Xns948B739FDBC4clairnospami2com@63.218.45.21>
I originally posted this to comp.lang.perl but it seems that most of the
people have moved here so I'll post here.
I'm trying to write a perl script that will parse the contents of the wtmp
file on HPUX. I've looked through the utmp headers and can't quite get the
unpack
template right. Here's what I've been trying:
$hp_utmp_template = "A8 A4 A12 l s s2 x2 l2 l A24 L";
but it doesn't seem to work. When I run the script using simple print
statements as a test it comes back with garbage. Anyone have a working
template or see what I've done wrong with my template?
From what I can tell the problem lies in the PID field. When I run the
script the first line of the wtmp is parsed correctly until it gets to the
PID field. The value returned from that field is this: 410320903 which is
WAY off. This of course throws off everything after it. I've been just
grasping at straws trying to change that part of the template but just
can't get it working. Any ideas?
Thanks,
Christian
------------------------------
Date: Tue, 10 Feb 2004 17:44:18 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Does anyone have the unpack template for wtmp on HPUX?
Message-Id: <c0b59i$g12$1@wisteria.csv.warwick.ac.uk>
Christian Lair <nobody@nowhere.com> wrote:
> I originally posted this to comp.lang.perl but it seems that most of the
> people have moved here so I'll post here.
comp.lang.perl was rmgrouped quite a long time ago.
> I'm trying to write a perl script that will parse the contents of the wtmp
> file on HPUX. I've looked through the utmp headers and can't quite get the
> unpack
> template right. Here's what I've been trying:
>
> $hp_utmp_template = "A8 A4 A12 l s s2 x2 l2 l A24 L";
>
> but it doesn't seem to work. When I run the script using simple print
> statements as a test it comes back with garbage. Anyone have a working
> template or see what I've done wrong with my template?
>
> From what I can tell the problem lies in the PID field. When I run the
> script the first line of the wtmp is parsed correctly until it gets to the
> PID field. The value returned from that field is this: 410320903 which is
> WAY off. This of course throws off everything after it. I've been just
> grasping at straws trying to change that part of the template but just
> can't get it working. Any ideas?
Can you write a little C program that prints out sizeof() and
offsetof() (if you don't have offsetof, it's
#define offsetof(struct, member) ((size_t) &((struct *)0)->member)
) for each member of the struct? I've never used HP-UX but should be
able to work out the template from that.
As a random guess, should some of those fields be ! fields (use the
compiler's own longs/shorts, rather than exactly 16- or 32-bits)?
You might also want to look at User::Utmp, which uses your system's
own getut* functions.
Ben
--
For the last month, a large number of PSNs in the Arpa[Inter-]net have been
reporting symptoms of congestion ... These reports have been accompanied by an
increasing number of user complaints ... As of June,... the Arpanet contained
47 nodes and 63 links. [ftp://rtfm.mit.edu/pub/arpaprob.txt] * ben@morrow.me.uk
------------------------------
Date: 10 Feb 2004 21:53:06 GMT
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Subject: Re: Does anyone have the unpack template for wtmp on HPUX?
Message-Id: <c0bjs2$399$1@canopus.cc.umanitoba.ca>
In article <Xns948B739FDBC4clairnospami2com@63.218.45.21>,
Christian Lair <nobody@nowhere.com> wrote:
:I'm trying to write a perl script that will parse the contents of the wtmp
:file on HPUX. I've looked through the utmp headers and can't quite get the
:unpack
:template right. Here's what I've been trying:
:$hp_utmp_template = "A8 A4 A12 l s s2 x2 l2 l A24 L";
:From what I can tell the problem lies in the PID field. When I run the
:script the first line of the wtmp is parsed correctly until it gets to the
:PID field. The value returned from that field is this: 410320903 which is
:WAY off.
What value were you expecting for that field? 6261 perchance?
410320903 is hex 0x18750007 which broken into integers would be
6261 and 7. The field after ut_pid in utmp.h is ut_type for which
the value 7 would mean USER_PROCESS which looks plausible.
Where are you getting your definition of the utmp structure from?
The structure you are using is not the same one as I find documented at
http://www.informatik.uni-frankfurt.de/doc/man/hpux/utmp.4.html
Your s2 must be the struct exit_status. The x2 after must then
be the unsigned short ut_reserved1 (makes sense, skipping a reserved
word.)
After that in utmp is time_t ut_time, and time_t is a long according to
http://www.informatik.uni-frankfurt.de/doc/man/hpux/types.5.html
You have l2 at that point in the template, not l, so let's look at
the next field. The next field is char ut_host[16] so the 2nd' l
of your l2 is going to overlay the first l of ut_host[16]. How long
is a long in HPUX? Looking ahead in your template, the A24 is
probably what is intended to match ut_host but there is even more
in your template before getting there that does not appear to be
in the hpux struct utmp . Unless, that is, there is a completely
different utmp format for a later revision...
I don't use HPUX at all. In SGI's IRIX that I use most, pid_t is
a short, and there is no reserved field before the ut_time and
no ut_host or ut_addr.
--
I predict that you will not trust this prediction.
------------------------------
Date: Tue, 10 Feb 2004 21:01:33 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: file size OT
Message-Id: <NEbWb.214419$Rc4.1723876@attbi_s54>
Jeff Thies wrote:
>>>I've figured out how to return the number of bytes uploaded/saved back
>
> to
>
>>>the browser. What I haven't figured out is how to read the file's size,
>>>either client or server side (perl), so I can calculate a percentage.
>>
>>The size of the file on the server is
>> $size = -s $file;
>
>
> That looks like the file size is not available until after the file has been
> saved.
> Is that right?
Depends on the OS and the module used for uploads.
Unix-like OSes let you see the size of the file while it is being
written, others show zero bytes until the file is closed.
CGI.pm provides access to the file after it has been completely
uploaded; for do-it-yourself solutions you can count the number
of decoded bytes that you are writing to the file.
-Joe
------------------------------
Date: Tue, 10 Feb 2004 14:43:49 -0800
From: "davido@codethought.nospamforme.com" <me@privacy.net>
Subject: generate a list of file extensions?
Message-Id: <ckni20tl53oh0gsf1lm3m6tcp7c19ql59l@4ax.com>
I need to scan a directory tree and generate a list of file extensions
from that tree for a search against a database. That way I can be
sure the database is properly updated based on all of the extensions
in this directory. The directory amounts to projects code and binary
files. I know how to use File::Find to search a list of file types
and get their *names*. Would searching and getting the file types be
basically the same thing?
Could someone point me at some code that could help me accomplish
this? Much appreciated.
------------------------------
Date: Tue, 10 Feb 2004 13:56:53 -0800
From: David O in Seattle <me@privacy.net>
Subject: Re: Include data in a perl program?
Message-Id: <ppki20d1967ke5vrd6fi73hjquo5vdha2d@4ax.com>
On Mon, 9 Feb 2004 22:31:36 +0000 (UTC), Ben Morrow
<usenet@morrow.me.uk> wrote:
>
>David O in Seattle <me@privacy.net> wrote:
>> I'm writing a PERL
>
>Perl or perl.
Umm.. ok...
>
>If you can't, you want to do the same thing but write some code to
>parse the .reg format yourself: it's pretty simply :).
>
>Ben
Turns out the file that's created by the Perl modules is a binary
"save" file and not the text-based 'reg' export file. So to use the
text file, I'd have to write the code to insert every key. While
that's certainly doable, I'm under a bit of a time contraint.
Thanks tho. I appreciate your input.
------------------------------
Date: Tue, 10 Feb 2004 14:42:02 -0500
From: lmm <>
Subject: Launching an .exe
Message-Id: <m4ci209406brvbbohqjur3shto1q3mnrnv@4ax.com>
I have written a script that that is supposed write a host file, open
a Windows executable file, sends out a few pings and then runs a batch
file that maps drives.
The problem I am having is that the the script stops after the
executable is launched. Presumably because it does not close and
therefore the script "hangs." The .exe is a VPN client so it cannot
run last. When I decided to add the pings and the batch file the
script stopped working, of course now I realize it was never working
as expected.
I have tried the following code to launch the exe:
my $exe = '"C:/Program Files/SonicWALL/SonicWALL Global VPN
Client/SWGVpnClient.exe"' ;
exec $exe ;
I also tried putting the above in a separate script and then a batch
file and having the script launch that and finally what is written
below. So I guess I need a way to launch the exe and then have the
Perl script move forward.
if ($loc eq "n") {
print "Writing the non-VPN hosts file.\n" ;
print HOSTS $not ; #write the file
print "Wrote non-VPN hosts file.\nYou may close this window by
typing exit or clicking the X\n" ;
} else {
print "Writing the VPN hosts file.\n" ;
print HOSTS $vpn ; #write the file
#opens the VPN Client software
print `C:/Program Files/SonicWALL/SonicWALL Global VPN
Client/SWGVpnClient.exe` ;
print `ping -n 10 gwdc` ;
print `C:/VPN/BAT//WIN2KLOGONFDQN.BAT` ;
print "Wrote VPN hosts file and executed LOGON script.\nYou may
close this window by clicking the X\n" ;
}
------------------------------
Date: Tue, 10 Feb 2004 20:20:52 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Launching an .exe
Message-Id: <c0bef4$kg4$1@wisteria.csv.warwick.ac.uk>
lmm <> wrote:
> I have written a script that that is supposed write a host file, open
> a Windows executable file, sends out a few pings and then runs a batch
> file that maps drives.
>
> The problem I am having is that the the script stops after the
> executable is launched. Presumably because it does not close and
> therefore the script "hangs." The .exe is a VPN client so it cannot
> run last. When I decided to add the pings and the batch file the
> script stopped working, of course now I realize it was never working
> as expected.
>
> I have tried the following code to launch the exe:
>
> my $exe = '"C:/Program Files/SonicWALL/SonicWALL Global VPN
> Client/SWGVpnClient.exe"' ;
> exec $exe ;
Read the docs for exec. Exec will never return: it replaces the Perl
process with the vpn client.
> I also tried putting the above in a separate script and then a batch
> file and having the script launch that and finally what is written
> below. So I guess I need a way to launch the exe and then have the
> Perl script move forward.
To do this under Windows you can either
1. try using the fork emulation:
my $pid = fork;
defined $pid or die "can't fork: $!";
unless ($pid) {
exec $exe;
die "exec failed: $!";
}
which in theory ought to work as of perl-5.6, but I've never had any
luck with it; or
2. use Win32::Process, passing the DETACHED_PROCESS flag.
Ben
--
Joy and Woe are woven fine,
A Clothing for the Soul divine William Blake
Under every grief and pine 'Auguries of Innocence'
Runs a joy with silken twine. ben@morrow.me.uk
------------------------------
Date: 10 Feb 2004 17:56:44 GMT
From: ctcgag@hotmail.com
Subject: Re: memory profiling
Message-Id: <20040210125644.443$9N@newsreader.com>
Jaap Karssenberg <j.g.karssenberg@student.utwente.nl> wrote:
> On 10 Feb 2004 01:18:10 GMT ctcgag@hotmail.com wrote:
> : Jaap Karssenberg <j.g.karssenberg@student.utwente.nl> wrote:
> : > Does anyone know of a simple way to see where the memory goes in a
> : > large perl application ?
> :
> : Depends on how modular the application is.
>
> It's kinda modular, if can figure out the memory usage per module that
> would make a good start for further analysis. So what do you suggest ?
When I have no idea where the memory could be going, usually I already have
a driver for each module, so I just rig it up to run a psuedo-workload on
each module separately and check the mem usage using "top" or whatever.
But I am proud (or perhaps ashamed) to say I've used Acme::Abuse to run
each module (in turn) in a separate interpreter, and just compared the
sizes of the respective processes, when I wasn't able to readily make a
realistic driver.
But the thing I most often use is just Data::Dumper, as usually there are
only a handful of suspects as to where the memory could be going.
warn "suspect1 is ",length Dumper(\%suspect1); # give rough estimate of
size
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service New Rate! $9.95/Month 50GB
------------------------------
Date: Tue, 10 Feb 2004 19:51:14 GMT
From: "Ala Qumsieh" <xxala_qumsiehxx@xxyahooxx.com>
Subject: Re: Perl usage these days?
Message-Id: <SCaWb.11250$Zl2.2454@newssvr29.news.prodigy.com>
<thumb_42@yahoo.com> wrote in message
news:8s4Wb.270436$xy6.1380339@attbi_s02...
> What is perl being used for these days?
>
> Seems almost everything web related I see is PHP or Java. (mostly PHP)
I have been using Perl at work on almost a daily basis for at least 6 years,
at three different companies in two different countries. Nothing of what I
do is web or IT related.
--Ala
------------------------------
Date: Tue, 10 Feb 2004 21:22:19 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: Perl usage these days?
Message-Id: <fYbWb.276857$na.437280@attbi_s04>
thumb_42@yahoo.com wrote:
> What is perl being used for these days?
>
> Seems almost everything web related I see is PHP or Java. (mostly PHP)
>
> My own experience is that Perl is wonderful for batch processing, command
> line stuff, cron and specialized servers but compared to what is available
> today, really doesn't seem suitable for serious web applications anymore.
http://www.slashcode.com/faq.shtml#Slashcodecom0
-Joe
------------------------------
Date: 10 Feb 2004 13:47:25 -0800
From: paul.clements@istrat.co.uk (Paul Clements)
Subject: Proc::Background killing parent process when child dies
Message-Id: <f2746386.0402101347.64ea4f4b@posting.google.com>
Hi,
I have a perl script which spawns processes by use of Proc::Background
and this works fine.
One of the child processes accesses a database and if that database is
down I want as well as the child process to die, I want the parent
process to exit.
Any clues on how to do this would be very much appreciated
Regards
Paul
------------------------------
Date: 10 Feb 2004 09:35:22 -0800
From: jeffjackson@fairisaac.com (Jeff)
Subject: Re: return status for nonexistent command run in backticks
Message-Id: <1b0085c0.0402100935.18b4a204@posting.google.com>
Glenn Jackman <xx087@freenet.carleton.ca> wrote in message news:<slrnc2g1mr.kid.xx087@smeagol.ncf.ca>...
> Jeff <jeffjackson@fairisaac.com> wrote:
> > sub statCheck
> > {
> > my ($childError) = @_;
> > my ($rc, $core, $sig);
> >
> > return (undef, undef, undef) if (not defined $childError);
> >
> > $rc = $childError >> 8;
> > $core = $childError & 128 ? TRUE : FALSE;
> > $sig = $childError & 127;
> >
> > return ($rc, $core, $sig);
> > }
> >
> > this works fine most of the time. but if i call a command that
> > doesn't exist, $? = -1 and this logic blows up. i can put a check in
> > here for -1 easily enough, but my question to you all is should
> > backticks be returning -1 ever? if i try running a nonexistent
> > command from the shell prompt (ksh), i get a return status of 127 (as
> > the man page for ksh says it should).
>
> I don't see where it "blows up". If $childError == -1, then $rc might
> be 16777215. What does the caller of statCheck do with its returned
> value?
>
> However, you can check for $childError == -1, and do something with $!
> which contains the reason for failure.
>
> Or, you can use a mask to only get an 8 bit value for $rc:
> $rc = ($childError & 0xff00) >> 8;
> which would make $rc == 255 if $childError == -1
i guess my real question is why is the return status = 127 when i type
a nonexistent command at the shell prompt and = -1 when i run it from
a perl program? for now i guess i'll put a check in for -1 and assume
that means the command didn't exist.
jj
------------------------------
Date: Tue, 10 Feb 2004 17:52:10 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: return status for nonexistent command run in backticks
Message-Id: <c0b5oa$g12$3@wisteria.csv.warwick.ac.uk>
jeffjackson@fairisaac.com (Jeff) wrote:
> i guess my real question is why is the return status = 127 when i type
> a nonexistent command at the shell prompt
Because that's what ksh does.
> and = -1 when i run it from a perl program?
Because that's what Perl does. perldoc -f system.
> for now i guess i'll put a check in for -1 and assume that means
> the command didn't exist.
No need to assume, it's documented.
Ben
--
And if you wanna make sense / Whatcha looking at me for? (Fiona Apple)
* ben@morrow.me.uk *
------------------------------
Date: 10 Feb 2004 13:51:09 -0800
From: dmd@3e.org (Daniel M. Drucker)
Subject: Term::Prompt broken? Or am I misreading documentation?
Message-Id: <b804d06d.0402101351.66aab5c8@posting.google.com>
Term::Prompt appears to be either very badly broken ... or I'm
completely misreading the documentation.
Term::Prompt's menuing system really doesn't seem to behave anything
like described in the documentation.
In this script, only the first prompt displays a menu at all, and
misnumbered, at that.
Can ANYONE tell me if I'm doing something wrong, or if this is a bug
in Term::Prompt?
Daniel Drucker
dmd@3e.org
#!/usr/bin/perl
use Term::Prompt;
my @fruits = qw(apple orange pear tomato grapefruit apricot peach);
my $fruitnum = &prompt("m", {
prompt => "Choose:",
title => "Fruits",
items => [@fruits],
order => 'down',
accept_empty_selection => 0,
accept_multiple_selections => 0,
});
print "you chose " . $fruits[$fruitnum] . "\n";
print "\n=============\n";
my $fruitnum = &prompt("m", {
prompt => "Choose:",
title => "Fruits",
items => [@fruits],
order => 'down',
cols => 1,
accept_empty_selection => 0,
accept_multiple_selections => 0,
});
print "you chose " . $fruits[$fruitnum] . "\n";
print "\n=============\n";
my $fruitnum = &prompt("m", {
prompt => "Choose:",
title => "Fruits",
items => [@fruits],
order => 'across',
accept_empty_selection => 0,
accept_multiple_selections => 0,
});
print "you chose " . $fruits[$fruitnum] . "\n";
print "\n=============\n";
my $fruitnum = &prompt("m", {
prompt => "Choose:",
title => "Fruits",
items => [@fruits],
order => 'across',
rows => 1,
accept_empty_selection => 0,
accept_multiple_selections => 0,
});
print "you chose " . $fruits[$fruitnum] . "\n";
print "\n=============\n";
------------------------------
Date: Tue, 10 Feb 2004 14:57:25 -0800
From: Nex6 <Nex6@nospam.com>
Subject: Re: trying to create a network script:
Message-Id: <c0bndr$miu$1@daisy.noc.ucla.edu>
It did not work,
it just says can't open file....
no matter how i try and open it, it does njot open.????
-Nex6
Ben Morrow wrote:
> see@sig.invalid wrote:
>
>>Nex6 wrote:
>>
>>>open fh, '+<\\\\$file\\c$\\reset.reg' or die "can't open $file: $!";
>>
>>Better is probably something like:
>>
>>open FH,"+<//$file/c\$/reset.reg" or die "Can't open $file: $!";
>
>
> Better again is
>
> open my $FH, '+<', "//$file/c\$/reset.reg" or die "can't open $file: $!";
>
> The lexical FH will close automatically when it goes out of scope.
>
> Ben
>
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 V10 Issue 6108
***************************************