[25295] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 7540 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Dec 20 11:10:48 2004

Date: Mon, 20 Dec 2004 08:10:16 -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           Mon, 20 Dec 2004     Volume: 10 Number: 7540

Today's topics:
        Is zero even or odd? <gactimus@xrs.net>
    Re: Is zero even or odd? <josef.moellers@fujitsu-siemens.com>
    Re: Is zero even or odd? <BB@BB.BB>
    Re: Is zero even or odd? (Randal L. Schwartz)
    Re: Is zero even or odd? <ullrich@math.okstate.edu>
    Re: Is zero even or odd? <jfields@austininstruments.com>
    Re: Is zero even or odd? <john@petcom.com>
    Re: Is zero even or odd? <t-tammaru@c0mca$t.net>
    Re: Is zero even or odd? <see@sig.com>
    Re: Is zero even or odd? <harrisq@tcs.inf.tu-dresden.de>
    Re: Is zero even or odd? (Richard Tobin)
    Re: Is zero even or odd? <dummy@dummy.net>
    Re: Is zero even or odd? <jmw@jmwa.demon.contraspam.yuk>
    Re: Is zero even or odd? <jmw@jmwa.demon.contraspam.yuk>
    Re: Is zero even or odd? (IFR LIT MET\)
    Re: Is zero even or odd? <mckenzie@despammed.com>
    Re: Length of Array of Array of Array <sudhirx@gmail.com>
    Re: MS Perl question -- how to use hacked script to wor <djcameron60616@yahoo.com>
    Re: MS Perl question -- how to use hacked script to wor <1usa@llenroc.ude.invalid>
    Re: Newbie question <x3v0-usenet@yahoo.com>
    Re: pause, wait, etc. <jgibson@mail.arc.nasa.gov>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Mon, 20 Dec 2004 14:21:11 -0000
From: Gactimus <gactimus@xrs.net>
Subject: Is zero even or odd?
Message-Id: <10sdnunotbnere2@corp.supernews.com>

I know 0 is neither negative or positive but what about odd/even? I think
it's even. 

Odd numbers start at 1 and go every other number 1,3,5,7;1,-1,-3,-5,-7
Even starts at 2 and go every other number 2,4,6,8;2,0,-2,-4,-6,-8


------------------------------

Date: Mon, 20 Dec 2004 15:24:39 +0100
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: Is zero even or odd?
Message-Id: <cq6n8g$bgu$2@nntp.fujitsu-siemens.com>

Gactimus wrote:
> I know 0 is neither negative or positive but what about odd/even? I thi=
nk
> it's even.=20
>=20
> Odd numbers start at 1 and go every other number 1,3,5,7;1,-1,-3,-5,-7
> Even starts at 2 and go every other number 2,4,6,8;2,0,-2,-4,-6,-8

As it can be divided by 2 without a remainder, it is obviously even.

--=20
Josef M=F6llers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize
						-- T.  Pratchett



------------------------------

Date: Mon, 20 Dec 2004 14:34:03 -0000
From: BB <BB@BB.BB>
Subject: Re: Is zero even or odd?
Message-Id: <10sdomrcqe6qt0e@corp.supernews.com>

Josef Moellers wrote:
> 
> Gactimus wrote:
> > I know 0 is neither negative or positive but what about odd/even? I think
> > it's even.
> >
> > Odd numbers start at 1 and go every other number 1,3,5,7;1,-1,-3,-5,-7
> > Even starts at 2 and go every other number 2,4,6,8;2,0,-2,-4,-6,-8
> 
> As it can be divided by 2 without a remainder, it is obviously even.

The divisor would have to be something smaller than 0 like -2.
Therefore zero is both even and negative.

> 
> --
> Josef Möllers (Pinguinpfleger bei FSC)
>         If failure had no penalty success would not be a prize
>                                                 -- T.  Pratchett




------------------------------

Date: 20 Dec 2004 07:02:45 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Is zero even or odd?
Message-Id: <1103555008.27a2823c1bbed9a94f757354cf25ab0d@teranews>

>>>>> "BB" == BB  <BB@BB.BB> writes:

BB> The divisor would have to be something smaller than 0 like -2.
BB> Therefore zero is both even and negative.

This is a troll.   *Negative*?  Can I have some of the drug you're
smoking? :)

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


------------------------------

