[11285] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4885 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Feb 13 00:07:31 1999

Date: Fri, 12 Feb 99 21:00:21 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 12 Feb 1999     Volume: 8 Number: 4885

Today's topics:
    Re: ActiveState GDBM or Equivalent? <xrxoxtxhxdx@xrxoxtxhx.xnxextx>
    Re: Announce: Perl Function Repository (was Re: Calcula <uri@sysarch.com>
    Re: Announce: Perl Function Repository (was Re: Calcula <dgris@moiraine.dimensional.com>
        bugs in dbmopen? <amayc@gyro.mit.edu>
    Re: Can't ODBC or ADO to Oracle8 NT <xrxoxtxhxdx@xrxoxtxhx.xnxextx>
    Re: choosing start_element() vs. startElement() dturley@pobox.com
    Re: choosing start_element() vs. startElement() <jdf@pobox.com>
    Re: Comments in Perl code <mpersico@erols.com>
    Re: Deleting array elements while looping through... (M.J.T. Guy)
    Re: File Creation ? <no_amaring@jps.net>
        Following a Redirect <mwatkins@promotion4free.com>
        Formats not printing <achoy@us.oracle.com>
        How to dereference properly (Marc-A. Woog)
    Re: How to dereference properly <jdf@pobox.com>
        passing multiple arrays to a subroutine (Cybernetic Bear)
    Re: passing multiple arrays to a subroutine <jeffp@crusoe.net>
    Re: passing multiple arrays to a subroutine <mwatkins@promotion4free.com>
    Re: passing multiple arrays to a subroutine <jeffp@crusoe.net>
    Re: Perl function to reboot NT Server? (Abigail)
    Re: Perl function to reboot NT Server? <xrxoxtxhxdx@xrxoxtxhx.xnxextx>
    Re: PFR: UTC_to_Epoch (Jari Aalto+mail.emacs)
    Re: Python vs. Perl vs. tcl ? (William Tanksley)
        Shell access? <bgarrett@hamilton.net>
    Re: Simple question for a complex PERLie <kswong@bigpond.com>
    Re: String Terminator scraig@my-dejanews.com
    Re: Trying to get IP of a client machine (I R A Aggie)
    Re: Trying to get IP of a client machine (Henry Penninkilampi)
    Re: Win32 perl how to do system(set var= $var) (Pedro Miguel A. C. Raposo)
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Fri, 12 Feb 1999 18:37:17 -0800
From: "Dave Roth" <xrxoxtxhxdx@xrxoxtxhx.xnxextx>
Subject: Re: ActiveState GDBM or Equivalent?
Message-Id: <%y5x2.3142$lx.1206@news2.giganews.com>

Eric Bohlman wrote in message ...
>[removed non-existent comp.lang.perl from newsgroups and followups]
>
>John Kane <jdkane@akanewmedia.com> wrote:
>: Can anyone tell me if a GDBM hash file module (or equivalent) exists for
>: ActiveState PERL on the Windows platform?
>
>AFAICT, there's no port of GDBM, but there *is* a port of DB_File.
>
>: SDBM (and others) limit the hash value to 1000 characters. GDBM on UNIX
>: allows much larger values. I want to use a hash file that allows large
>: values on the windows platform.
>
>DB_File should meet your needs.
>

There is indeed a port of GDBM_File for Win32.
  http://www.roth.net/perl/gdbm/

dave
--
=================================================================
Dave Roth                                ...glittering prizes and
Roth Consulting                      endless compromises, shatter
http://www.roth.net                     the illusion of integrity
Win32, Perl, C++, ODBC, Training
rothd at roth dot net

Our latest Perl book is now available:
"Win32 Perl Programming: The Standard Extensions"
http://www.roth.net/books/extensions/





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

Date: 12 Feb 1999 13:30:44 -0500
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Announce: Perl Function Repository (was Re: Calculate yesterdays           date)
Message-Id: <x7k8xno4ob.fsf@home.sysarch.com>

>>>>> "DG" == Daniel Grisinger <dgris@moiraine.dimensional.com> writes:

  DG> [posted and mailed]
  DG> merlyn@stonehenge.com (Randal L. Schwartz) writes:

  >> Will it be changed to thedaybefore() tomorrow? :)

  DG> Of course not.  Tomorrow it will be amended to read-

  DG> my $yesterday = yesterday();
  DG> my $daybefore = yesterday's_yesterday();

boy, you are wrong here. there is no package called ysterday. (bet you
forgot that ' used (and is still supported) to be the package space
delimiter).

it should be:

$day_of_yore = yesterday( $is_it_then_yet ? $today : yesterday() );

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
Perl Hacker for Hire  ----------------------  Perl, Internet, UNIX Consulting
uri@sysarch.com  ------------------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: 12 Feb 1999 17:45:04 -0700
From: Daniel Grisinger <dgris@moiraine.dimensional.com>
Subject: Re: Announce: Perl Function Repository (was Re: Calculate yesterdays date)
Message-Id: <m3yam33ze7.fsf@moiraine.dimensional.com>

ilya@math.ohio-state.edu (Ilya Zakharevich) writes:

> If you are picking snippets from the newsfeed, probably it is good to
> supply a DejaNews thread URL (is there such a beast?) so that people
> will be able to track the related discussion as well.

That sounds like a good idea.  I'll work on it later tonight.

dgris
-- 
Daniel Grisinger          dgris@moiraine.dimensional.com
perl -Mre=eval -e'$_=shift;;@[=split//;;$,=qq;\n;;;print 
m;(.{$-}(?{$-++}));,q;;while$-<=@[;;' 'Just Another Perl Hacker'


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

Date: Fri, 12 Feb 1999 19:00:44 -0500
From: Amay Champaneria <amayc@gyro.mit.edu>
Subject: bugs in dbmopen?
Message-Id: <36C4C0AC.295095CE@gyro.mit.edu>

Has anyone found bugs in the dbmfile implementation found in Perl
5.004_04 (for dec alpha)?  I'm using dbmopen and dbmclose in CGI
scripts, and every now and then a script hangs.  

-Amay Champaneria


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

Date: Fri, 12 Feb 1999 18:40:40 -0800
From: "Dave Roth" <xrxoxtxhxdx@xrxoxtxhx.xnxextx>
Subject: Re: Can't ODBC or ADO to Oracle8 NT
Message-Id: <aC5x2.3147$lx.1518@news2.giganews.com>

Bueller wrote in message <79vfnp$h3k$1@nnrp1.dejanews.com>...
>Howdy all,
>
>I've been writing Perl to connect to databases for a month or so now. I've
>used WIN32::OLE and WIN32::ODBC and so far had no problems reading and
>writing to MS Access and SQL Server databases. However I've installed
Oracle
>8.0.3 for NT and can't connect using any method. I get the following
message
>from the open connection -
>
>[160] [] "Specified driver could not be loaded due to system error 126
(Oracle
>ODBC Driver)."
>
>I don't think it's an ODBC problem on the host as I can successfully link
and
>query tables from the Oracle database to an MS Access DB via ODBC.
>
>I've checked all the doco, Oracles site and searched the Net and haven't
had
>any luck as yet. I have an uneasy feeling that it could be that the Oracle
>8.0.3 driver is ODBC 2.5 not 3.0 (3.0 required for WIN32::ODBC etc.) but
I'm
>not completely sure that this is the case. Can anyone either confirm this
(so
>I'll get Oracle 8.0.4) or suggest a workaround.

You need to turn on your ODBC tracing and then send me the log file.
It sounds like you have a configuration problem with the ODBC driver.
BTW: Win32::ODBC only requires ODBC v2.5. :)

dave

--
=================================================================
Dave Roth                                ...glittering prizes and
Roth Consulting                      endless compromises, shatter
http://www.roth.net                     the illusion of integrity
Win32, Perl, C++, ODBC, Training
rothd at roth dot net

Our latest Perl book is now available:
"Win32 Perl Programming: The Standard Extensions"
http://www.roth.net/books/extensions/





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

Date: Sat, 13 Feb 1999 02:19:33 GMT
From: dturley@pobox.com
Subject: Re: choosing start_element() vs. startElement()
Message-Id: <7a2nff$bf0$1@nnrp1.dejanews.com>

In article <MPG.112e5d58e15cad30989a34@nntp.hpl.hp.com>,
  lr@hpl.hp.com (Larry Rosler) wrote:
> In article <36C4B030.F5F1D273@giss.nasa.gov> on Fri, 12 Feb 1999
> 17:50:24 -0500, Jay Glascoe <jglascoe@giss.nasa.gov> says...
> ...
> > Ken, words cannot convey my intense feelings of displeasure
> > for the whole "guessTheCapitalizationOfThisLetter"
> > game...  <shudder>.  It's also hard to read.  Really.
>
> Especially for people for whom English is not their native language.

English *is* my native language, and I hate names like that. I was just given
3 MB of files (179 "pieces")containing server-side JavaScript code to review
(all written by C++ programmers), and every single variable name and every
single function name is written as mixed case words.

I was dizzy after the first 30 minutes!

--

____________________________________
David Turley

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: 12 Feb 1999 23:02:40 -0500
From: Jonathan Feinberg <jdf@pobox.com>
To: Ken MacLeod <ken@bitsko.slc.ut.us>
Subject: Re: choosing start_element() vs. startElement()
Message-Id: <m3vhh7vtlr.fsf@joshua.panix.com>

Ken MacLeod <ken@bitsko.slc.ut.us> writes:

> Java's style for method names is mixed-case with initial lower case,
> like `startElement()'.
> 
> Perl's recommended style, as I'm sure you know, is to use all lower
> case seperated with underscores, like `start_element()'.

After_you've_been_using_underscores_for_a_while,
they_start_to_"feel_like"_spaces.
IFindItHardToBelieveThatTheSameIsTrueOfStudlyCaps.  LoseTheStudlyCaps.

-- 
JonathanFeinbergJdf@Pobox.ComSunnyBrooklynNY
Http://Pobox.Com/~Jdf


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

Date: Fri, 12 Feb 1999 21:10:51 -0500
From: "Matthew O. Persico" <mpersico@erols.com>
Subject: Re: Comments in Perl code
Message-Id: <36C4DF2B.BBBC9A3A@erols.com>

As long as we're on the subject...

I'm using cperl-mode 4.19 and I almost cannot break it. Lord knows I've
tried. But every time I think it's messed up the indenting or font
coloring it has turned out to be a typo or a construct that didn't make
it through perl -c.

Except for one tiny thing that drives me nuts.

Pod.

No let me rephrase that.

Possessives in pod. As in:

	this function's arguments.

cperl 4.19 reads that as a string start and I get all green text until
the next random possessive in my pod.

I can live with keyword highlighting in my pod and the indenting seems
fine, but is there a way to add another "hard construct" for single
quotes in pod to be ignored?

Much obliged.

You know, that old truism about the only thing being able to parse perl
is perl isn't quite so true anymore.

Ilya Zakharevich wrote:
> 
> [A complimentary Cc of this posting was sent to Russ Allbery
> <rra@stanford.edu>],
> who wrote in article <ylsocc7kl2.fsf@windlord.stanford.edu>:
> > >> % perl -pi.bak -e 's/\#.*$//' file.pl
> > >                        ^   ^
> > >                         Why?
> >
> > The trailing $ clearly isn't needed, true.
> 
> In this particular case, yes.  But without -p it would changes the semantic.
> 
> >                                             The backslash before the # is
> > a habit I'm in as well since it unconfuses cperl-mode's syntax
> > highlighting, which otherwise is under the impression the rest of the
> > expression is a comment.
> 
> Only on primitive Emaxen.  On RMS's Emacs 20.3 CPerl has no problem
> with this.
> 
> >
> > There are a few odd nits like that with cperl-mode (dealing with (\s|$) in
> > a regex is another one), some of which may be related to the fact that I'm
> > still using emacs 19.34 and therefore don't have the benefit of the new
> > parsing code that's supposedly in emacs 20.  (But for doubters, cperl-mode
> > works wonderfully the vast majority of the time and makes writing and
> > debugging Perl considerably faster.)
> 
> The patches for 19.34 are available (including CPAN).  I use 19.33 myself.
> 
> Ilya

-- 
Matthew O. Persico
http://www.erols.com/mpersico
http://www.digistar.com/bzip2


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

Date: 13 Feb 1999 00:00:20 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Deleting array elements while looping through...
Message-Id: <7a2fak$i90$1@pegasus.csx.cam.ac.uk>

In article <79v6tt$8mm$1@nnrp1.dejanews.com>,  <dhosek@webley.com> wrote:
>Programmatically it's really not a problem:
>
>$j=0;
>ENTRY: for(@test) {
>   if ($_ meets deletion criteria) {
>      @test=(@test[0..$j-1],$test[$j+1..$#test]);
>      redo ENTRY;
>   }
>   $j++;
>}
>
>Questions: Am I really as bullet-proof as I think I am?

What sort of bullets do you have in mind?    Have you read the
documentation, in particular (from   perldoc perlsyn ) ?

     If any part of LIST is an array, foreach will get very
     confused if you add or remove elements within the loop body,
     for example with splice.   So don't do that.


Mike Guy


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

Date: Fri, 12 Feb 1999 18:23:18 -0800
From: "amaring" <no_amaring@jps.net>
Subject: Re: File Creation ?
Message-Id: <36c5577f.0@news1.jps.net>

My problem is it won't create the file called file.tmp, it creates a file
called "$file",  Is there any reason for this?




It creates a file called "file.tmp" as you would expect. (OK it opens the
file for writing creating it if possible and needed)...

Now what was your question again?

--
Sam

You can blame it all on the internet. I do...
--Larry Wall




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

Date: Sat, 13 Feb 1999 01:44:54 -0000
From: "Mike Watkins" <mwatkins@promotion4free.com>
Subject: Following a Redirect
Message-Id: <ego7mKvV#GA.139@nih2naae.prod2.compuserve.com>

Hi there,

I'm currently making a URL submission script which will submit to serveral
FFA pages.  The actual submission works fine, but I would
like to be able to verify that the link was actually submitted a little
better.  Most FFA scripts will redirect the user, instead of give any
actual output, so $HTML = $reponse->content() doesn't really work.


I've finally figured out how to tell if the script redirects the user or
not.  I do this will the following code:

use HTTP::Status;
my $scode = $response->code()
if (is_redirect($scode)) { ... }

I would like the script to check the page it gets redirected to for a
pre-defined block of text, like "Thanks For The Link".  My question is,
how do I get the content of the web page which the FFA script redirects to?

Any help would be much appreciated,
Mike Watkins






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

Date: Fri, 12 Feb 1999 16:20:45 -0800
From: Allen Choy <achoy@us.oracle.com>
Subject: Formats not printing
Message-Id: <36C4C55D.2779520A@us.oracle.com>


Hi,

I recently built perl 5.004_04 on an ultra-sparc.  Everything seems to
work,
except code that uses formats.  Any ideas?

Thanks,

allen

Here are my perl -V stats:

Summary of my perl5 (5.0 patchlevel 4 subversion 4) configuration:
  Platform:
    osname=solaris, osvers=2.5.1, archname=sun4-solaris
    uname='sunos davinci 5.5.1 generic_103640-05 sun4u sparc
sunw,ultra-1 '
    hint=recommended, useposix=true, d_sigaction=define
    bincompat3=y useperlio=undef d_sfio=undef
  Compiler:
    cc='gcc', optimize='-O', gccversion=2.8.1
    cppflags='-I/usr/local/include'
    ccflags ='-I/usr/local/include'
    stdchar='unsigned char', d_stdstdio=define, usevfork=false
    voidflags=15, castflags=0, d_casti32=define, d_castneg=define
    intsize=4, alignbytes=8, usemymalloc=y, prototype=define
  Linker and Libraries:
    ld='gcc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib /usr/ccs/lib
    libs=-lsocket -lnsl -ldl -lm -lc -lcrypt
    libc=/lib/libc.so, so=so
    useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
    cccdlflags='-fpic', lddlflags='-G -L/usr/local/lib'


Characteristics of this binary (from libperl):
  Built under solaris
  Compiled at Feb  5 1999 19:48:36
  @INC:
    /private/packages/perl5/lib/sun4-solaris/5.00404
    /private/packages/perl5/lib
    /private/packages/perl5/lib/site_perl/sun4-solaris
    /private/packages/perl5/lib/site_perl
    .



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

Date: Sat, 13 Feb 1999 02:09:08 GMT
From: mwoog@pobox.ch (Marc-A. Woog)
Subject: How to dereference properly
Message-Id: <36c5de80.33232275@news.datacomm.ch>

Hi,

I am doing my first steps with references and I am getting kinda
crazy. I have stored references to hashes in the hash %levels. This
seems to be working. Now I would like to dereference the stored hashes
and sort them by keys. But the sorting doesn't work, so I assume I am
not dereferencing right (believe me: I've read perlref back and forth
without even getting close).

(-w and 'use strict' is on)

foreach $key (sort keys %levels) {
 print "$key\n";
 foreach $level (@{$levels{"$key"}}) {
  # I assume that I am doing something wrong here
  %hash = %$level;
  # cause this doesn't get sorted
  foreach $bookmark (sort keys %hash) {
   print "$bookmark -> $hash{$bookmark}\n";
  }
 }
}

Could anynone help me out? Thanks for any answers!

Regards,

Marc


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

Date: 12 Feb 1999 23:10:36 -0500
From: Jonathan Feinberg <jdf@pobox.com>
To: mwoog@pobox.ch
Subject: Re: How to dereference properly
Message-Id: <m3socbvt8j.fsf@joshua.panix.com>

mwoog@pobox.ch (Marc-A. Woog) writes:

> I have stored references to hashes in the hash %levels.

Okay, solid.

> foreach $key (sort keys %levels) {
>  print "$key\n";
>  foreach $level (@{$levels{"$key"}}) {
                   ^

Whoah, you said that $level{$key} is a reference to a hash, but you're
dereferencing it as if it were an array ref.

Which is it?

If it's indeed a hash ref, you can examine it like so

  foreach my $bookmark (keys %{$levels{$key}}) {
     # do something with $levels{$key}->{$bookmark}
  }

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


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

Date: Sat, 13 Feb 1999 00:19:50 GMT
From: cybear_x[nospam]@geocities.com (Cybernetic Bear)
Subject: passing multiple arrays to a subroutine
Message-Id: <36c4c3bf.23286415@news.webhart.net>

I am trying to pass two arrays to a subroutine, but its not working. I
am certain that my subroutine is created properly because I can pass
single variables to it without any problems, and I can pass a single
array to it, but not two arrays.

The subroutine call looks like this:
$return=createHTML($tempfile, $galleryfile, $scandir, @ufound,
@tfound);

The subroutine looks like this:
sub createHTML{
	my ($tempfile, $galleryfile, $scandir, @userfound,
@titlefound)= @_;
 ---additional non-related code ---

I'm sure its a simple problem, but what am I missing?

Thanks

Dave


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

Date: Fri, 12 Feb 1999 19:43:32 -0500
From: evil Japh <jeffp@crusoe.net>
Subject: Re: passing multiple arrays to a subroutine
Message-Id: <Pine.GSO.3.96.990212193839.19433A-100000@crusoe.crusoe.net>

Read perldoc perldsc, and perldoc perlref.

But here's a sampler:

something(\@array1,\@array2);

sub something {
	my ($aref1,$aref2) = @_;
	my @a1 = @$aref1;
	my @a2 = @$aref2;
	# etc...
}

-- 
Jeff Pinyan (jeffp@crusoe.net)
www.crusoe.net/~jeffp

Crusoe Communications, Inc.
973-882-1022
www.crusoe.net



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

Date: Sat, 13 Feb 1999 01:03:01 -0000
From: "Mike Watkins" <mwatkins@promotion4free.com>
Subject: Re: passing multiple arrays to a subroutine
Message-Id: <ORpMNzuV#GA.280@nih2naae.prod2.compuserve.com>

Hi there,

Yeah, I had the exact same problem as you.  All I did was put the two arrays
in a hash, then sent the hash over.  For some reason,  it seems like perl
doesn't know when an array ends, and when another begins.  Or, you can join
one for the arrays and make it a single variable, then pass it through the
subroutine.

I'm sure there's a better solution, but this way works.

Hope that helps,
Mike


Cybernetic Bear <"cybear_x[nospam]"@geocities.com> wrote in message
<36c4c3bf.23286415@news.webhart.net>...
>I am trying to pass two arrays to a subroutine, but its not working. I
>am certain that my subroutine is created properly because I can pass
>single variables to it without any problems, and I can pass a single
>array to it, but not two arrays.
>
>The subroutine call looks like this:
>$return=createHTML($tempfile, $galleryfile, $scandir, @ufound,
>@tfound);
>
>The subroutine looks like this:
>sub createHTML{
> my ($tempfile, $galleryfile, $scandir, @userfound,
>@titlefound)= @_;
> ---additional non-related code ---
>
>I'm sure its a simple problem, but what am I missing?
>
>Thanks
>
>Dave




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

Date: Fri, 12 Feb 1999 20:48:38 -0500
From: evil Japh <jeffp@crusoe.net>
Subject: Re: passing multiple arrays to a subroutine
Message-Id: <Pine.GSO.3.96.990212204706.19433B-100000@crusoe.crusoe.net>

> in a hash, then sent the hash over.  For some reason,  it seems like perl
> doesn't know when an array ends, and when another begins.  Or, you can join

That's because in the list ($a,$b,@c,@d,$e), @c and @d are expanded, and
so the list becomes not 5 elements, but 1 + 1 + (how many in @c) + (how
many in @d) + 1.  Sending arrays as references to arrays is a safe way of
doing this.

-- 
Jeff Pinyan (jeffp@crusoe.net)
www.crusoe.net/~jeffp

Crusoe Communications, Inc.
973-882-1022
www.crusoe.net



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

Date: Sat, 13 Feb 1999 00:29:40 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Perl function to reboot NT Server?
Message-Id: <UH3x2.3070$rs2.2689661@client.news.psi.net>

droby@copyright.com (droby@copyright.com) wrote on MCMXCI September
MCMXCIII in <URL:news:7a25l3$sd7$1@nnrp1.dejanews.com>:
__ 
__ Which brings to mind a sure-fire method, with some robotics programming on a
__ second machine (Unix of course).  ;-)


For a sure-fire method, you might prefer using VMS.



Abigail
-- 
perl -wle 'print "Prime" if (1 x shift) !~ /^1?$|^(11+?)\1+$/'


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

Date: Fri, 12 Feb 1999 19:09:56 -0800
From: "Dave Roth" <xrxoxtxhxdx@xrxoxtxhx.xnxextx>
Subject: Re: Perl function to reboot NT Server?
Message-Id: <E16x2.3175$lx.1210@news2.giganews.com>

Georg Buehler wrote in message <79vp3j$uc9$1@camel18.mindspring.com>...
>I need to programmatically reboot a Windows NT 4.0 server using Perl.
>
>I'm sure such a function exists, but I've poured over the module
>documentation in vain.
>
>I'm currently using ActiveState's 5.00502.

This is from Chapter 9 of my book. It explains about how to initiate a
system
shutdown (and reboot). This can be done remotely as well as on the local
machine.
In some builds of 5.005 the shutdown functions in the Win32 extension were
removed. You will want to check and make sure that yours does indeed have it
implimented. I believe that ActivePerl (from ActiveState) has always had it
in their Win32 extension.

Shutting Down A Machine
=======================
If your user account has been granted the appropriate privileges your
script can force a Win32 machine to shutdown using the
InitiateSystemShutdown() function:

  Win32::InitiateSystemShutdown( $Machine, $Message, $Countdown, $Force,
$Reboot );

The first parameter ($Machine) is the name of a machine which is to
shut down. If this parameter is an empty string () then the local machine
will be affected.

The second parameter ($Message) is a text string message that will be
displayed on the screen of the computer specified in the first parameter.
Typically this is something informing the user that the machine is going to
shut down so all files should be saved.

The third parameter ($Countdown) is a numeric value which represents the
amount of time (in seconds) before the shut down process begins -- a type
of countdown. When a shut down is initiated the message specified as the
second parameter is displayed on the screen and the number of seconds before
shut down is displayed. This countdown will start at the time specified as
the third parameter. An administrator will usually specify some amount of
time, like 5 minutes, giving a user enough time to properly finish saving
files or finish and send email messages.

The fourth parameter ($Force) is a flag indicating whether or not the
machine should force a shut down or not. If a system shut down is forced
then applications will not be given a chance to save open files [em] they
are simply shut down. This forceful shut down will occur if the fourth
parameter
is a non zero value. Otherwise the each application will ask the user to
save
open files during the shut down process.

The fith parameter ($Reboot) is a flag that indicates whether or not to
reboot
the machine. If the value is non zero then the machine will shut down
followed
by a reboot.

The function returns TRUE (1) if the specified computer will initiate the
shut
down process otherwise the computer will not shut down and the function
returns
FALSE (0).

For the Win32::InitiateSystemShutdown() function to be successful the user
who
calls the function must have the privilege SE_SHUTDOWN_NAME (Force A
Shutdown
>From A Remote System) enabled on the computer which is to be shut down.

If the $Countdown value (the third parameter) is zero (0) then no message
will
be displayed on the specified computer and the shutdown will begin
immediately
and there will be no chance for any aborting the shut down. At any time
during
the countdown process (before shut down actually begins) the shut down can
be
aborted using the Win32::AbortShutdown() function:

  Win32::AbortSystemShutdown( $Machine );

The only parameter ($Machine) specifies which computer is to to abort a shut
down. If the parameter is an empty string () then the local machine is
specified.

This function will return TRUE (1) if the function is successful. The
function
is considered successful if it submits the request to abort a shut down and
the
request is accepted by the specified machine. Even if the specified machine
is
not shutting down but the abort request was successfully sent then the
function
is considered successful. Otherwise the function fails and returns FALSE
(0).

Just as with Win32::InitiateSystemShutdown() the SE_SHUTDOWN_NAME privilege
(Force A Shutdown From A Remote System) must be enabled on the specified
machine for the user who calls this function.

If a user initiates a system shut down by means of hitting CTRL+ALT+DEL and
specifying shutdown the operating system will initiate the shutdown with a
countdown of zero therefore this type of shutdown can not be aborted using
this
function.

There is an alternative to the Win32::InitiateSystemShutdown() function
which
provides for more options although it only works on the local machine. This
is the
Win32::AdminMisc::ExitWindows() function:

 Win32::AdminMisc::ExitWindows( $ExitTpe );

The only parameter ($ExitType) is a flag which specifies exactly how Windows
will exit. This can be any value from Table 9.25. This value can also be
logically
ORed with EWX_FORCE which will cause applications to quit without saving
any open
files. This is a harsh way of shutting down but could be necessary if an
unattended
shut down or logoff is required.

If the function is successful it returns a TRUE value and begins its
exiting
process otherwise if fails and returns FALSE.


Table 9.25: Various Exit Types for the Win32::AdminMisc::ExitWindows()
function.
EWX_LOGOFF.......Log the user off. Applications will be informed so the
                 user may be prompted to save files.
EWX_POWEROFF.....Force the system to shutdown and power off. The system must
                 support poweroff. On Windows NT the user account calling
the
                 function the SE_SHUTDOWN_NAME privilege.
EWX_REBOOT.......Shut down the system and reboot the computer. On Windows NT
                 the user account calling the function the SE_SHUTDOWN_NAME
                 privilege.
EWX_SHUTDOWN.....Shut down the system but don't reboot. On Windows NT the
user
                 account calling the function the SE_SHUTDOWN_NAME
privilege.


NOTE:
Both the Win32::InitiateSystemShutdown() and Win32::AbortShutdown() have
been moved
out of the Win32 extension if Perl 5.005. The source code suggests that it
will be
moved to other extensions but does not indicate which ones.

dave

--
=================================================================
Dave Roth                                ...glittering prizes and
Roth Consulting                      endless compromises, shatter
http://www.roth.net                     the illusion of integrity
Win32, Perl, C++, ODBC, Training
rothd at roth dot net

Our latest Perl book is now available:
"Win32 Perl Programming: The Standard Extensions"
http://www.roth.net/books/extensions/





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

Date: 12 Feb 1999 17:52:07 +0200
From: jari.aalto@poboxes.com (Jari Aalto+mail.emacs)
Subject: Re: PFR: UTC_to_Epoch
Message-Id: <ptr7ltnbowo.fsf@olkikukka.i-have-a-misconfigured-system-so-shoot-me>

lr@hpl.hp.com (Larry Rosler) writes:

> 
> In article <m3d83g92nf.fsf_-_@moiraine.dimensional.com> on 11 Feb 1999 
> 12:11:16 -0700, Daniel Grisinger <dgris@moiraine.dimensional.com> 
> says...
> > lr@hpl.hp.com (Larry Rosler) writes:
> > 
> > > What I would like to see is a dynamic on-line equivalent of the kind of 
> > > code published in The Perl Cookbook, contributed to and reviewed 
> > > collaboratively, and with a searchable index.
> 
> 
> As ground rules, I suggest that all functions be '-w' and 'use strict;' 
> compliant.  Lines should fit without folding; tabs should be avoided.  
> Documentation is 'good', but test code might not be necessary, to keep 
> the volume down.
> 

I would suggest too that each piece of function be documented with
standard banner, for example like what I use in my perl programs.

jari


# ****************************************************************************
#
#   DESCRIPTION
#
#       Return ISO 8601 date YYYY-MM-DD
#
#   INPUT PARAMETERS
#
#       none
#
#   RETURN VALUES
#
#       $str
#
# ****************************************************************************

sub DateYYYY_MM_DD ()
{
    my $id        = "$LIB.DateYYYY_MM_DD";

    my (@time)    = localtime(time);
    my $YY        = 1900 + $time[5];
    my ($DD, $MM) = @time[3..4];
#   my ($mm, $hh) = @time[1..2];

    $debug and warn "$id: @time\n";

    #   I don't know why Month(MM) is one less that the number month
    #   in my calendar. That's why +1. Does it count from zero?

    sprintf "%d-%02d-%02d", $YY, $MM + 1, $DD;
}


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

Date: Sat, 13 Feb 1999 04:55:18 GMT
From: wtanksle@dolphin.openprojects.net (William Tanksley)
Subject: Re: Python vs. Perl vs. tcl ?
Message-Id: <slrn7ca64o.1hs.wtanksle@dolphin.openprojects.net>

On Fri, 12 Feb 1999 18:53:56 GMT, @l@ wrote:
>  Lars Marius Garshol <larsga@ifi.uio.no> wrote:

>> I agree with that. What bothered me and made me write the article was
>> mainly that a lot of people seemed to choose Perl without even knowing
>> Python, tcl, Ruby, REXX or anything else existed at all.

>Come on .. you can't hate Perl just because it's popular!

He didn't say he hated Perl -- he said that he was bothered by the fact that
people chose it without considering the alternatives.  It bothers a lot of
us -- it's _very_ hard to find a website with any reasons to program in Perl
instead of Python.  I think I've seen one (and I've searched), and it was
_wrong_.

>> I basically wanted to scream out and see if something happened. And it
>> did: I got the frustration out of my system. :)

>You also got me into reading more Python :) So far, I like it .. I think
>there are a lot of similarities with Perl.

Yes, we've stolen a lot from Perl, and vice versa.

>Treating everything as an object
>will be tricky at the beginning (for me at least), but I am planning to get
>over that. I wonder how I will feel about it as I read more. I have heard
>some people say that choosing to write their next program in Perl or Python
>is basically determined by a coin toss. That scares me :)

Amusing :).  I would choose Perl pretty consistently for text munching, and
Python for everything else.

>> I agree that these are weak points in the syntax. However, I can't
>> really think of any better alternatives myself, and also, they are in
>> parts of the language I rarely need. So thankfully the damage is

>Hmmm.. you rarely need print() statements in your scripts?

No, he was talking about the comma hack -- how you make print not output a
newline.

>Most of my scripts
>generate some form of report after some extensive analysis. I don't think I
>can live without print()! (or can I?)

I would imagine that must of your reports are line-oriented, and that you
want a newline more often than not.  When you don't want one, you can either
use comma, or you can use the write method of any file object.

>> limited. (And, yes, it reminds me too of Basic, although the varieties
>> I've used used ';' instead of ','.)

>Yep .. that's it. It has been so long :)

Ditto.  In fact, I learned my second computer language, assembly, because I
didn't know how to make Basic not print a newline.  Ironic, huh?  It was
fun.

>> The trouble with references in Perl for me is that I generally
>> organize my programs around my data structure and I think in terms of
>> the data structure. So languages that make it hard for me to build the
>> data structure do not get a lot of points. :)

>I guess you just have to learn how to think in the proper way when dealing
>with references.

Yup.

>Treating everything as objects in Python also needs some
>getting used to.

Sort of.  It's not like you *have* to make objects.  You do have to use
them, of course, most of the time.

>I guess I'll just have to wait and see.

Good luck.

>--Ala

-- 
-William "Billy" Tanksley
"There is nothing more silly than a silly laugh."
             -Gaius Valerius Catullus


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

Date: Fri, 12 Feb 1999 22:40:17 -0800
From: Bill Garrett <bgarrett@hamilton.net>
Subject: Shell access?
Message-Id: <36C51E4E.24D918D3@hamilton.net>

Hello,
I have just started to learn perl programming and didn't have access to
a unix shell.  I   was wondering if anyone knew where to get a unix
shell account for free.  Would anyone consider letting me have access to
there unix shell account?
Thanks,
Jason



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

Date: Sat, 13 Feb 1999 11:15:28 +1100
From: Ka-shu Wong <kswong@bigpond.com>
Subject: Re: Simple question for a complex PERLie
Message-Id: <Pine.LNX.4.03.9902131107570.268-100000@goose>



On Fri, 12 Feb 1999, Gregg Yows wrote:

[snip]

> I can't do a simple string switch because I only want to switch the last
> part of the string.

Yes you can.  You just put the first bit back in:

$newstring = "<img src=u.jpg>";
s#(<td>(?!&nbsp;).*?</td>.*?)<td>&nbsp;</td>#$1<td>$newstring</td>#s;

This regexp seems to do the trick.  The whole html file must be in $_
though...


KS




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

Date: Sat, 13 Feb 1999 01:54:46 GMT
From: scraig@my-dejanews.com
Subject: Re: String Terminator
Message-Id: <7a2m13$adl$1@nnrp1.dejanews.com>




> print <<"_END_";
> </BODY>
> </HTML>
> _END_
>
> when I compile the program it says that the string terminator _END_ couldn't
> be found before the end of the program.  Obviously it is there,

  It's not obvious that it's there.  Whitespace doesn't show up on the
screen. That's usually the problem for me when I get this message.  The
string terminator must be "_END_\n" exactly, but I've inadvertantly made it
"_END_ \n", which looks just the same. Try moving with the arrow keys on that
line, or select the text, to see if there are any extra spaces.



-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: 13 Feb 1999 01:16:41 GMT
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: Trying to get IP of a client machine
Message-Id: <slrn7c9koj.p19.fl_aggie@enso.coaps.fsu.edu>

On Fri, 12 Feb 1999 14:24:58 -0800, R J SIngh <rjsing@hotmail.com> wrote:

+ I am currently facing a problem in obtaining IP address of a client
+ machine that is sending a request to my server. I am using
+ $ENV{REMOTE_ADDR} to obtain the IP address of the client. But what I am
+ getting is the IP address of the proxy server to which the client is
+ connected.

1. This isn't a perl question
2. I don't think you can

James


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

Date: Sat, 13 Feb 1999 13:54:52 +1030
From: htp@dove.net.au (Henry Penninkilampi)
Subject: Re: Trying to get IP of a client machine
Message-Id: <htp-1302991354520001@htp5500.metropolis.net.au>

fl_aggie@thepentagon.com:
>rjsing@hotmail.com:
>
>+ I am currently facing a problem in obtaining IP address of a client
>+ machine that is sending a request to my server. I am using
>+ $ENV{REMOTE_ADDR} to obtain the IP address of the client. But what I am
>+ getting is the IP address of the proxy server to which the client is
>+ connected.
>
>1. This isn't a perl question
>2. I don't think you can

Use JavaScript to obtain the IP address of the client's machine and submit
this information along with the rest of the form as an invisible field.

Henry.


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

Date: Sat, 13 Feb 1999 02:24:16 GMT
From: Pedro.Raposo@tmn.pt (Pedro Miguel A. C. Raposo)
Subject: Re: Win32 perl how to do system(set var= $var)
Message-Id: <7a2o03$i4j$1@duke.telepac.pt>

>Thanks for your answer. I did not think about using child processes. I was
>under the delusion that I could set this environment variable with one script
>in a batch file and the next script in the same batch file would be able to
>pick it up and use it.  Thanks.

[Stuff Deleted]

Of course you could always use Win32::AdminMisc to set the environment 
variable (either system wide, or just user)

"Remember, Luke, there's more than one way of doing it ..."

Pedro Raposo


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

Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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

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