[23888] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6091 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Feb 7 03:05:34 2004

Date: Sat, 7 Feb 2004 00:05:07 -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           Sat, 7 Feb 2004     Volume: 10 Number: 6091

Today's topics:
    Re: ?-xism: <andy@andyh.co.uk>
        @INC unshift? <nospam@nospam.net>
    Re: @INC unshift? <uri@stemsystems.com>
    Re: ANSI(?) characters from perl debug are unwanted (Walter Roberson)
    Re: Counting words <krahnj@acm.org>
    Re: Counting words <bmb@ginger.libs.uga.edu>
    Re: CPAN cc vs. gcc <me@privacy.net>
    Re: How to execute a command line in Perlscript (Eric SALGON)
    Re: how to find the last "new line" in string (Charles DeRykus)
    Re: how to find the last "new line" in string (Walter Roberson)
    Re: Need help passing arrays by reference pls. <tadmc@augustmail.com>
    Re: Need help passing arrays by reference pls. <kuujinbo@hotmail.com>
    Re: Need help passing arrays by reference pls. (Walter Roberson)
    Re: NNTP Subject Parsing $_@_.%_
    Re: NNTP Subject Parsing $_@_.%_
    Re: Perl and WMI <Petri_member@newsguy.com>
    Re: Perl script into a Windows Service <ceo@nospan.on.net>
    Re: Perl script into a Windows Service <andy@andyh.co.uk>
    Re: Perl script into a Windows Service (Cosmic Cruizer)
    Re: Req.for Advice: Learning Perl <none@hotmail.com>
    Re: Req.for Advice: Learning Perl <ebohlman@earthlink.net>
    Re: SourceCode : perl OOPS by Conway: (David Combs)
        Using "static" in Perl Extensions <mshelor@comcast.removeme.net>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sat, 07 Feb 2004 02:28:22 +0000
From: Andy Hassall <andy@andyh.co.uk>
Subject: Re: ?-xism:
Message-Id: <q3j820tjd59u1e6qmst5g6g0hff1gglvg0@4ax.com>

On Thu, 05 Feb 2004 22:05:39 GMT, fishfry <BLOCKSPAMfishfry@your-mailbox.com>
wrote:

>The statement
>
>  print qr/abc/;
>
>produces the output
>
>(?-xism:abc)
>
>I looked in man perlop and didn't find a clear description of what this 
>means. Where's this documented? What's it mean?

 perldoc perlre



 See also module YAPE::Regex::Explain
<http://theoryx5.uwinnipeg.ca/CPAN/data/YAPE-Regex-Explain/Explain.html> 

 ... which says:

 The regular expression:

(?-imsx:abc)

matches as follows:
  
NODE                     EXPLANATION
----------------------------------------------------------------------
(?-imsx:                 group, but do not capture (case-sensitive)
                         (with ^ and $ matching normally) (with . not
                         matching \n) (matching whitespace and #
                         normally):
----------------------------------------------------------------------
  abc                      'abc'
----------------------------------------------------------------------
)                        end of grouping
----------------------------------------------------------------------

-- 
Andy Hassall <andy@andyh.co.uk> / Space: disk usage analysis tool
<http://www.andyh.co.uk> / <http://www.andyhsoftware.co.uk/space>


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

Date: Sat, 07 Feb 2004 06:17:54 GMT
From: "Jeff Thies" <nospam@nospam.net>
Subject: @INC unshift?
Message-Id: <mq%Ub.13698$jH6.6223@newsread1.news.atl.earthlink.net>

  I have shared hosting with an out of date LWP module.

  I'd like to point to a local recent version, but it reads the out of date
copy.

Can I unshift a path onto @INC so it looks there first? There must be a
better way to point to the right path just for this module.

  I can't seem to find the docs for this. Maybe I'm just hazed over!

  Jeff




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

Date: Sat, 07 Feb 2004 06:46:51 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: @INC unshift?
Message-Id: <x73c9nqtd0.fsf@mail.sysarch.com>


use lib 'path/to/new/lwp' ;

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: 7 Feb 2004 00:00:14 GMT
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Subject: Re: ANSI(?) characters from perl debug are unwanted
Message-Id: <c019qe$9oa$1@canopus.cc.umanitoba.ca>

In article <b7784f4d.0402060900.6d625a70@posting.google.com>,
Alan <alan_santacruz@yahoo.com> wrote:
:The display from perl -d is showing what i guess are ANSI display
:control sequences in an Windows XP Command Prompt window.