Date: Mon, 20 Dec 2004 09:19:39 -0600
From: David C. Ullrich <ullrich@math.okstate.edu>
Subject: Re: Is zero even or odd?
Message-Id: <lards0tmkk434tgtmpaepavj4b4p6ekkl8@4ax.com>

On Mon, 20 Dec 2004 14:34:03 -0000, BB <BB@BB.BB> wrote:

>Josef Moellers wrote:
>> 
>> Gactimus wrote:
>> > I know 0 is neither negative or positive but what about odd/even? I think
>> > it's even.
>> >
>> > Odd numbers start at 1 and go every other number 1,3,5,7;1,-1,-3,-5,-7
>> > Even starts at 2 and go every other number 2,4,6,8;2,0,-2,-4,-6,-8
>> 
>> As it can be divided by 2 without a remainder, it is obviously even.
>
>The divisor would have to be something smaller than 0 like -2.

Huh? 0/2 is somehow undefined because 2 > 0? Interesting.

>Therefore zero is both even and negative.
>
>> 
>> --
>> Josef Möllers (Pinguinpfleger bei FSC)
>>         If failure had no penalty success would not be a prize
>>                                                 -- T.  Pratchett
>


************************

David C. Ullrich


------------------------------

Date: Mon, 20 Dec 2004 09:13:35 -0600
From: John Fields <jfields@austininstruments.com>
Subject: Re: Is zero even or odd?
Message-Id: <anqds054e36bfqtm3m7s15n3kk0o2r37jk@4ax.com>

On Mon, 20 Dec 2004 14:34:03 -0000, BB <BB@BB.BB> wrote:

>Josef Moellers wrote:
>> 
>> Gactimus wrote:
>> > I know 0 is neither negative or positive but what about odd/even? I think
>> > it's even.
>> >
>> > Odd numbers start at 1 and go every other number 1,3,5,7;1,-1,-3,-5,-7
>> > Even starts at 2 and go every other number 2,4,6,8;2,0,-2,-4,-6,-8
>> 
>> As it can be divided by 2 without a remainder, it is obviously even.
>
>The divisor would have to be something smaller than 0 like -2.
>Therefore zero is both even and negative.

---
Zero has no sign. Consider:

If zero was positive, 1+0 > 1, but 1+0 = 0
If zero was negative, 1+0 < 1, but 1+0 = 0

-- 
John Fields


------------------------------

Date: Mon, 20 Dec 2004 09:21:25 -0600
From: John Sefton <john@petcom.com>
Subject: Re: Is zero even or odd?
Message-Id: <41C6EDF5.1050205@petcom.com>

Randal L. Schwartz wrote:
>>>>>>"BB" == BB  <BB@BB.BB> writes:
>>>>>
> 
> BB> The divisor would have to be something smaller than 0 like -2.
> BB> Therefore zero is both even and negative.
> 
> This is a troll.   *Negative*?  Can I have some of the drug you're
> smoking? :)
> 

It's not a prime, because a prime can
only be divided by itself and 1.
0 can't be divided by itself, but
can be divided by everything else.
An anti-prime?
John



------------------------------

Date: Mon, 20 Dec 2004 10:30:30 -0500
From: "Tam/WB2TT" <t-tammaru@c0mca$t.net>
Subject: Re: Is zero even or odd?
Message-Id: <uLadna6l--ViclvcRVn-qA@comcast.com>


"BB" <BB@BB.BB> wrote in message news:10sdomrcqe6qt0e@corp.supernews.com...
> Josef Moellers wrote:
>>
>> Gactimus wrote:
>> > I know 0 is neither negative or positive but what about odd/even? I 
>> > think
>> > it's even.
>> >
>> > Odd numbers start at 1 and go every other number 1,3,5,7;1,-1,-3,-5,-7
>> > Even starts at 2 and go every other number 2,4,6,8;2,0,-2,-4,-6,-8
>>
>> As it can be divided by 2 without a remainder, it is obviously even.
>
> The divisor would have to be something smaller than 0 like -2.
> Therefore zero is both even and negative.
>
>>
>> --
>> Josef Möllers (Pinguinpfleger bei FSC)
>>         If failure had no penalty success would not be a prize
>>                                                 -- T.  Pratchett
>
>
I seeem to recall 0 coming up negative in some old IBM mainframes. That was 
an artifact of the way signed numbers were converted to binary.

