[13990] in Perl-Users-Digest
Perl-Users Digest, Issue: 1400 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Nov 16 18:15:44 1999
Date: Tue, 16 Nov 1999 15:15:30 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <942794129-v9-i1400@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 16 Nov 1999 Volume: 9 Number: 1400
Today's topics:
Re: qn about Getopt::Long module <linberg@literacy.upenn.edu>
Re: qn about Getopt::Long module <gellyfish@gellyfish.com>
reading one line at a time <jazz108@yahoo.com>
Re: reading one line at a time <linberg@literacy.upenn.edu>
Re: reading one line at a time (Abigail)
Re: reading one line at a time (Kragen Sitaker)
Re: Regular Expressions (Brett W. McCoy)
Re: Regular Expressions <lr@hpl.hp.com>
Re: Removing all combinations of spaces/tabs at end of (David H. Adler)
Re: Scheduling jobs .... working in windows but serveri <310064202272#0001@online.de>
Re: seeking seek algorithm <Mike.Wescott@ColumbiaSC.NCR.COM>
Re: Slurping output form system(runme.exe) <gellyfish@gellyfish.com>
Re: something like Text::Wrap::wrap() that's HTML aware <rootbeer@redcat.com>
Re: Thanks for nothing <AgitatorsBand@yahoo.com>
Re: Trying to use a variable as an operator (Greg Bacon)
Re: Trying to use a variable as an operator (Kragen Sitaker)
Re: unbuffered input <Mike.Wescott@ColumbiaSC.NCR.COM>
Re: Unload/reload modules? (Kragen Sitaker)
Uptime plugin for Perl on NT patelni101480@my-deja.com
Uptime plugin for Perl on NT patelni101480@my-deja.com
Uptime plugin for Perl on NT patelni101480@my-deja.com
Re: Using Open2() Win32 NT ? <hattons@cpkwebser5.ncr.disa.mil>
Re: Using Open2() Win32 NT ? (Kragen Sitaker)
Re: Where can i find more information on Schwartzian tr (David H. Adler)
Re: Why isn't the HTML::Parser an HTML::Parser? (Bart Lateur)
Re: Why isn't the HTML::Parser an HTML::Parser? (Abigail)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 16 Nov 1999 16:57:31 -0500
From: Steve Linberg <linberg@literacy.upenn.edu>
Subject: Re: qn about Getopt::Long module
Message-Id: <m3bt8u85h0.fsf@projdirc.literacy.upenn.edu>
geetago@my-deja.com writes:
> I am using Getopt::Long module for argument
> parsing. How can i force my program to exit if
> the it is invoked with an "unknown options"
According to 'perldoc Getopt::Long', it will die if called with invalid
options, unless of course you call it in an eval block, where you can check
for errors in the usual fashion. But it's all in the documentation.
--
Steve Linberg, Chief Goblin
Silicon Goblin Technologies
http://silicongoblin.com
Be kind. Remember, everyone you meet is fighting a hard battle.
------------------------------
Date: 16 Nov 1999 21:50:28 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: qn about Getopt::Long module
Message-Id: <80sjj4$35a$1@gellyfish.btinternet.com>
On Tue, 16 Nov 1999 17:58:31 GMT geetago@my-deja.com wrote:
> I am using Getopt::Long module for argument
> parsing. How can i force my program to exit if
> the it is invoked with an "unknown options"
>
GetOptions('blah') || die "incorrect usage\n";
Of course you may also want to read what it says in the manpage about
trapping $SIG{__WARN__} as well ...
/J\
--
Jonathan Stowe <jns@gellyfish.com>
<http://www.gellyfish.com>
Hastings: <URL:http://dmoz.org/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Tue, 16 Nov 1999 22:21:15 GMT
From: "n.thiyagarajan" <jazz108@yahoo.com>
Subject: reading one line at a time
Message-Id: <3831DC57.B854E8BD@yahoo.com>
hi everyone,
i want to open a file and read in on line at a time using perl.
any suggestions?
jazz108@yahoo.com
------------------------------
Date: 16 Nov 1999 17:36:54 -0500
From: Steve Linberg <linberg@literacy.upenn.edu>
Subject: Re: reading one line at a time
Message-Id: <m3aeoe83nd.fsf@projdirc.literacy.upenn.edu>
"n.thiyagarajan" <jazz108@yahoo.com> writes:
> i want to open a file and read in on line at a time using perl.
> any suggestions?
Yikes. Put on your flameproof suit quick. This is one of the very basic
types of things one does with Perl, and will be richly documented in just
about any source of Perl documentaction -- the books, the FAQ, the man
pages, the help docs that came with your Perl installation, even deja news.
Please consult with any of these sources.
--
Steve Linberg, Chief Goblin
Silicon Goblin Technologies
http://silicongoblin.com
Be kind. Remember, everyone you meet is fighting a hard battle.
------------------------------
Date: 16 Nov 1999 16:40:30 -0600
From: abigail@delanet.com (Abigail)
Subject: Re: reading one line at a time
Message-Id: <slrn833nhd.cvu.abigail@alexandra.delanet.com>
n.thiyagarajan (jazz108@yahoo.com) wrote on MMCCLXVIII September MCMXCIII
in <URL:news:3831DC57.B854E8BD@yahoo.com>:
**
** i want to open a file and read in on line at a time using perl.
** any suggestions?
You cannot. Ignore what the documentation says, it's all lies, damned
lies and statistics.
Abigail
--
perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Tue, 16 Nov 1999 22:50:54 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: reading one line at a time
Message-Id: <idlY3.19571$YI2.844979@typ11.nn.bcandid.com>
In article <3831DC57.B854E8BD@yahoo.com>,
n.thiyagarajan <jazz108@yahoo.com> wrote:
>i want to open a file and read in on line at a time using perl.
>any suggestions?
RTFM.
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
The Internet stock bubble didn't burst on 1999-11-08. Hurrah!
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Tue, 16 Nov 1999 21:27:04 GMT
From: bmccoy@foiservices.com (Brett W. McCoy)
Subject: Re: Regular Expressions
Message-Id: <slrn833j5f.5io.bmccoy@moebius.foiservices.com>
Also Sprach Luis Figueiredo <panzer@hfeles.pt>:
>if ($x =~ /;{2, }/) {print "yes";};
>
>i tryed on using
>
>if ($x =~ /\;{2, }/) {print "yes";};
>
>Hoping that the semicolon was causing the problem, but with no results.
>
>I'm using the number 2 as an example, 3 or 4 would be more apropriated.
Have you tried using split?
-----
#!/usr/bin/perl -w
use strict;
my $r = 'key1;key2;key3;key4';
my @keywords = split(';', $r);
print "Number of keywords = ", scalar(@keywords), "\n";
--
Brett W. McCoy bmccoy@foiservices.com
Computer Operations Manager (Alpha Geek) http://www.foiservices.com
FOI Services, Inc./DIOGENES 301-975-0110
---------------------------------------------------------------------------
------------------------------
Date: Tue, 16 Nov 1999 14:14:41 -0800
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Regular Expressions
Message-Id: <MPG.129b772c8f595ed598a215@nntp.hpl.hp.com>
In article <slrn833j5f.5io.bmccoy@moebius.foiservices.com> on Tue, 16
Nov 1999 21:27:04 GMT, Brett W. McCoy <bmccoy@foiservices.com> says...
...
> Have you tried using split?
> -----
> #!/usr/bin/perl -w
>
> use strict;
>
> my $r = 'key1;key2;key3;key4';
>
> my @keywords = split(';', $r);
>
> print "Number of keywords = ", scalar(@keywords), "\n";
I haven't done a benchmark in a while, but about an order of magnitude
is too good to pass up. TMTOWTDI, but this choice is really poor.
Benchmark: timing 262144 iterations of Split, Tr...
Split: 15 wallclock secs (15.02 usr + 0.00 sys = 15.02 CPU)
Tr: 3 wallclock secs ( 1.83 usr + 0.00 sys = 1.83 CPU)
#!perl -w
use strict;
use Benchmark;
my $r = 'key1;key2;key3;key4';
timethese(1 << (shift || 0), {
Split => sub { my @keywords = split /;/, $r; @keywords - 1 },
Tr => sub { $r =~ tr/;// },
});
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 16 Nov 1999 16:06:29 -0500
From: dha@panix.com (David H. Adler)
Subject: Re: Removing all combinations of spaces/tabs at end of string
Message-Id: <slrn833hqk.odm.dha@panix.com>
On Mon, 15 Nov 1999 15:46:32 -0800, David Cassell
<cassell@mail.cor.epa.gov> wrote:
>[1] make sure you have your own personal copy of the docs which
>come with Perl [including the FAQ] - if it isn't on your hard
>drive already, grab a copy from CPAN [www.cpan.org]
Personally, if the docs aren't with your copy of perl, I'd reinstall.
Many (if not most) consider a perl install w/o documentation to be
quite broken.
dha
--
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
All the study in the world doesn't make it science - Paul Weller
------------------------------
Date: Wed, 17 Nov 1999 00:02:14 +0100
From: bmlam <310064202272#0001@online.de>
Subject: Re: Scheduling jobs .... working in windows but serveris linux
Message-Id: <3831E276.60BE462E@online.de>
Kragen Sitaker schrieb:
> In article <80rufc$8e2$1@news.vsnl.net.in>,
> Ishpal <ishpal@infobase.co.in> wrote:
> >I need to schedule jobs .. like sending e-mails at regular intervals say
> >everyweek. How can I shedulemy script to run at regular intervals.
> >I'm working in windows NT but the server on which our site is hoated is a
> >Linux server.
>
NT (at least the server version) supports the "at" command originating from the
Unix world. And "at" is a less user friendly version of cron. This may help in
case in have no way to schedule crontab jobs on Linux.
To enable "at" on NT you need to start a certain service as the Administrator
however I cant recall which one that was.
>
> cron. Not a Perl question.
> --
> <kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
> The Internet stock bubble didn't burst on 1999-11-08. Hurrah!
> <URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: 16 Nov 1999 14:31:03 -0500
From: Mike Wescott <Mike.Wescott@ColumbiaSC.NCR.COM>
Subject: Re: seeking seek algorithm
Message-Id: <x4bt8u8c94.fsf@ColumbiaSC.NCR.COM>
paul_p_francis@my-deja.com writes:
> i have a large (over 20 Gig) binary file with fixed length records. i
> have to aggregate 2 fields and calculate frequency distribution on
> another field. the problem is it takes over 65 minutes for my perl
> script to complete on a unix server running perl 5.005.
>
> if possible, i am hoping to find a way to speed this up.
>
> currently i am trying to use threads and seek() to start at 4
> different places (tot_recs/4)in the file and work forward until overlap-
> 1 with no luck so far.
Some suggestions: Rather than threads, try separate processes. Try
more than 4 processes/threads; try fewer. Make your reads in larger
chunks 64K or so. Split the process into a pipeline: reading large
chunks, writing record-size chunks into the pipe, reading the pipe
and pulling apart the data and doing the analysis. Try varying the
number of processes on each side of the pipe looking for optimum
performance. Try multiple buffers in shared memory rather than pipes.
Have someone else look over the code to make sure you're not doing
something silly (happens to all of us).
--
-Mike Wescott
mike.wescott@ColumbiaSC.NCR.COM
------------------------------
Date: 16 Nov 1999 22:53:11 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Slurping output form system(runme.exe)
Message-Id: <80sn8n$3c9$1@gellyfish.btinternet.com>
On Mon, 15 Nov 1999 21:31:58 -0500 Steven T. Hatton wrote:
> Scott Lanning wrote:
>
>> "Steven T. Hatton" <hattons@cpkwebser5.ncr.disa.mil> writes:
>> > $result=`commandname.exe`;
>> >
>> > I still need to send the contents of $variable to the command. Suppose
>> > I dump the contents of $variable to an output file called dump.txt. I
>> > can do the following at the command line:
>> >
>> > type dump.txt | commandneame.exe
>>
>> If you can do that, surely could just
>>
>> $result = `commandname.exe < dump.txt`;
>>
> I can do that. That isn't what I want. I don't want to create the temporary
> files at all. I want to do something like Open2 does. I can't figure out
> exactly what it does, but I think it is close. Here's what I want:
>
> Query a database and put results into a variable:
>
> Stream the contents of the variable to a command line tool that processes the
> value of the variable.
>
> Put the results of the command line into another variable.
>
> I don't want to create the temporary files.
>
Then you might want to read the perlipc manpage or the manpage for
IPC::Open2 perhaps or use a shell here-doc inside a Perl `` here-doc -
of course none of these might work on Win32 because of the way its
dumb 'shell' works.
/J\
--
Jonathan Stowe <jns@gellyfish.com>
<http://www.gellyfish.com>
Hastings: <URL:http://dmoz.org/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Tue, 16 Nov 1999 14:06:59 -0800
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: something like Text::Wrap::wrap() that's HTML aware?
Message-Id: <Pine.GSO.4.10.9911161321050.15797-100000@user2.teleport.com>
On 16 Nov 1999, Jed Parsons wrote:
> Maybe I shouldn't be using Text::Wrap in the first place. What I want to
> do is present chunks of text with line numbers on a web page. I want
> every viewer of the page to see the same text/line number correspondence.
That's a very UnWebLike thing to do. But okay....
> The only solution I can think of is to make a table consisting of two
> columns, one for lines of the text, the other for line numbers (every
> fifth).
>
> There are two immmediate problems. First, HTML code must be overlooked in
> calculating the length of a line in determining where to chop it off
> (where to wrap). The second problem is that unclosed HTML tags must be
> closed and reopened on the next line. For example, leaving out any HTML
> table code for clarity, I might want this text ...
>
> Fighting crime, trying to save the world, here they come <I>just in
> time</I>, the Powerpuff Girls!
>
> ... to come out like this ...
>
> Fighting crime,
> trying to save
> the world, here
> they come <I>just</I>
> <I>in time</I>, the 5
> Powerpuff Girls!
Would you break an <A href=....> the same way? That would not be the Right
Thing to do. But I'm not sure what would be right, either, as you wouldn't
want a possible line number to be part of the anchor.
But I still think you'll want to use HTML::Parser to do this. Good luck
with it!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 16 Nov 1999 22:32:47 GMT
From: Scratchie <AgitatorsBand@yahoo.com>
Subject: Re: Thanks for nothing
Message-Id: <jYkY3.1191$wJ6.225615@news.shore.net>
Jonathan Stowe <gellyfish@gellyfish.com> wrote:
:> I don't need any smartass comments.
:>
: Then you abviously dont want any answers here then ...
I don't know if you intended it that way, but this was one of the funniest
things I've read all day.
--Art
--
--------------------------------------------------------------------------
National Ska & Reggae Calendar
http://www.agitators.com/calendar/
--------------------------------------------------------------------------
------------------------------
Date: 16 Nov 1999 21:23:21 GMT
From: gbacon@ruby.itsc.uah.edu (Greg Bacon)
Subject: Re: Trying to use a variable as an operator
Message-Id: <80si09$o0m$2@info2.uah.edu>
In article <V1gY3.18604$YI2.798318@typ11.nn.bcandid.com>,
kragen@dnaco.net (Kragen Sitaker) writes:
: I always thought it was a shame Perl didn't have anything like APL's
: "reduce" operator -- +/, x/, etc. Now I know the shocking truth.
Have you seen mjd's implementation of reduce in Perl? The version
that I saw is in the notes for one of his classes (and I assume he owns
the copyright, so I won't reproduce it here). Ask him or wait for
someone else to produce an implementation.
Greg
--
There are no facts, only interpretations.
-- Nietzsche
------------------------------
Date: Tue, 16 Nov 1999 22:34:33 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Trying to use a variable as an operator
Message-Id: <ZZkY3.19536$YI2.841485@typ11.nn.bcandid.com>
In article <80si09$o0m$2@info2.uah.edu>, Greg Bacon <gbacon@cs.uah.edu> wrote:
>In article <V1gY3.18604$YI2.798318@typ11.nn.bcandid.com>,
> kragen@dnaco.net (Kragen Sitaker) writes:
>: I always thought it was a shame Perl didn't have anything like APL's
>: "reduce" operator -- +/, x/, etc. Now I know the shocking truth.
>
>Have you seen mjd's implementation of reduce in Perl? The version
>that I saw is in the notes for one of his classes (and I assume he owns
>the copyright, so I won't reproduce it here). Ask him or wait for
>someone else to produce an implementation.
Well, you could do it fairly trivially like this:
#!/usr/bin/perl -w
use strict;
sub reduce (&@) {
my $block = shift;
my $first = shift;
return @_ ? $block->($first, reduce($block, @_)) : $first;
}
print reduce { shift() + shift() } 1, 2, 3, 4;
But somehow "reduce { shift() + shift() } 1, 2, 3, 4" doesn't have the
cachet of "+/1 2 3 4".
(Note that the above reduce() works from the right, like APL's. That's
why it's doing that funky recursion thing.)
(Hmm, would grade-up have been nicer if it had taken an operator as an
argument like reduce did, and like Perl's sort does? Wouldn't it be
nice to have a Perl grade-up? Oh, hell, here's one based on the
Schwartzian Transform:
#!/usr/bin/perl -w
use strict;
sub grade_up (&@) {
my $block = shift;
my $i = 0;
return map { $_->[0] }
sort { $block->($a->[1], $b->[1]) }
map { [$i++, $_] } @_;
}
my @words = qw(did gyre and gimble in the wabe);
my @grade = grade_up {$_[0] cmp $_[1]} qw(did gyre and gimble in the wabe);
print "@words[@grade] -- @grade\n";
)
(Disclaimer: I haven't read mjd's reduce; it's not my fault if his is
the same as mine because my implementation is the most obvious one.
:))
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
The Internet stock bubble didn't burst on 1999-11-08. Hurrah!
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: 16 Nov 1999 16:02:19 -0500
From: Mike Wescott <Mike.Wescott@ColumbiaSC.NCR.COM>
Subject: Re: unbuffered input
Message-Id: <x466z28810.fsf@ColumbiaSC.NCR.COM>
Håkan Jonsson <hakjo733@student.liu.se> writes:
> I am trying to make a loop, which is automatically exited if the user
> presses any key on the keyboard. Meanwhile, the loop is suppoused to be
> running. Therefore, the input must be unbuffered, and the program must
> proceed without waiting for any input.
>
> How can this be done in Perl?
perldoc -q keyboard
--
-Mike Wescott
mike.wescott@ColumbiaSC.NCR.COM
------------------------------
Date: Tue, 16 Nov 1999 22:39:19 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Unload/reload modules?
Message-Id: <r2lY3.19546$YI2.843087@typ11.nn.bcandid.com>
In article <Pine.GSO.4.10.9911151716090.15797-100000@user2.teleport.com>,
Tom Phoenix <rootbeer@redcat.com> wrote:
>On Fri, 12 Nov 1999, Diemo Schwarz wrote:
>> is it possible to unload and then reload a module from a running perl
>> program?
>
>No, not really. It's much like trying to give back memory to the system
>after it's been allocated. You could do (as programs written in C and some
>other languages do) and re-exec your own program, but that's generally not
>worth it for Perl programs.
You can indeed reload the module; see perldoc perlvar on %INC.
However, the import() method of a module can do arbitrarily evil
things; there's no easy way to undo them because you don't know what
they are.
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
The Internet stock bubble didn't burst on 1999-11-08. Hurrah!
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Tue, 16 Nov 1999 21:07:01 GMT
From: patelni101480@my-deja.com
Subject: Uptime plugin for Perl on NT
Message-Id: <80sh1g$jn7$1@nnrp1.deja.com>
I'm trying to ping a machine, then shut it down. Then I am trying to
find the uptime of the machine that I just shutdown, and if it has been
up for more than 5 minutes, I try to shutdown another machine. It may
sound a bit confusing but its really very simple. I ping for example,
machine 1, if it is alive, then I shutdown machine 1. Then I TRY to
find the uptime for machine 1, if it has been up for more than 5
minutes, I go ahead and shutdown machine 2. But for some reason I can
get as far as shutting machine 1 down. When I try to find the uptime of
that machine, it gives me funny errors. My problem is that I can't run
uptime for the machine I want it to run on. I have provided some code:
After I shutdown machine one, I try to use the followin sub procedure
from the uptime plugin:
sub time2days {
print "converting $_[0]\n" if $debug;
my $days = (time() - $_[0])/(24*60*60);
my $hours = ($days - int($days)) * 24;
my $minutes = ($hours - int($hours)) * 60;
# This part should give me the uptime for machine 1
if ($minutes>=5) {
print ("initiate reboot sequence");
$reboot = false;
#condition
use Net::Ping;
require ("c:\ws2.ini");
#calls on the ws2.ini file which contains a machine name.
$Ping=Net::Ping->new(icmp);
#uses perl's pinging feature
foreach $ws2 (@ws2) {
#Calls on the workstation I made in an ini file
if ($Ping->ping($ws2,2)) {
print ("\nCan ping Workstation $ws2 OK \n");
$reboot = true;
}
else {
print ("\n$ws2 apears to be off the network\n");
}
if ($reboot = true) {
system ("shutdown \\\\machine 2 /C /Y /R");
}
#Loop that pings the workstations, and if they are not alive, it
prints out a message
} # For each
} # If
else {
print ("sorry can not reboot");
}
# my $day_st = $days >= 2 ? 'days' : 'day';
# return sprintf("%0d $day_st %02d:%02d", $days, $hours,
$minutes);
return sprintf($minutes);
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 16 Nov 1999 21:07:17 GMT
From: patelni101480@my-deja.com
Subject: Uptime plugin for Perl on NT
Message-Id: <80sh21$jnm$1@nnrp1.deja.com>
I'm trying to ping a machine, then shut it down. Then I am trying to
find the uptime of the machine that I just shutdown, and if it has been
up for more than 5 minutes, I try to shutdown another machine. It may
sound a bit confusing but its really very simple. I ping for example,
machine 1, if it is alive, then I shutdown machine 1. Then I TRY to
find the uptime for machine 1, if it has been up for more than 5
minutes, I go ahead and shutdown machine 2. But for some reason I can
get as far as shutting machine 1 down. When I try to find the uptime of
that machine, it gives me funny errors. My problem is that I can't run
uptime for the machine I want it to run on. I have provided some code:
After I shutdown machine one, I try to use the followin sub procedure
from the uptime plugin:
sub time2days {
print "converting $_[0]\n" if $debug;
my $days = (time() - $_[0])/(24*60*60);
my $hours = ($days - int($days)) * 24;
my $minutes = ($hours - int($hours)) * 60;
# This part should give me the uptime for machine 1
if ($minutes>=5) {
print ("initiate reboot sequence");
$reboot = false;
#condition
use Net::Ping;
require ("c:\ws2.ini");
#calls on the ws2.ini file which contains a machine name.
$Ping=Net::Ping->new(icmp);
#uses perl's pinging feature
foreach $ws2 (@ws2) {
#Calls on the workstation I made in an ini file
if ($Ping->ping($ws2,2)) {
print ("\nCan ping Workstation $ws2 OK \n");
$reboot = true;
}
else {
print ("\n$ws2 apears to be off the network\n");
}
if ($reboot = true) {
system ("shutdown \\\\machine 2 /C /Y /R");
}
#Loop that pings the workstations, and if they are not alive, it
prints out a message
} # For each
} # If
else {
print ("sorry can not reboot");
}
# my $day_st = $days >= 2 ? 'days' : 'day';
# return sprintf("%0d $day_st %02d:%02d", $days, $hours,
$minutes);
return sprintf($minutes);
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 16 Nov 1999 21:08:59 GMT
From: patelni101480@my-deja.com
Subject: Uptime plugin for Perl on NT
Message-Id: <80sh54$jq4$1@nnrp1.deja.com>
I'm trying to ping a machine, then shut it down. Then I am trying to
find the uptime of the machine that I just shutdown, and if it has been
up for more than 5 minutes, I try to shutdown another machine. It may
sound a bit confusing but its really very simple. I ping for example,
machine 1, if it is alive, then I shutdown machine 1. Then I TRY to
find the uptime for machine 1, if it has been up for more than 5
minutes, I go ahead and shutdown machine 2. But for some reason I can
get as far as shutting machine 1 down. When I try to find the uptime of
that machine, it gives me funny errors. My problem is that I can't run
uptime for the machine I want it to run on. I have provided some code:
After I shutdown machine one, I try to use the followin sub procedure
from the uptime plugin:
sub time2days {
print "converting $_[0]\n" if $debug;
my $days = (time() - $_[0])/(24*60*60);
my $hours = ($days - int($days)) * 24;
my $minutes = ($hours - int($hours)) * 60;
# This part should give me the uptime for machine 1
if ($minutes>=5) {
print ("initiate reboot sequence");
$reboot = false;
#condition
use Net::Ping;
require ("c:\ws2.ini");
#calls on the ws2.ini file which contains a machine name.
$Ping=Net::Ping->new(icmp);
#uses perl's pinging feature
foreach $ws2 (@ws2) {
#Calls on the workstation I made in an ini file
if ($Ping->ping($ws2,2)) {
print ("\nCan ping Workstation $ws2 OK \n");
$reboot = true;
}
else {
print ("\n$ws2 apears to be off the network\n");
}
if ($reboot = true) {
system ("shutdown \\\\machine 2 /C /Y /R");
}
#Loop that pings the workstations, and if they are not alive, it
#prints out a message
else {
print ("sorry can not reboot");
}
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 16 Nov 1999 14:45:37 -0500
From: "Steven T. Hatton" <hattons@cpkwebser5.ncr.disa.mil>
Subject: Re: Using Open2() Win32 NT ?
Message-Id: <3831B45F.F9FC8E73@cpkwebser5.ncr.disa.mil>
Kragen,
Thanks, this is a cool trick for cleaning up after yourself when you create a
temp file. Unfortunately it still creates a temp file. I will potentially be
processing thousands of results in batch and will not want to be creating temp
files on each hit. I also don't like the security implications of creating
temp files.
Steve
Kragen Sitaker wrote:
> In article <3831682F.891EDEA@cpkwebser5.ncr.disa.mil>,
> Steven T. Hatton <hattons@cpkwebser5.ncr.disa.mil> wrote:
> >Get $variable
> >Stream $Variable into | commandLine.exe | read $results from pipe.
>
> #!/usr/bin/perl -w
> use strict;
> my $variable = "blah badoo maga " x 100;
> open TMPOUT, ">foo" or die "Can't open foo: $!\n";
> print TMPOUT $variable;
> close TMPOUT;
> open RESULTS, "fmt < foo |" or die "Can't fork: $!\n";
> while (<RESULTS>) {
> print "got: $_";
> }
> unlink "foo" or die "Can't unlink foo: $!\n";
>
> You might want to pick a different filename, of course, and fmt only
> exists in Unix. But this should clarify the technique.
> --
> <kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
> The Internet stock bubble didn't burst on 1999-11-08. Hurrah!
> <URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Tue, 16 Nov 1999 22:16:36 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Using Open2() Win32 NT ?
Message-Id: <8JkY3.19527$YI2.838798@typ11.nn.bcandid.com>
In article <3831B45F.F9FC8E73@cpkwebser5.ncr.disa.mil>,
Steven T. Hatton <hattons@cpkwebser5.ncr.disa.mil> wrote:
>Thanks, this is a cool trick for cleaning up after yourself when you create a
>temp file.
You mean unlink? :)
> Unfortunately it still creates a temp file. I will potentially be
>processing thousands of results in batch and will not want to be creating temp
>files on each hit.
Waiiiit a minute. You don't want to open a file for each hit, but
you're going to *spawn an external program* for each hit? You've got
to be kidding.
Temp files are messy, I admit. But they're not as messy as open2()'s
potential deadlocks.
You could open RESULTS, "echo $variable | foo |" instead. (You may
have to do suitable cleanup on $variable first, and you'll suffer your
system's command-line limit.)
>I also don't like the security implications of creating temp files.
You mean race conditions? Don't create them in /tmp, then. That's why
I used 'foo' instead of '/tmp/foo' -- I didn't want to go through the
rigmarole of creating a temp file securely in /tmp with sysopen.
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
The Internet stock bubble didn't burst on 1999-11-08. Hurrah!
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: 16 Nov 1999 16:42:30 -0500
From: dha@panix.com (David H. Adler)
Subject: Re: Where can i find more information on Schwartzian transform!
Message-Id: <slrn833ju5.odm.dha@panix.com>
On Mon, 15 Nov 1999 23:37:22 -0800, Larry Rosler <lr@hpl.hp.com> wrote:
>In article <x7u2mnusqw.fsf@home.sysarch.com> on 15 Nov 1999 20:31:35 -
>0500, Uri Guttman <uri@sysarch.com> says...
>> larry: (i know you will read this) should our article/sort pages link to
>> tom's article and other pages?
>
>How did you know? :-)
>
>The HTML version includes the following references and hyperlinks:
[snip existing references]
I'd just like to point out that Effective Perl Programming also has a
section on the ST. Not to mention that it's named after the
co-author... :-)
dha
--
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
"You're quite free to convert your strings to byte arrays and do the
entire pattern tree by hand in pure logic code if you'd like. By the
time you finish most of the rest of us will be doing contract work on
Mars." - Zenin on comp.lang.perl.misc
------------------------------
Date: Tue, 16 Nov 1999 22:04:02 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Why isn't the HTML::Parser an HTML::Parser?
Message-Id: <3831d442.791414@news.skynet.be>
Eric Bohlman wrote:
>But HTML::Parser will not generate an end-element event unless the
>element has an explicit end-tag. This means that you need to use
>application logic to figure out where certain elements end, and if you
>get it wrong, your application will stumble over perfectly legal constructs.
>
>A true HTML parser uses an HTML DTD to guide its parsing. HTML::Parser
>is really only a tokenizer. For many applications that's all you really
>need, but the name *is* misleading.
How about HTML::TreeBuilder? That is based upon HTML::Parser (I start
feeling dirty when using that module name ...), but it is indeed guided
by the the syntax per the DTD.
Caveat: I got an out-of-memory error when trying to process a 15 k HTML
file, so it's quite a hungry little thing...
--
Bart.
------------------------------
Date: 16 Nov 1999 16:44:07 -0600
From: abigail@delanet.com (Abigail)
Subject: Re: Why isn't the HTML::Parser an HTML::Parser?
Message-Id: <slrn833no4.cvu.abigail@alexandra.delanet.com>
Bart Lateur (bart.lateur@skynet.be) wrote on MMCCLXVIII September
MCMXCIII in <URL:news:3831d442.791414@news.skynet.be>:
@@
@@ How about HTML::TreeBuilder? That is based upon HTML::Parser (I start
@@ feeling dirty when using that module name ...), but it is indeed guided
@@ by the the syntax per the DTD.
Which DTD? There's no "the DTD" for HTML, there are several. Including
3 for HTML 4.0.
Abigail
--
package Z;use overload'""'=>sub{$b++?Hacker:Another};
sub TIESCALAR{bless\my$y=>Z}sub FETCH{$a++?Perl:Just}
$,=$";my$x=tie+my$y=>Z;print$y,$x,$y,$x,"\n";#Abigail
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V9 Issue 1400
**************************************