[9261] in Perl-Users-Digest
Perl-Users Digest, Issue: 2857 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jun 12 15:07:44 1998
Date: Fri, 12 Jun 98 12:01:37 -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 Fri, 12 Jun 1998 Volume: 8 Number: 2857
Today's topics:
Perl for NT - Capturing Errors <lecraw@gte.net>
Re: Perl for NT - Capturing Errors (Brad Murray)
Re: Prob in FAQ: Week of the year <quentin@shaddam.amd.com>
Re: Prob in FAQ: Week of the year <tchrist@mox.perl.com>
Re: Prob in FAQ: Week of the year (Sullivan N. Beck)
Re: Problem with MOMSpider (Joe McMahon)
Puzzle challenge (Tim Bunce) (Tim Bunce)
Re: question on a process mgmt (how to kill a child pro <gnat@frii.com>
Re: removing dups from a file <devs@usa.net>
Re: removing dups from a file <tchrist@mox.perl.com>
Re: removing dups from a file (Matt Knecht)
Script for Crash jharris01@my-dejanews.com
while (<>) vs. foreach (@ARGV) <agianni@acsu.buffalo.edu>
Re: while (<>) vs. foreach (@ARGV) <nguyend7@egr.msu.edu>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 12 Jun 1998 13:03:42 -0400
From: "Dave" <lecraw@gte.net>
Subject: Perl for NT - Capturing Errors
Message-Id: <6lrn65$9qo$1@gte1.gte.net>
Hi,
I'm trying to capture error output from the following line. I can get the
success message sent to a file, but not the error message. The errors would
be caused by the failed execution of the parameters, not the app. I've
running this in a process, but that doesn't help either. It will create the
file, but it is empty. I've looked everyplace I can think of for an answer
with no luck.
Code:
system ("cmd /c c:\\atria\\bin\\cleartool.exe vob \\my_vob
>>e:\\cclog\\capture.txt");
This is the error screen output. Success is similar, but is captured to
file.
c:\perl>cc1.pl
cleartool: Error: Unrecognized command: "lsvob1"
Thanks for the help from a perl novice.
Dave
------------------------------
Date: 12 Jun 1998 10:36:30 -0700
From: murrayb@vansel.alcatel.com (Brad Murray)
Subject: Re: Perl for NT - Capturing Errors
Message-Id: <6lrouu$s3@cadre2.vansel.alcatel.com>
It seems Dave suggested...
>I'm trying to capture error output from the following line. I can get the
>success message sent to a file, but not the error message. The errors would
>be caused by the failed execution of the parameters, not the app. I've
>running this in a process, but that doesn't help either. It will create the
>file, but it is empty. I've looked everyplace I can think of for an answer
>with no luck.
>
>Code:
>system ("cmd /c c:\\atria\\bin\\cleartool.exe vob \\my_vob
>>>e:\\cclog\\capture.txt");
This is your shell screwing you, not perl. As the errors are printed on
STDERR and not STDOUT, your command line here will only capture regular
text output to your capture.txt file. In order to capture stderr under
NT's default shell, you need the syntax:
command 2>> filename
...to indicate default filehandle 2 (stderr). This is terribly under-
documented under NT as any potentially powerful command line functionality
seems to be in that environment.
But I agree in anticipation of Tom's flame: this is not a perl question.
Frankly, anything between system(" and ") is not likely to be a perl
question.
--
Brad Murray "The fall of modern man will be preceded by the
Software Analyst de-evolution of communications to the days of
Alcatel Canada oral tradition." --Tom Christiansen paraphrased
------------------------------
Date: 12 Jun 1998 12:34:36 -0500
From: Quentin Fennessy <quentin@shaddam.amd.com>
Subject: Re: Prob in FAQ: Week of the year
Message-Id: <xim3edaikwj.fsf@shaddam.amd.com>
>>>>> "Tom" == Tom Christiansen <tchrist@mox.perl.com> writes:
Tom> Keep in mind that last time I checked, American work weeks
Tom> did not follow that. Perhaps this has changed. I got out of
Tom> the work business long ago. :-)
I ran into a similar problem. I don't know how other companies
calculate it, but AMD procedures disagree with Date::DateCalc.
I recently solved it this way:
($mday,$mon,$year) = (localtime(time))[3,4,5];
$year += 1900;
($fww, $fyr) = week_number($year,1,1);
($ww, $yr) = week_number($year,$mon+1,$mday);
# normalize to AMD practices
#
if ($fww == 53) { $ww ++; }
if ($ww > 52) { $ww = 1; $yr ++; }
return ($ww, $yr);
--
Quentin Fennessy AMD, Austin Texas
Secret hacker rule #11 - hackers read manuals
------------------------------
Date: 12 Jun 1998 17:46:58 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Prob in FAQ: Week of the year
Message-Id: <6lrpii$r15$3@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
Quentin Fennessy <quentin@shaddam.amd.com> writes:
:I ran into a similar problem. I don't know how other companies
:calculate it, but AMD procedures disagree with Date::DateCalc.
That's what I was afraid of. I think then that we need to tell the
Date people that they need to give us a way to calculate normal American
business weeks, not ISO weeks that aren't used here.
--tom
--
Actually, you'll know we're nearing the end when I make |$foo| mean
"absolute value"... :-) Larry Wall in <1994Feb25.192042.17196@netlabs.com>
------------------------------
Date: 12 Jun 1998 14:33:50 -0400
From: sbeck@cise.ufl.edu (Sullivan N. Beck)
Subject: Re: Prob in FAQ: Week of the year
Message-Id: <xz3af7impv5.fsf@cave.cise.ufl.edu>
Tom> [courtesy cc of this posting sent to cited author via email] In
Tom> comp.lang.perl.misc, Quentin Fennessy <quentin@shaddam.amd.com>
Tom> writes: :I ran into a similar problem. I don't know how other
Tom> companies :calculate it, but AMD procedures disagree with
Tom> Date::DateCalc.
Tom> That's what I was afraid of. I think then that we need to tell
Tom> the Date people that they need to give us a way to calculate
Tom> normal American business weeks, not ISO weeks that aren't used
Tom> here.
Date::Manip can handle either ISO weeks (the 1st week of the year contains
Jan 4) or "normal" weeks (the 1st week of the year contains Jan 1). See
the variable Jan1Week1 in the man page.
Note that Date::Manip tries to be ISO 8601 compliant by default, so the
Jan 4 case is on by default. You can turn this off by:
&Date_Init("Jan1Week1=1");
------------------------------------------------------------------------------
Sullivan Beck http://www.cise.ufl.edu/~sbeck/
sbeck@cise.ufl.edu | This space reserved for some saying demonstrating great
PH : (352) 392-1057 | wisdom, wit, or insight. I'll fill it in just as soon
Fax: (352) 392-1220 | as I have any of the above.
------------------------------------------------------------------------------
------------------------------
Date: Fri, 12 Jun 1998 14:09:57 -0400
From: joe.mcmahon@gsfc.nasa.gov (Joe McMahon)
Subject: Re: Problem with MOMSpider
Message-Id: <joe.mcmahon-1206981409570001@prtims.stx.com>
In article <3580EBAB.21C12688@dux.dundee.ac.uk>, James Sutherland
<jasuther@dux.dundee.ac.uk> wrote:
>HELP!
>
>I have just installed MOMSpider on the University WWW server. After
>installing it and creating an instruction file, I get:
>Undefined subroutine &main::AF_INET called at lib/wwwhttp.pl line 106.
>
>Where can I find &main::AF_INET? Some of the standard libraries refer to
>AF_INET, but I can't find any sort of definition.
>
>
>While I like and use Perl, I've not been using it all that long - what's
>up here? BTW, the homepage for MOMSpider says the program needs Perl4 -
>would that mean it can't run under Perl5? That would be a little odd,
>surely?
Yes, it does mean that. Your choices are: install perl4 (somewhere where
only MOMSpider will use it), convert MOMSpider to perl5 (and win undying
gratitude from a lot of people who will finally be able to delete perl4),
or toss it out and write a custom spider using LWP (see Randal's Web
Techniques columns for a simple program you can build on).
--- Joe M.
------------------------------
Date: Fri, 12 Jun 1998 15:00:27 GMT
From: Tim.Bunce@ig.co.uk (Tim Bunce) (Tim Bunce)
Subject: Puzzle challenge
Message-Id: <EuG1os.J04@ig.co.uk>
A list of names in a specific order is given to a set of messengers
in a remote land.
The messengers travel independently to a destination were they
give the names to you.
The problem is that the messengers quite often, say 70%, miss out one
or more names and occasionally, say 10%, get the order wrong.
Names are never added, repeated or changed, only missed or reordered.
The messengers always think they've got it right.
For example:
Original list: foo bar baz boo
Messenger A says: foo bar boo
Messenger B says: bar boo baz
Messenger C says: foo bar baz boo
Messenger D says: boo foo bar baz
Messenger E says: foo bar baz
Messenger F says: foo baz boo
The problem is to find the full list of names and the original order.
Tim.
------------------------------
Date: 12 Jun 1998 10:57:27 -0600
From: Nathan Torkington <gnat@frii.com>
Subject: Re: question on a process mgmt (how to kill a child process without creating zombie)
Message-Id: <5q4sxqmubs.fsf@prometheus.frii.com>
Tom Christiansen <tchrist@mox.perl.com> writes:
> In comp.lang.perl.misc, Justin Vallon <vallon@bear.com> writes:
> :(suppose NFS is down, kill -9 is blocked).
>
> I disbelieve, strenuously--as, I would imagine, does your kernel.
My experience has been that no matter how I tell the kernel to mount
the NFS volume, processes block infinitely and do not respond to kill
-9 when the NFS server goes away. Sucks, huh?
Repeat after me: "NFS stands for Nuisance File System".
Nat
------------------------------
Date: Fri, 12 Jun 1998 11:39:20 -0500
From: Deva Seetharam <devs@usa.net>
Subject: Re: removing dups from a file
Message-Id: <358159B8.D0C765C0@usa.net>
Michael Stearns wrote:
> Hello:
>
> I have a text file with about 700 lines.
>
> I would like to remove duplicate lines from the file.
>
> Can someone recommend a good way to do this?
>
> Thanks,
> Michael Stearns
If use sort, it changes the order of records in the file.
If you dont want to lose the order of records,
you can do something like this.
Ofcourse, it is not a nifty one-liner.
open(INPUT, "...") or die "Could not open data file : $!";
open(OUTPUT, "...") or die "Could not open output : $!";
my(@lines) = <INPUT>;
my(%records) = ();
foreach $line (@lines)
{
#Write the record to output, if it occurs for the first time.
if (! ($records{$line}) )
{
print OUTPUT $line;
# Make a note that the record has been written.
$records{$line} = 1;
}
}
close(INPUT) or die "Could not close the input file : $!";
close(OUTPUT) or die "Could not close the output file :$!";
Hope this helps.
Deva
------------------------------
Date: 12 Jun 1998 17:16:48 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: removing dups from a file
Message-Id: <6lrnq0$r15$2@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
michael@datahost.com writes:
:I would like to remove duplicate lines from the file.
Perl tip #741: The word "duplicate" should free-associate to "hash".
Perl tip #742: The word "unique" should free-associate to "hash".
Perl tip #743: The word "in" should free-associate to "hash".
--tom
--
The debate rages on: Is PL/I Bachtrian or Dromedary?
------------------------------
Date: Fri, 12 Jun 1998 18:52:08 GMT
From: hex@voicenet.com (Matt Knecht)
Subject: Re: removing dups from a file
Message-Id: <sNeg1.107$Ik1.2241858@news3.voicenet.com>
Tom Christiansen <tchrist@mox.perl.com> wrote:
>Perl tip #741: The word "duplicate" should free-associate to "hash".
>Perl tip #742: The word "unique" should free-associate to "hash".
>Perl tip #743: The word "in" should free-associate to "hash".
I'd love to see Perl tips 0-740! ;)
--
Matt Knecht - <hex@voicenet.com>
"496620796F752063616E207265616420746869732C20796F7520686176652066
617220746F6F206D7563682074696D65206F6E20796F75722068616E6473210F"
------------------------------
Date: Fri, 12 Jun 1998 16:49:20 GMT
From: jharris01@my-dejanews.com
Subject: Script for Crash
Message-Id: <6lrm6g$qel$1@nnrp1.dejanews.com>
Does anybody have a good script for sumarizing the output of the Unix crash
command?
Jeremy
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: Fri, 12 Jun 1998 13:51:33 -0400
From: Andrew S Gianni <agianni@acsu.buffalo.edu>
Subject: while (<>) vs. foreach (@ARGV)
Message-Id: <35816AA4.8D727735@buffalo.edu>
What's the best way to read a list from the command line? The camel book
seems to suggest that you should use something like:
while(<>){
...
do stuff with $ARGV
...
}
but when I use that kind of structure, it takes way longer to run than
if I use something like:
foreach (@ARGV){
...
do stuff with $_
...
}
Is this one of those things where something gets recompiled every time a
$ARGV is used or something? For now, I'm sticking with the second
implementation because it takes maybe 2 seconds vs. 30 to run.
Hmm?
Andrew
--
Andrew Gianni - Applications Developer "Not till we are lost, in other
SUNY at Buffalo - ACS/CIT words, not till we have lost
215 MFAC, Ellicott Complex, Box 610016 the world, do we begin to
Buffalo, NY 14261-0016 find ourselves, and realize
(716)645-3587x7009 fax:(716)645-3588 where we are and the
agianni@buffalo.edu infinite extent of our
http://www.cs.buffalo.edu/~agianni/ relationships" - Thoreau
------------------------------
Date: 12 Jun 1998 18:27:07 GMT
From: Dan Nguyen <nguyend7@egr.msu.edu>
Subject: Re: while (<>) vs. foreach (@ARGV)
Message-Id: <6lrrtr$btp$1@msunews.cl.msu.edu>
Andrew S Gianni <agianni@acsu.buffalo.edu> wrote:
: What's the best way to read a list from the command line? The camel book
: seems to suggest that you should use something like:
: while(<>){
: ...
: do stuff with $ARGV
: ...
: }
You should use <> when it's a file. Perl opens each @ARGV and
sends it's output to $_. So you should process $_.
: but when I use that kind of structure, it takes way longer to run than
: if I use something like:
: foreach (@ARGV){
: ...
: do stuff with $_
: ...
: }
I'd use something like this if the command-line options, but there is
a module for that kind of stuff.
: Is this one of those things where something gets recompiled every time a
: $ARGV is used or something? For now, I'm sticking with the second
: implementation because it takes maybe 2 seconds vs. 30 to run.
The reason for the time difference is this. The first one 'shift's an
entry from @ARGV and places it $ARGV. It then tries to open $ARGV.
It'll probably fail. (If your not using the -w option for perl you
should). In the second loop, your not opening files so it doesn't
take as long.
--
Dan Nguyen |
nguyend7@cps.msu.edu | Remember Byron.
http://www.cps.msu.edu/~nguyend7 |
------------------------------
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 2857
**************************************