Tam 




------------------------------

Date: Mon, 20 Dec 2004 15:36:15 GMT
From: "Nicholas O. Lindan" <see@sig.com>
Subject: Re: Is zero even or odd?
Message-Id: <PjCxd.4752$yK.1793@newsread3.news.atl.earthlink.net>

"John Sefton" <john@petcom.com> wrote

> 0 can't be divided by itself,

Sure it can: 0 / 0 = 0 * (1 / 0) = 0 * infinity = 1

It works if the only three numbers in the universe are
0, 1, and infinity -- A number system that seems very
suited to usenet.

-- 
Nicholas O. Lindan, Cleveland, Ohio
Consulting Engineer:  Electronics; Informatics; Photonics.
Remove spaces etc. to reply: n o lindan at net com dot com
psst.. want to buy an f-stop timer? nolindan.com/da/fstop/


------------------------------

Date: Mon, 20 Dec 2004 16:38:38 +0100
From: Mitch Harris <harrisq@tcs.inf.tu-dresden.de>
Subject: Re: Is zero even or odd?
Message-Id: <32o9vuF3nfbklU1@news.dfncis.de>

Randal L. Schwartz wrote:
>>>>>>"BB" == BB  <BB@BB.BB> writes:
> 
> 
> BB> The divisor would have to be something smaller than 0 like -2.
> BB> Therefore zero is both even and negative.
> 
> This is a troll.   *Negative*?  Can I have some of the drug you're
> smoking? :)

Well, it's called "negative" in French. (also positive, in order to
be logically consistent). And their bridges hold up pretty well.

as to the antecedent, woo hoo! I'd guess sleep deprivation.

-- 
Mitch Harris
(remove q to reply)



------------------------------

Date: 20 Dec 2004 15:42:24 GMT
From: richard@cogsci.ed.ac.uk (Richard Tobin)
Subject: Re: Is zero even or odd?
Message-Id: <cq6rt0$fk4$1@pc-news.cogsci.ed.ac.uk>

In article <41C6EDF5.1050205@petcom.com>, John Sefton  <john@petcom.com> wrote:

>It's not a prime, because a prime can
>only be divided by itself and 1.

If you rephrase that as "is a multiple only of 1 and itself" you will save
yourself the exception

>0 can't be divided by itself

-- Richard


------------------------------

Date: Mon, 20 Dec 2004 15:50:04 GMT
From: "Androcles" <dummy@dummy.net>
Subject: Re: Is zero even or odd?
Message-Id: <MwCxd.43422$Rf4.1324@fe2.news.blueyonder.co.uk>


"John Fields" <jfields@austininstruments.com> wrote in message 
news:anqds054e36bfqtm3m7s15n3kk0o2r37jk@4ax.com...
> On Mon, 20 Dec 2004 14:34:03 -0000, BB <BB@BB.BB> wrote:
>
>>Josef Moellers wrote:
>>>
>>> Gactimus wrote:
>>> > I know 0 is neither negative or positive but what about odd/even? 
>>> > I think
>>> > it's even.
>>> >
>>> > Odd numbers start at 1 and go every other number 
>>> > 1,3,5,7;1,-1,-3,-5,-7
>>> > Even starts at 2 and go every other number 2,4,6,8;2,0,-2,-4,-6,-8
>>>
>>> As it can be divided by 2 without a remainder, it is obviously even.
>>
>>The divisor would have to be something smaller than 0 like -2.
>>Therefore zero is both even and negative.
>
> ---
> Zero has no sign. Consider:
>
> If zero was positive, 1+0 > 1, but 1+0 = 0
> If zero was negative, 1+0 < 1, but 1+0 = 0

I thought 1+0 = 1, but I guess I can't do hard sums.
Androcles.



> -- 
> John Fields 




------------------------------

Date: Mon, 20 Dec 2004 15:40:38 +0000
From: John Woodgate <jmw@jmwa.demon.contraspam.yuk>
Subject: Re: Is zero even or odd?
Message-Id: <LcJXhRE2JvxBFwmr@jmwa.demon.co.uk>