:E.g. the command line  
:    perl -d -e 42
:gives
:    main::(-e:1):   42
:    ?[4;m  DB<1> ?[1mq

Those are ANSI alright. Turn on underline, then turn on bold.


:How can the ANSI output be turned off,

You could remove the Term::ANSI module I suppose.


:or alternatively XP be told to handle the ANSI correctly?

Sorry, no clue on that part.
-- 
   Any sufficiently advanced bug is indistinguishable from a feature.
   -- Rich Kulawiec


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

Date: Sat, 07 Feb 2004 00:55:27 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Counting words
Message-Id: <40243722.DA0C2860@acm.org>

Brad Baxter wrote:
> 
> On Thu, 6 Feb 2004, Walter Roberson wrote:
> 
> > In article <Pine.A41.4.58.0402052134460.28924@ginger.libs.uga.edu>,
> > Brad Baxter  <bmb@ginger.libs.uga.edu> wrote:
> > :On Wed, 4 Feb 2004, Fran wrote:
> > :> Can anybody please tell me how to count words? If a need to know if an
> > :> input has n words, how do I do it? Thank you
> >
> > :perl -pale '$=+=@F}{*_=*=' input
> >
> > That's cruel!
> 
> Flatterer.

Unfortunately the count will be off by 60 because $= starts with the
value 60.

perl -pale '$=+=@F}{$_=$=-60' input


John
-- 
use Perl;
program
fulfillment


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

Date: Fri, 6 Feb 2004 22:05:08 -0500
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: Counting words
Message-Id: <Pine.A41.4.58.0402062141230.11678@ginger.libs.uga.edu>

On Sat, 7 Feb 2004, John W. Krahn wrote:

> Brad Baxter wrote:
> > On Thu, 6 Feb 2004, Walter Roberson wrote:
> > > In article <Pine.A41.4.58.0402052134460.28924@ginger.libs.uga.edu>,
> > > Brad Baxter  <bmb@ginger.libs.uga.edu> wrote:
> > > :perl -pale '$=+=@F}{*_=*=' input
> > > That's cruel!
> > Flatterer.
>
> Unfortunately the count will be off by 60 because $= starts with the
> value 60.
>
> perl -pale '$=+=@F}{$_=$=-60' input

Too true.  I should have stopped here and been happy.

perl -pale '$n+=@F}{*_=*n' input

My apologies to the OP.

Brad


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

Date: Sat, 7 Feb 2004 13:13:23 +1300
From: "Tintin" <me@privacy.net>
Subject: Re: CPAN cc vs. gcc
Message-Id: <c01amg$12d1tq$1@ID-172104.news.uni-berlin.de>


"Mike Hunter" <mhunter@uclink.berkeley.edu> wrote in message
news:slrnc27fsp.gt.mhunter@celeste.net.berkeley.edu...
> I have a sun box I'd like to build cpan packages on.  Uname -a tells me it
is
> using solaris "5.9"....

Actually, SunOS 5.9 or Solaris 9

>I have gcc installed on the machine, but `cc` seems
> to be just a shell script that does nothing.

Well, it does do something.  It tells you there is no compiler installed.

>
> For whatever reason, cpan seems to want to try to build c files with cc
> instead of gcc.  I tried symlinking cc to gcc, but that didn't work.
Where
> can I tell cpan to use gcc instead of cc?

Try either changing the order of your PATH setting to move /usr/ucb to the
end, or better still, just link /usr/ucb/cc to /usr/local/bin/gcc




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

Date: Fri, 6 Feb 2004 11:17:41 +0000 (UTC)
From: eric.salgon@mane.com (Eric SALGON)
Subject: Re: How to execute a command line in Perlscript
Message-Id: <bvvt4l$76t$1@s1.read.news.oleane.net>

Unfortunatly, I have implemented "shell" and "puts" functions in my ASP code 
but `$_` return no result in @output array with a simple 'dir' command.

I'm afraid it's a problem of right on my IIS server.

Eric

In article <elvUb.19067$Fp6.2360@newssvr16.news.prodigy.com>, 
ceo@nospan.on.net says...
>
>Eric SALGON wrote:
>> Hi,
>> 
>> Is there someone who knows how to execute a command line (such a simple 
echo 
>> cmd) in PerlScript.
>> 
>> I hve tryed '' or system() but the result is the same: no result but no 
error 
>> !
>> 
>> This syntax works fine in a perl program but not in PerlScript
>> 
>> An idea ?
>> 
>
>I just realized I didn't answer your question in my last response.
>
>First of all, as a general rule, and one that is outlined in the FAQ 
>(and asked about a lot here is) system() does NOT provide output.  But 
>most especially in the Windows world where Microsoft writes their own 
>rules, this is also not the case in either ASP or WSH (still assuming 
>you are talking about "PerlScript" and not "Perl script.")
>
>Using output wrappers in the ASP and WSH worlds for outputing a string, 
>the following code will work in both worlds for outputing a "system" 
>command:
>
>sub shell {
>
>    my @output;
>    for (@_) { push( @output, `$_` ) }
>    chomp( @output );
>    return wantarray ? @output : \@output;
>
>}
>
>puts( shell( 'dir /l/on/' ) );
>
>or you can:
>
>puts( shell(
>    'dir',
>    'type c:\\autoexec.bat',
>    'dir c:\\winnt\\system32',
>    'command4',
>    'command5',
>));
>
>If:
>
>ASP: sub puts { for (@_) { $Response->Write( "$_\n" ) } }
>WSH: sub puts { for (@_) { $WScript->Echo( "$_\n" ) } }
>
>Incidentially using PerlScript in Windows allows you this convenience. 
>The "official" Microsoft "interface" (read "complicated and 
>convolluted") for executing a command in a scripting environment (both 
>ASP and WSH) is WshShell.Exec() (which takes two calls to set up.)  You 
>can do this in PerlScript if you want, but the regular Perl way of 
>executing a system command works much smoother.
>
>HTH,
>Chris
>-----
>Chris Olive
>chris -at- --spammers-are-vermen-- technologEase -dot- com
>http://www.technologEase.com
>(pronounced "technologies")
>
>



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

Date: Sat, 7 Feb 2004 05:41:23 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: how to find the last "new line" in string
Message-Id: <Hsp94z.IL0@news.boeing.com>

In article <4023460D.DB525A34@acm.org>, John W. Krahn <krahnj@acm.org> wrote:
>Walter Roberson wrote:
>> 
>> In article <4022E838.33F20CBC@acm.org>, John W. Krahn <krahnj@acm.org> wrote:
>> :hshen wrote:
>> 
>> :> If a string contains a few lines, (separated by '\n'), how can I make
>> :> a  regular expression to replace this '\n' by a space?
>> 
>> :You don't really need a regular expression.
>> 
>> :$string =~ tr/\n/ /;
>> 
>> But the Subject refers to the *last* "new line" in the string;
>> your proposed solution would change *all* of them.
>
>Yah, I hate when they put the important information in the subject line
>instead of the actual message.  :-)
>
>$_ = reverse $string;
>s/\n/ /;
>$string = reverse $_;
>

Did someone already mention:   $string =~ s/\n\Z//;

 

--
Charles DeRykus


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

Date: 7 Feb 2004 06:19:50 GMT
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Subject: Re: how to find the last "new line" in string
Message-Id: <c02026$j7v$1@canopus.cc.umanitoba.ca>

In article <Hsp94z.IL0@news.boeing.com>,
Charles DeRykus <ced@bcstec.ca.boeing.com> wrote:
:Did someone already mention:   $string =~ s/\n\Z//;

That's wrong in three ways:

              \Z  Match only at end of string, or before newline at the end
              \z  Match only at end of string

Bug #1: If the newline is the last character of the string,
\n\Z is going to want to match a newline -before- that.

Bug #2: The poster wanted to replace the last newline with a space,
not remove it.

Bug #3: If the last newline in the string is not at the end of the
string, the pattern won't match it.

This should work, though (I think):

  $string =~ s/\n([^\n]*)\z/ \1/;
-- 
   "There are three kinds of lies: lies, damn lies, and statistics."
   -- not Twain, perhaps Disraeli, first quoted by Leonard Courtney


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

Date: Fri, 6 Feb 2004 17:14:51 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Need help passing arrays by reference pls.
Message-Id: <slrnc287vb.28e.tadmc@magna.augustmail.com>

G Klinedinst <g_klinedinst@hotmail.com> wrote:

> for my $a ( @subArr1 ) {

> If I can figure out how to do that using the references, like you are
> using I will do that


Apply "Use Rule 1" from perlreftut.pod:

   for my $a ( @subArr1 ) {   # pretend it is a regular array

   for my $a ( @{     } ) {   # replace the array _name_ with a block...

   for my $a ( @{ $subArr1_ref } ) {   # ... that returns a ref to an array

(and in this case you can drop the block's curlies)


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Sat, 07 Feb 2004 12:50:32 +0900
From: ko <kuujinbo@hotmail.com>
Subject: Re: Need help passing arrays by reference pls.
Message-Id: <c01ncm$rtq$1@pin3.tky.plala.or.jp>

Walter Roberson wrote:

> In article <168f035a.0402061349.79d8b12b@posting.google.com>,
> G Klinedinst <g_klinedinst@hotmail.com> wrote:
> :> # You should avoid the unnecessary concatenations you had in your code.
> 
> :Why is that? Are the commas implemented faster, or just for
> :readability?
> 
> Commas in print's are converted into concatenation internally, so both
> have the same execution speed.

Got a question about the paragraph above ...

[snip]

Remember reading somewhere that there is a difference between the two, so I
tried this:

bash-2.05b$ cat bench && bench
#!/usr/bin/perl -w
use strict;
use Benchmark;

my $str = 'x' x 100_000;
my $null = ($^O !~ /win/i) ? '/dev/null' : 'nul';
open(NULL, ">$null") or die $!;

timethese(10_000, {
    commas => sub {print NULL $str, $str, $str, $str},
    concat => sub {print NULL $str . $str . $str . $str}
});

__END__
Benchmark: timing 10000 iterations of commas, concat...
commas:  3 wallclock secs ( 0.67 usr +  1.71 sys =  2.38 CPU)
@ 4196.72/s (n=10000)

concat:  6 wallclock secs ( 3.88 usr +  1.70 sys =  5.58 CPU)
@ 1792.72/s (n=10000)

Please correct the usage if I made a mistake - rarely use Benchmark, as I
still have a lot to learn and am trying to concentrate on writing readable
good code versus writing fast code. But I would like to understand why
there is a speed difference - is it actually the case that 'Commas in
print's are converted into concatenation internally'. Is this even
something to be concerned about?

thanks in advance - keith


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

Date: 7 Feb 2004 05:35:58 GMT
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Subject: Re: Need help passing arrays by reference pls.
Message-Id: <c01tfu$i5i$1@canopus.cc.umanitoba.ca>

In article <c01ncm$rtq$1@pin3.tky.plala.or.jp>,
ko  <kuujinbo@hotmail.com> wrote:
:Walter Roberson wrote:
:> Commas in print's are converted into concatenation internally, so both
:> have the same execution speed.

:Got a question about the paragraph above ...

You think I can find the part of the documentation I was thinking of?
No.... :(
-- 
   Those were borogoves and the momerathsoutgrabe completely mimsy. 


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

Date: Sat, 07 Feb 2004 05:29:06 GMT
From: $_@_.%_
Subject: Re: NNTP Subject Parsing
Message-Id: <CI_Ub.2766$M8.1874@nwrdny02.gnilink.net>

Well ive had a look at both of those pieces of code.
And I must say that the programming is very very impressive indeed!
I've learned quite a bit looking at the examples, I thank you all
very much for the helpfull input.

I've made some progress with this, but ive run into a tricky bit.
What it is.. how do i print this HoHoA so that i can test the result?

        #ToDo...combine multi-part articles
        #$xover{$_}[0] #subject      #$xover{$_}[4] #references
        #$xover{$_}[1] #from         #$xover{$_}[5] #bytes
        #$xover{$_}[2] #date         #$xover{$_}[6] #lines
        #$xover{$_}[3] #message-id   #$xover{$_}[7] #xref:full
        #m/(.+)[(\[\{]+?(\d+)[\/\-]+?(\d+)[)\]\}]+?/
        #$1 is: subject, $2 is: part, $3 is: total parts
        # (HoHoA) subject->total parts->current part, msg id
        
        my %HoHoA;
        for my $k (sort keys %xover) {
            if ($xover{$k}[0] =~
                m/(.+)[(\[\{]+?(\d+)[\/\-]+?(\d+)[)\]\}]+?/) {
                push @{$HoHoA{$1}{$3}}, "$2";
                push @{$HoHoA{$1}{$3}}, "$xover{$k}[3]";
            }
        }


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

Date: Sat, 07 Feb 2004 07:39:24 GMT
From: $_@_.%_
Subject: Re: NNTP Subject Parsing
Message-Id: <MC0Vb.16215$IF1.7662@nwrdny03.gnilink.net>

> Well ive had a look at both of those pieces of code.
> And I must say that the programming is very very impressive indeed!
> I've learned quite a bit looking at the examples, I thank you all
> very much for the helpfull input.
> 
> I've made some progress with this, but ive run into a tricky bit.
> What it is.. how do i print this HoHoA so that i can test the result?
> 
>         #ToDo...combine multi-part articles
>         #$xover{$_}[0] #subject      #$xover{$_}[4] #references
>         #$xover{$_}[1] #from         #$xover{$_}[5] #bytes
>         #$xover{$_}[2] #date         #$xover{$_}[6] #lines
>         #$xover{$_}[3] #message-id   #$xover{$_}[7] #xref:full
>         #m/(.+)[(\[\{]+?(\d+)[\/\-]+?(\d+)[)\]\}]+?/
>         #$1 is: subject, $2 is: part, $3 is: total parts
>         # (HoHoA) subject->total parts->current part, msg id
>         
>         my %HoHoA;
>         for my $k (sort keys %xover) {
>             if ($xover{$k}[0] =~
>                 m/(.+)[(\[\{]+?(\d+)[\/\-]+?(\d+)[)\]\}]+?/) {
>                 push @{$HoHoA{$1}{$3}}, "$2";
>                 push @{$HoHoA{$1}{$3}}, "$xover{$k}[3]";
>             }
>         }
> 
n/m i got it :-)

        open (FH, '> test');
        for my $k1 (keys %HoHoA) {
            for my $k2 (keys %{$HoHoA{$k1}}) {
                print FH "subject: $k1\n";
                print FH "has $k2 parts total\n";
                print FH "this is the information for this subject\n";
                foreach (@{$HoHoA{$k1}{$k2}}) {
                    print FH "$_\n"
                }
                print FH "\n"
            }
        }
        close FH;


subject: Att:CHARLI 320bps[04/14] - "The Smoky Mountain Players - Smoky Moumtain Old Time Favorites - 03 - The Great Speckled Bird.mp3" yEnc 
has 8 parts total
this is the information for this subject
1
<nMBUb.182379$Rc4.1349880@attbi_s54>
2
<BMBUb.184720$sv6.955576@attbi_s52>
3
<OMBUb.182381$Rc4.1350709@attbi_s54>
4
<0NBUb.182384$Rc4.1350590@attbi_s54>
5
<eNBUb.184723$sv6.954877@attbi_s52>
6
<rNBUb.182385$Rc4.1350702@attbi_s54>
7
<ENBUb.182386$Rc4.1350712@attbi_s54>
8
<QNBUb.185030$5V2.895547@attbi_s53>


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

Date: 6 Feb 2004 19:37:27 -0800
From: Petri <Petri_member@newsguy.com>
Subject: Re: Perl and WMI
Message-Id: <c01mhn0veg@drn.newsguy.com>

In article <5dd9b03b.0402060819.407264d8@posting.google.com>, seldn says...
> I know how to query the WMI in VBScript to get system information,
> however, can this also be done in Perl?  I've downloaded and
> installed ActiveState Perl; I guess what I'm looking for now is
> the best modules that can be used for this task.

All you need is Win32::OLE, and it's standard in ActivePerl.
If you already know how to use the Windows Script Object from VBScript, you
basically already have all you need to do the same tasks in Perl. :)

Look at the stuff under Windows Scripting in the table of contents of your
ActivePerl html documentation to see what I mean.

Here is an example of accessing WMI from Perl:
---8<---
#! c:\perl\bin\perl.exe
# Script to demonstrate using WMI 
# Requires that WMI core classes be installed
#   from http://www.microsoft.com/management/wmi
# Retrieves info from the local system

use strict;
use Win32::OLE qw(in with);

my $wmi = Win32::OLE->GetObject("winmgmts:");

print "Computer System\n";
print "-" x 20,"\n";
my $sys_set = $wmi->InstancesOf("Win32_ComputerSystem");
foreach my $sys (in($sys_set)) {
  print "Caption:  ".$sys->{'Caption'}."\n";
  print "PriOwner: ".$sys->{'PrimaryOwnerName'}."\n";
  print "SysType:  ".$sys->{'SystemType'}."\n";
  print "Domain:   ".$sys->{'Domain'}."\n";
}

print "\n";
print "Operating System\n";
print "-" x 30,"\n";
my $os_set = $wmi->InstancesOf("Win32_OperatingSystem");
foreach my $os (in($os_set)) {
  print "Caption:       ".$os->{'Caption'}."\n";
  print "Manuf:         ".$os->{'Manufacturer'}."\n";
  print "BootDevice:    ".$os->{'BootDevice'}."\n";
  print "System Dir:    ".$os->{'SystemDirectory'}."\n";
  print "Organization:  ".$os->{'Organization'}."\n";
  print "BuildNum:      ".$os->{'BuildNumber'}."\n";
  print "Build:         ".$os->{'BuildType'}."\n";
  print "Version:       ".$os->{'Version'}."\n";
  print "CSDVersion:    ".$os->{'CSDVersion'}."\n";
  print "Locale:        ".$os->{'Locale'}."\n";
  print "WinDir:        ".$os->{'WindowsDirectory'}."\n";
  print "TotMem:        ".$os->{'TotalVisibleMemorySize'}." bytes\n";
  print "SerNum:        ".$os->{'SerialNumber'}."\n";
}

print "\n";
print "PageFile Settings\n";
print "-" x 30,"\n";
my $pf_set = $wmi->InstancesOf("Win32_PageFile");
foreach my $pf (in($pf_set)) {
  print "Name:     ".$pf->{'Name'}."\n";
  print "Initial:  ".$pf->{'InitialSize'}." MB\n";
  print "Max:      ".$pf->{'MaximumSize'}." MB\n";
}

print "\n";
print "Services\n";
print "-" x 20,"\n";
my $serv_set = $wmi->InstancesOf("Win32_Service");
foreach my $serv (in($serv_set)) {
  print "Service => ".$serv->{'DisplayName'}."  [".$serv->{'Name'}."]\n";
  print "\tState:        ".$serv->{'State'}."\n";
  print "\tStatus:       ".$serv->{'Status'}."\n";
  print "\tExecuteable:  ".$serv->{'PathName'}."\n";
  print "\tStart Name:   ".$serv->{'StateName'}."\n";
  print "\tPID:          ".$serv->{'ProcessID'}."\n";
  print "\n";
}

print "\n";
print "Processes\n";
print "-" x 20,"\n";
my $proc_set = $wmi->InstancesOf("Win32_Process");
printf "%-10s %-40s\n","PID","Name";
printf "%-10s %-40s\n","-" x 5,"-" x 20;
foreach my $proc (in($proc_set)) {
  printf "%-10s %-40s\n",$proc->{'ProcessID'},$proc->{'Name'};
}

print "\n";
print "Print Jobs\n";
print "-" x 20,"\n";
my $print_set = $wmi->InstancesOf("Win32_PrintJob");
if ($print_set->{'Count'} eq 0) {
  print "No print jobs.\n";
}
else {
  foreach my $print (in($print_set)) {
    print "Name:  ".$print->{'Name'}."\n";
    print "\tJobID:        ".$print->{'JobID'}."\n";
    print "\tStatus:       ".$print->{'Status'}."\n";
    print "\tTotal Pages:  ".$print->{'TotalPages'}."\n";
    print "\n";
  }
}

print "\n";
print "Network Connections\n";
print "-" x 20,"\n";
my $conn_set = $wmi->InstancesOf("Win32_NetworkConnection");
foreach my $conn (in($conn_set)) {
  printf "%-40s %-10s\n",$conn->{'Name'},$conn->{'Caption'};
}

print "\n";
print "Logical Disks\n";
print "-" x 20,"\n";
my $disk_set = $wmi->InstancesOf("Win32_LogicalDisk");
foreach my $disk (in($disk_set)) {
printf "%-7s %-25s %-8s
%-5s\n",$disk->{'DeviceID'},$disk->{'Description'},$disk->{'FileSystem'},$disk->{'DriveType'};
}

print "\n";
print "Network Adapters\n";
print "-" x 20,"\n";
my $adapt_set = $wmi->InstancesOf("Win32_NetworkAdapter");
foreach my $adapt (in($adapt_set)) {
  print $adapt->{'Name'}."\n";
  print "\tType:           ".$adapt->{'AdapterType'}."\n";
  print "\tDesc:           ".$adapt->{'Description'}."\n";
  print "\tDeviceID:       ".$adapt->{'DeviceID'}."\n";
  print "\tStatus:         ".$adapt->{'Status'}."\n";
  print "\tManuf:          ".$adapt->{'Manufacturer'}."\n";
  print "\tMAC:            ".$adapt->{'MACAddress'}."\n";
  print "\tInstall Date:   ".$adapt->{'InstallDate'}."\n";
  print "\n";
}

print "\n";
print "Desktop\n";
print "-" x 20,"\n";
my $dt_set = $wmi->InstancesOf("Win32_Desktop");
foreach my $dt (in($dt_set)) {
  print $dt->{'Name'}."\n";
  print "\tScreenSave active:   ".$dt->{'ScreenSaverActive'}."\n";
  print "\tScreenSaver .exe:    ".$dt->{'ScreenSaverExecutable'}."\n";
  print "\tScreenSaver secure:  ".$dt->{'ScreenSaverSecure'}."\n";
  print "\tScreenSaver timeout: ".$dt->{'ScreenSaverTimeout'}." sec\n";
  print "\n";
}

print "\n";
print "User Accounts\n";
print "-" x 20,"\n";
my $user_set = $wmi->InstancesOf("Win32_UserAccount");
foreach my $user (in($user_set)) {
  print $user->{'Name'}."\n";
  print "\tDomain:       ".$user->{'Domain'}."\n";
  print "\tSID:          ".$user->{'SID'}."\n";
  print "\tCaption:      ".$user->{'Caption'}."\n";
  print "\tDescription:  ".$user->{'Description'}."\n";
  print "\tDisabled:     ".$user->{'Disabled'}."\n";
  print "\tStatus:       ".$user->{'Status'}."\n";
  print "\tLockout:      ".$user->{'Lockout'}."\n";
  print "\t***Password Settings***\n";
  print "\t\tChangeable:  ".$user->{'PasswordChangeable'}."\n";
  print "\t\tRequired:    ".$user->{'PasswordRequired'}."\n";
  print "\t\tExpires:     ".$user->{'PasswordExpires'}."\n";
  print "\n";
}
---8<---

I think that example is originally from Microsoft themselves...
I used it 3.5 years ago to get started on WMI-hacking. :)

Hope this helps!

Petri



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

Date: Sat, 07 Feb 2004 00:23:00 GMT
From: Chris <ceo@nospan.on.net>
Subject: Re: Perl script into a Windows Service
Message-Id: <EdWUb.32572$x26.824@newssvr33.news.prodigy.com>

Cosmic Cruizer wrote:
> For the last several months, I have been trying to turn a simple Perl script 
> into a Windows 2000 service. I keep finding a lot of question about doing 
> this in newsgroups, but I have yet to find an easy to follow solution. Can 
> anybody recommend either a book, web page, article, or something that will 
> help me out? It almost sounds like setting up a Perl script to run as a 
> service is an urban legend. 
> 

No, it's not an urban legend.  It's actually not that hard to do. 
Recent versions of Perl make this rather easy to do.  I know this sounds 
weird, but I don't have access to the Web right now to find what I know 
is out there, but do some searching on Dave Roth -- he's king of Perl 
Win32 and I know I saw some outlines from him within the last two years 
on the preferred way to create WinNT-based services using ActiveState Perl.

The poor man's method, which works best for older versions of 
ActiveState Perl (esp. 5.00x) is to use Microsloth's SRVANY.EXE 
executable.  Look in Microsloth's (pathetic) Support/KB engine for 
SRVANY.EXE and see what you come up with.  There is a KB article that 
explains the registry pokes/insertions that need to be done to setup 
your own service using a script and SRVANY.EXE.

Writing an installer to install an app using either method is not hard 
to do either.

I can be more specific about the SRVANY.EXE method if you need more 
guidance.  Hope this gets you going.

Chris
-----
Chris Olive
chris -at- --spammers-are-vermin-- technologEase -dot- com
http://www.technologEase.com
(pronounced "technologies")


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

Date: Sat, 07 Feb 2004 00:31:39 +0000
From: Andy Hassall <andy@andyh.co.uk>
Subject: Re: Perl script into a Windows Service
Message-Id: <jec8205j9h5lt6pccf7aihusui37c5s3i2@4ax.com>

On Fri, 06 Feb 2004 21:52:52 GMT, XXjbhuntxx@white-star.com (Cosmic Cruizer)
wrote:

>For the last several months, I have been trying to turn a simple Perl script 
>into a Windows 2000 service.

http://theoryx5.uwinnipeg.ca/CPAN/data/Win32-Daemon-Simple/Simple.html

-- 
Andy Hassall <andy@andyh.co.uk> / Space: disk usage analysis tool
<http://www.andyh.co.uk> / <http://www.andyhsoftware.co.uk/space>


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

Date: Sat, 07 Feb 2004 01:25:53 GMT
From: XXjbhuntxx@white-star.com (Cosmic Cruizer)
Subject: Re: Perl script into a Windows Service
Message-Id: <Xns9487B15264B13ccruizermydejacom@64.164.98.50>

Andy Hassall <andy@andyh.co.uk> wrote in <jec8205j9h5lt6pccf7aihusui37c5s3i2
@4ax.com>:

>http://theoryx5.uwinnipeg.ca/CPAN/data/Win32-Daemon-Simple/Simple.html

Thanks Andy and Chris.

The link listed above is pretty easy to follow. I will need to give it a try 
when I have a bit more time.

Since I finally needed to get something up and running for the weekend, I 
kind of cheated. I'm trying out Firedaemon. It took me all of 10 minutes to 
get my service up and running. But the real test will be on Monday when I 
check out the server.

Thanks for the suggestions.


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

Date: Sat, 07 Feb 2004 00:04:36 +0000
From: darren_uk <none@hotmail.com>
Subject: Re: Req.for Advice: Learning Perl
Message-Id: <jYVUb.549$vo1.424@newsfep4-winn.server.ntli.net>

Eric Bohlman wrote:

> darren_uk <none@hotmail.com> wrote in
> news:MDUUb.518$cb7.3935@newsfep4-glfd.server.ntli.net:
> 
>> I need to come up to speed with Perl quickly.
>> 
>> I own "Learning Perl" but find that I personally am better at looking
>> at simple (and not so simple) examples, and probably moving onto more
>> complex examples.
>> 
>> For example, browsing some of the "How2" postings in this newsgroup
>> and trying to understand the answers seems to steepen the learning
>> curve for me - possibly this is because I'm a problem solver by nature
>> and have 15 years of support experience so running through someone
>> else's code and figuring out what it does is just the way I work best.
> 
> Sounds like _The Perl Cookbook_ is just the thing for you.

:-D

As soon as you mentioned that book, I thought, "I'm sure I've got that
somewhere".  Sure enough, after much digging through archive boxes, I came
across a box with a bunch of computer books, including "Perl Cookbook" (and
found my "Perl5 Pocket Reference" too).


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

Date: 7 Feb 2004 00:36:54 GMT
From: Eric Bohlman <ebohlman@earthlink.net>
Subject: Re: Req.for Advice: Learning Perl
Message-Id: <Xns9487BDC47151Eebohlmanomsdevcom@130.133.1.17>

darren_uk <none@hotmail.com> wrote in
news:jYVUb.549$vo1.424@newsfep4-winn.server.ntli.net: 

> As soon as you mentioned that book, I thought, "I'm sure I've got that
> somewhere".  Sure enough, after much digging through archive boxes, I
> came across a box with a bunch of computer books, including "Perl
> Cookbook" (and found my "Perl5 Pocket Reference" too).

Keep in mind that there's a second edition which was published in the last 
year or so, and significantly expanded; the first edition is nearly 6 years 
old.  Nonetheless, the first edition should serve you well in the short-
term; just get the new one when you need to expand your horizons even 
further.


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

Date: Sat, 7 Feb 2004 08:03:29 +0000 (UTC)
From: dkcombs@panix.com (David Combs)
Subject: Re: SourceCode : perl OOPS by Conway:
Message-Id: <c0264h$t2$1@reader2.panix.com>

In article <pan.2004.01.11.19.20.14.740006@remove.adelphia.net>,
James Willmore  <jwillmore@adelphia.net> wrote:
>
>It's sad that once a book is written and published, the publisher retains
>more control than the author over the finished product. 

A couple of years ago he told me that they (Manning)
also had the rights to any *second* volume -- or in fact
to anything on the same subject (oop in perl) that he
might write, and that, however, they had decided,
he thought, *not* to publish such a book.

He said, back then, that he was legally blocked.

(I suggested he *ask* them to release him, but
he wasn't too optimistic about doing that.)

Which is way too bad, since even back then
he said that he had enough new material,
uncovered in the existing book, to fill an
entire second book (I think that's what he said.)

Does anyone have any news since then?

David




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

Date: Fri, 06 Feb 2004 19:19:10 -0700
From: Mark Shelor <mshelor@comcast.removeme.net>
Subject: Using "static" in Perl Extensions
Message-Id: <zvmdnanZnOy_1rndRVn-vw@comcast.com>

I've encountered a troublesome inconsistency in the Perl extension I've 
written for CPAN (Digest::SHA).  The problem involves the use of a 
static array within a performance-critical transform function.  When 
compiling under gcc on my big-endian PowerPC (Mac OS X), declaring this 
array as "static" DECREASES the transform throughput by around 5%. 
However, declaring it as "static" on gcc/Linux/Intel INCREASES the 
throughput by almost 30%.

I would prefer that the array not be "static" so that the underlying C 
function will be thread-safe.  However, giving up close to 30% 
performance on gcc/Linux/Intel is unacceptable for a digest routine, 
whose value is often closely tied to speed.

Can anyone enlighten me on this mystery, and recommend a simple, clean, 
portable way to assure good performance on all host types?

TIA, Mark



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

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


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