I read in sci.electronics.design that Gactimus <gactimus@xrs.net> wrote
(in <10sdnunotbnere2@corp.supernews.com>) about 'Is zero even or odd?',
on Mon, 20 Dec 2004:
>I know 0 is neither negative or positive but what about odd/even? I think
>it's even. 
>
>Odd numbers start at 1 and go every other number 1,3,5,7;1,-1,-3,-5,-7
>Even starts at 2 and go every other number 2,4,6,8;2,0,-2,-4,-6,-8

There is other evidence. Even powers of negative numbers are positive,
and (-x)^0 = 1, which is usually positive. (;-)
-- 
Regards, John Woodgate, OOO - Own Opinions Only. 
The good news is that nothing is compulsory.
The bad news is that everything is prohibited.
http://www.jmwa.demon.co.uk Also see http://www.isce.org.uk 


------------------------------

Date: Mon, 20 Dec 2004 15:48:23 +0000
From: John Woodgate <jmw@jmwa.demon.contraspam.yuk>
Subject: Re: Is zero even or odd?
Message-Id: <QM1RleEHRvxBFwlq@jmwa.demon.co.uk>

I read in sci.electronics.design that Nicholas O. Lindan <see@sig.com>
wrote (in <PjCxd.4752$yK.1793@newsread3.news.atl.earthlink.net>) about
'Is zero even or odd?', on Mon, 20 Dec 2004:

>"John Sefton" <john@petcom.com> wrote 
>
>> 0 can't be divided by itself,
>
>Sure it can: 0 / 0 = 0 * (1 / 0) = 0 * infinity = 1 

One possible solution, given the enormous lack of rigour in 'infinity'.
But in general, 0/0 can take any value. Consider:

Lim {@->0}[(2377.pi.sin@)/@] = 2377.pi

-- 
Regards, John Woodgate, OOO - Own Opinions Only. 
The good news is that nothing is compulsory.
The bad news is that everything is prohibited.
http://www.jmwa.demon.co.uk Also see http://www.isce.org.uk 


------------------------------

Date: Mon, 20 Dec 2004 10:47:57 -0500
From: "Richards Noah \(IFR LIT MET\)" <Noah.Richards@infineon.com>
Subject: Re: Is zero even or odd?
Message-Id: <cq6s7f$nse$1@athen03.muc.infineon.com>


> > > Odd numbers start at 1 and go every other number 1,3,5,7;1,-1,-3,-5,-7
> > > Even starts at 2 and go every other number 2,4,6,8;2,0,-2,-4,-6,-8
> >
> > As it can be divided by 2 without a remainder, it is obviously even.
>
> The divisor would have to be something smaller than 0 like -2.
> Therefore zero is both even and negative.
>

A number n is considered even if there exists an integer m such that n = 2m.
Since 0 = (2) (0), it is even.

However, zero is *not* negative, or positive for that matter.  Positive and
negative numbers are defined in terms of 0, with positive being > 0 and
negative being < 0.  Since 0 is not greater than 0 and 0 is not less than 0,
0 is not positive or negative.

Just for kicks, zero is a *non-negative* and *non-positive* number, since
both of these sets include 0.




------------------------------

Date: Mon, 20 Dec 2004 16:02:50 +0000
From: Alec McKenzie <mckenzie@despammed.com>
Subject: Re: Is zero even or odd?
Message-Id: <mckenzie-524FF2.16025020122004@news.aaisp.net.uk>

> I seeem to recall 0 coming up negative in some old IBM mainframes. That was 
> an artifact of the way signed numbers were converted to binary.

In computers using ones complement arithmetic, the number zero can be 
represented in two ways: all bits zero (which appears positive) or all 
bits one (which appears negative).

But this is just a matter of how numbers are represented in the machine, 
and says nothing about whether zero is really a positive number, a 
negative number, or neither.m

-- 
Alec McKenzie
mckenzie@despammed.com


------------------------------

Date: 20 Dec 2004 06:57:44 -0800
From: "salsablr" <sudhirx@gmail.com>
Subject: Re: Length of Array of Array of Array
Message-Id: <1103554664.554150.127960@f14g2000cwb.googlegroups.com>


Well, I'm yet to figure out what is causing the problem.
My data structure is a little complex (atleast complex for me)

$# {$g_Ao_TEList[$index]{$teIt}[0][0]}
<=== This doesn't works; infact i tried to store the count in
$lines which results nothing.

I have an "Array(1)" which references to "Array of Hashes" and the
value of each of the keys in the array references to an "Array of Array
of Array"

Now 'm trying to get the last index of the Array from "Array of Array
of Array".... Any pointers..


Tad McClellan wrote:
> Tom <sudhirx@gmail.com> wrote:
>
> > How to find the length of an "Array of Array of Array"
> >
> > I get syntax error when i say $#fx[0][0][0]
>
>
> Well first off, the $#array syntax does NOT give you the length
> of the array, it gives you the last index in the array.
>
> The @array syntax in a scalar context gives you the length of the
array.
>
>
> To find the length of your multi-dim array, simply apply "Use Rule 1"
from:
>
>    perldoc perlreftut
>
>
> I usually do it in 3 steps:
>
>    my $length = @array;   # pretend it is a regular old array
>
>    my $length = @{   };   # replace the _name_ of the array with a
block
>
>    my $length = @{ $fx[0][0][0]  };   # fill in the block with code
that
>                                       # returns a reference to the
>                                       # right kind of thingy
>
> --
>     Tad McClellan                          SGML consulting
>     tadmc@augustmail.com                   Perl programming
>     Fort Worth, Texas



------------------------------

Date: 20 Dec 2004 06:52:11 -0800
From: "James" <djcameron60616@yahoo.com>
Subject: Re: MS Perl question -- how to use hacked script to work correctly(was Question on loops and return values or sumpin)
Message-Id: <1103554331.278223.5120@z14g2000cwz.googlegroups.com>


A. Sinan Unur wrote:
> "James" <djcameron60616@yahoo.com> wrote in
> news:1102535945.679552.290720@z14g2000cwz.googlegroups.com:
>
> > So the question is how to get this function (GetDriveSpace) to be
> > passed an array, essentially - is this impossible potentially
because
> > of the module design?  Resources.pm is the module used with this
> > script.  ShowKeys is what returns total, used and free space -- so
this
> > is a third factor in manipulating this array.
> > I'm really trying to get the values for used, total and free space
-
> > and I'm not quite sure how to get at it, and this is already taking
too
> > long for me to figure out.
>
> It would be useful if you learned a little bit of Perl first.
>
> > use lib "$ENV(HOME)/site/lib";
>
> What do you think this does?
>
> > no lib ".";
>
> Why do you think this is necessary?
>
> > use Win32::Resources;
>
> From:
>
>
http://search.cpan.org/~fabpot/Win32-Resources-0.02/lib/Win32/Resources.pm
>
>     Win32::Resources allows you to deal with windows
>     executable (.exe or .dll) resources (load, update
>     and delete resources).
>
> What does this have to do with getting drive space info?
>
> > use Win32API::Resources;
>
> OK. This module is not available through ppm but I found it on CPAN.
> Downloaded and installed it and read the docs. Have you tried that?
>
> > # use strict;
> > # use warnings;
>
> Why are these commented out?
>
> > my @Drives = Win32API::Resources::GetDrives();
> > my %DRVSpace = Win32API::Resources::GetDriveSpace("C:\\");
> > my $pathtofiles = "\\C:\\scripts\\";
> > my $pathtoserverslist = "\\\\xxxxxnnnnnn\\";
> > my $Threshold = "80";
> > my $last_updated = localtime (time);
>
> I give up. This crap is much too hard to read. So, you want to:
>
> 1. Find out what are the valid drive assignments on your system
> 2. Find out how much space is on each one
>
> Why not do that?
>
> use strict;
> use warnings;
>
> use Win32API::Resources;
>
> use Data::Dumper;
>
> sub get_drive_space_info {
>     my @drives = Win32API::Resources::GetDrives();
>     my %drives;
>     for (@drives) {
>         $drives{$_} = { Win32API::Resources::GetDriveSpace($_) };
>     }
>     return \%drives;
> }
>
> sub print_drive_space_info {
>     my %ds_info = %{ $_[0] };
>
>     for my $d (sort keys %ds_info) {
>         my %drive = %{ $ds_info{$d} };
>         print "Drive $d\n";
>         next if exists $drive{0};
>         for my $k (keys %drive) {
>             print "\t$k => $drive{$k}\n";
>         }
>     }
> }
>
> print_drive_space_info(get_drive_space_info());
>
>
> __END__
>
> Adapt this script to your needs.
>
>
> Sinan.

Sinan,

How are you this morning?
First off, thank you much for your help in the past.
Second, if you have the time/will to do so, can you suggest how to
optimize code like what follows, and any suggestions on strong checking
of integer bounds (i.e. pos/neg values affecting the script or its
results)?
Thanks .. James

--- CODE FOLLOWS ---

# perl -w
#
**************************************************************************
# dspace.pl -- script to calculate growth of used disk space over time.

# Some material gained from online help or sources, including usenet.
# Names of sources are available if necessary.  Wall and Frisch
examples
# from O'Reilly books helped set some structure or ideas.
#
***************************************************************************
use strict 'vars';
use strict;
use warnings;
use Win32API::Resources;
use Win32::NetAdmin;
use Data::Dumper;
our $lastvalue_updated = localtime (time);
our @Drives;
my $server=our @Driveinfo;
my $username=Win32::LoginName();
open(HANDLE1,"machines.txt") || die "open: $!";
open(HANDLE2,">>growth.txt") || die "open: $!";
print "\nSome drives may not show results due to no disk\n";
print "in drive, empty drive or other errors.\n";
print "\nThe following are valid disk drives: @Drives\n";
while (@Driveinfo=<HANDLE1>)
{
if (not($username eq "our-admin" or "Administrator"
or Win32::NetAdmin::ourGroupIsMember
($server, "Administrators", $username)))
{
exit;
}
print_drive_space_info(get_drive_space_info());
}
close(HANDLE1) || die "close0: $!";
close(HANDLE2) || die "close0: $!";
print "\n\nlastvalue run: $lastvalue_updated\n";

sub get_drive_space_info
{
my @drives = Win32API::Resources::GetDrives();
my %drives;
for (@drives)
{
$drives{$_} = { Win32API::Resources::GetDriveSpace($_) };
}
return \%drives;
}

sub print_drive_space_info
{
my %ds_info = %{ $_[0] };
our $total = 0;
our $free = 0;
our $used = 0;
our $growth = 0;
our $growthrate = 0;
for my $d (sort keys %ds_info)
{
my %drive = %{ $ds_info{$d} };
print "Drive $d\n";
next if exists $drive{0};
for my $k (keys %drive)
{
my $string = ($k => $drive{$k});
print "\t$k => $drive{$k}\n";
if ($k eq "DriveSpaceQuotaFree")
{
my $nada = scalar($drive{$k});
next;
}
elsif ($k eq "DriveSpaceTotal")
{
$total = (scalar($drive{$k}) / 1000000);
}
elsif ($k eq "DriveSpaceFree")
{
$free = (scalar($drive{$k}) / 1000000);
}
$used = ($total - $free);
$growth = ($used);
$growthrate = (($growth * 100) / $total);
$total = sprintf("%5.2f","$total");
$free = sprintf("%5.2f","$free");
$used = sprintf("%5.2f","$used");
$growth = sprintf("%5.2f","$growth");
$growthrate = sprintf("%3.2f","$growthrate");
}
print HANDLE2 "$d  $total  $free  $used  $growth  $growthrate
$lastvalue_updated\n";
    }
}
__END__



------------------------------

Date: 20 Dec 2004 15:24:20 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: MS Perl question -- how to use hacked script to work correctly(was Question on loops and return values or sumpin)
Message-Id: <Xns95C569DA419C2asu1cornelledu@132.236.56.8>

"James" <djcameron60616@yahoo.com> wrote in
news:1103554331.278223.5120@z14g2000cwz.googlegroups.com: 

> A. Sinan Unur wrote:

[ Full quotation snipped. Don't do that. Figure out the relevant parts of 
  the post you are replying to, and quote only those parts. Please go 
  ahead and re-read the posting quidelines so you can help others help 
  you. ]

> First off, thank you much for your help in the past.

You are welcome.

> Second, if you have the time/will to do so, can you suggest how to
> optimize code like what follows, 

You should first get it to compile:

C:\Home> perl -c d4.pl
Semicolon seems to be missing at d4.pl line 7.
Bareword found where operator expected at d4.pl line 12, near "*
use strict"
        (Missing operator before strict?)
String found where operator expected at d4.pl line 12, near "strict 'vars'"
        (Do you need to predeclare strict?)
syntax error at d4.pl line 11, near "examples
# from O'Reilly books helped set some structure or ideas.
#
"
BEGIN not safe after errors--compilation aborted at d4.pl line 13.

> and any suggestions on strong checking of integer bounds (i.e. pos/neg 
> values affecting the script or its results)?

I am not sure what this all means.

> # perl -w

You don't need the shebang line on Windows but the proper syntax is, say,

#! /usr/bin/perl

Note the exclamation point (the bang in shebang).

> use strict 'vars';

Why? You should drop this.

> use strict;
> use warnings;
> use Win32API::Resources;
> use Win32::NetAdmin;
> use Data::Dumper;
> our $lastvalue_updated = localtime (time);
> our @Drives;

You should declare your variables within the smallest applicable scope.

> my $server=our @Driveinfo;

What on earth do you think this does?

The rest of your code, for example, 

> for my $k (keys %drive)
> {
> my $string = ($k => $drive{$k});
> print "\t$k => $drive{$k}\n";
> if ($k eq "DriveSpaceQuotaFree")
> {
> my $nada = scalar($drive{$k});
> next;
> }

can only be described as insanity-inducing. It looks like you have not even 
made an attempt to actually read any Perl documentation.

In addition to the posting guidelines, it looks like the following 
discussion is also relevant in your case:

http://perl.plover.com/Questions.html

You could at least show a minimal amount of respect to your readers by 
properly formatting your source code and does not have glaring syntax 
errors.

> $used = ($total - $free);
> $growth = ($used);

Huh?

> $growthrate = (($growth * 100) / $total);

Isn't growth supposed represent the change in the used space from the last 
time drives were checked?

> $total = sprintf("%5.2f","$total");
> $free = sprintf("%5.2f","$free");
> $used = sprintf("%5.2f","$used");
> $growth = sprintf("%5.2f","$growth");
> $growthrate = sprintf("%3.2f","$growthrate");
> }
> print HANDLE2 "$d  $total  $free  $used  $growth  $growthrate
> $lastvalue_updated\n";

Anyway, what is stopping you from:

my $last_update = localtime time;

printf HANDLE2, "%5.2f %5.2f %5.2f %5.2f %3.2f %s",
    	$d, $total, $free, $used, $growth, $growthrate, $last_update;

Why you would want to have the last update stamp at the end of the line is 
beyond me but whatever floats your boat.

Sinan.


------------------------------

Date: Mon, 20 Dec 2004 09:37:47 -0500
From: Ken <x3v0-usenet@yahoo.com>
Subject: Re: Newbie question
Message-Id: <0tBxd.11390$FE.8574@fe37.usenetserver.com>

> ####################### SCRIPT #######################
> 
> #!/usr/local/bin/perl -w
> 
> # turn on perl's safety features
> use strict;
> #use warning;
> 
> # load our modules
> 
> my $msg;
> my $current_dir = `pwd`;
> my $log="dtest.log";
> print "Current directory is $current_dir";
> 
> # Main
> 
> prepare
> 

Try this instead:

prepare();

You can't call subroutines without the parentheses. You also need to 
make sure all expressions end in a semicolon.



------------------------------

Date: Tue, 14 Dec 2004 08:48:51 -0800
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: pause, wait, etc.
Message-Id: <141220040848517504%jgibson@mail.arc.nasa.gov>

In article <1103041464.304626@nntp.acecape.com>, daniel kaplan
<nospam@nospam.com> wrote:

> Hi all,
> 
> Am looking for some type of a "pause" function.  Long story short, have
> written a quick script that will send out, one time only, some 400 emails
> (reminders for a specific event).
> 
> My thing is this, while I am using:
> 
> unless(open (MAIL, "| /usr/sbin/sendmail -t -oi -odq"))
> 
> with the "queue" parameter, truth is, I don't really trust the mail server
> at my hosting place.  I would swear, they sneeze and the mail server goes
> down.  So putting 400 emails in their queue, I just don't trust.  At the
> same time, turning off the "queue" is rude, and would be far worse than
> sneezing!
> 
> So I looked for some type of function that would pause my script for X
> seconds, in between each email.  But between CPAN and perldoc came up short.
> 
> Does such a beast exist?

sleep, sleep, sleep, ... , and the answer will appear to you in a
dream. :)


-----------== Posted via Newsfeed.Com - Uncensored Usenet News ==----------
   http://www.newsfeed.com       The #1 Newsgroup Service in the World!
-----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19 Servers =-----


------------------------------

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 7540
***************************************


home help back first fref pref prev next nref lref last post