[25627] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7869 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Mar 9 09:05:51 2005

Date: Wed, 9 Mar 2005 06:05:23 -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           Wed, 9 Mar 2005     Volume: 10 Number: 7869

Today's topics:
        [perl-python] a program to delete duplicate files <xah@xahlee.org>
    Re: Advice for moving linux script to MacPerl <1usa@llenroc.ude.invalid>
    Re: cant display generated html in browser (perl script <nobull@mail.com>
    Re: FAQ 8.0 What does "bad interpreter" mean? <josef.moellers@fujitsu-siemens.com>
    Re: goto& destroying @_ - Problem finally replicated (Anno Siegel)
        Help needed to write a regular expression. (Vittal)
    Re: Help needed to write a regular expression. <1usa@llenroc.ude.invalid>
    Re: Help needed to write a regular expression. <someone@example.com>
        HTML::Parser - duplicated text in <h2> .. </h2> ? <geoff.cox@notquitecorrectfreeuk.com>
    Re: include external perl program alythh@netscape.net
    Re: include external perl program <tadmc@augustmail.com>
    Re: infinite loop (newbie) <1usa@llenroc.ude.invalid>
        p5 manager for whole file backups <eighner@io.com>
    Re: perlpod/perldoc Q: I want asterisk bullets <kalinaubears@iinet.net.au>
    Re: Praesideo: Latin for 'to watch over' <invinity@nvinity.net>
    Re: Praesideo: Latin for 'to watch over' <invinity@nvinity.net>
    Re: Q: Only put unique element in a HoL? (Magnus)
        Struggling to install HTML::Mason (mod_perl would be a  john_ramsden@sagitta-ps.com
        Win32::TieRegistry Logon User Name jairagoo@gmail.com
    Re: Win32::TieRegistry Logon User Name <nobull@mail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 9 Mar 2005 04:56:13 -0800
From: "Xah Lee" <xah@xahlee.org>
Subject: [perl-python] a program to delete duplicate files
Message-Id: <1110372973.657649.212920@l41g2000cwc.googlegroups.com>

here's a large exercise that uses what we built before.

suppose you have tens of thousands of files in various directories.
Some of these files are identical, but you don't know which ones are
identical with which. Write a program that prints out which file are
redundant copies.

Here's the spec.
--------------------------
The program is to be used on the command line. Its arguments are one or
more full paths of directories.

perl del_dup.pl dir1

prints the full paths of all files in dir1 that are duplicate.
(including files in sub-directories) More specifically, if file A has
duplicates, A's full path will be printed on a line, immediately
followed the full paths of all other files that is a copy of A. These
duplicates's full paths will be prefixed with "rm " string. A empty
line follows a group of duplicates.

Here's a sample output.

inPath/a.jpg
rm inPath/b.jpg
rm inPath/3/a.jpg
rm inPath/hh/eu.jpg

inPath/ou.jpg
rm inPath/23/a.jpg
rm inPath/hh33/eu.jpg

order does not matter. (i.e. which file will not be "rm " does not
matter.)

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

perl del_dup.pl dir1 dir2

will do the same as above, except that duplicates within dir1 or dir2
themselves not considered. That is, all files in dir1 are compared to
all files in dir2. (including subdirectories) And, only files in dir2
will have the "rm " prefix.

One way to understand this is to imagine lots of image files in both
dir. One is certain that there are no duplicates within each dir
themselves. (imagine that del_dup.pl has run on each already) Files in
dir1 has already been categorized into sub directories by human. So
that when there are duplicates among dir1 and dir2, one wants the
version in dir2 to be deleted, leaving the organization in dir1 intact.

perl del_dup.pl dir1 dir2 dir3 ...

does the same as above, except files in later dir will have "rm "
first. So, if there are these identical files:

dir2/a
dir2/b
dir4/c
dir4/d

the c and d will both have "rm " prefix for sure. (which one has "rm "
in dir2 does not matter) Note, although dir2 doesn't compare files
inside itself, but duplicates still may be implicitly found by indirect
comparison. i.e. a==c, b==c, therefore a==b, even though a and b are
never compared.


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

Write a Perl or Python version of the program.

a absolute requirement in this problem is to minimize the number of
comparison made between files. This is a part of the spec.

feel free to write it however you want. I'll post my version in a few
days.

http://www.xahlee.org/perl-python/python.html

 Xah
 xah@xahlee.org
 http://xahlee.org/PageTwo_dir/more.html



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

Date: Wed, 09 Mar 2005 06:53:48 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Advice for moving linux script to MacPerl
Message-Id: <Xns9614134B68E11asu1cornelledu@127.0.0.1>

ecurts@neo.rr.com wrote in news:1110334853.242722.30470
@o13g2000cwo.googlegroups.com:

> So here's my question... Is this what you have to do to get perl
> scripts to run on an OS9 server with AppleShare IP?

The language in which the scripts are written is irrelevant. This is a web 
server configuration question. As such, you would be more likely to get 
useful responses on an appropriate forum. For example,

comp.infosystems.www.servers.mac

seems like a good place to try.

Sinan.


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

Date: Wed, 09 Mar 2005 13:14:50 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: cant display generated html in browser (perl script)
Message-Id: <d0mshq$188$1@sun3.bham.ac.uk>



Piet L. wrote:

>>Anyhow this is not the 'right' way to use XSL on the web.  You should 
>>simply put a processing instruction in the XML to tell the browser where 
>>to fetch the XSLT.
> 
> How do I do that?

The processing instruction looks something like this:

   <?xml-stylesheet href="whatever.xsl" type="text/xsl"?>

How you put such a processing instruction into an XML document would 
depend on the tools you are using to generate the XML document.

For example using XML::DOM to create an XML document it would look 
something like this:

     my $stylesheet='whatever.xml';
     my $xmldoc = XML::DOM::Document->new;
     $xmldoc->setXMLDecl($xmldoc->createXMLDecl('1.0','UTF-8'));
     $xmldoc->appendChild
	    ( $xmldoc->createProcessingInstruction
	      ( 'xml-stylesheet',
		qq'href="$stylesheet" type="text/xsl"' ) );



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

Date: Wed, 09 Mar 2005 09:01:48 +0100
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: FAQ 8.0 What does "bad interpreter" mean?
Message-Id: <d0mak8$kpi$1@nntp.fujitsu-siemens.com>

PerlFAQ Server wrote:
> This message is one of several periodic postings to comp.lang.perl.misc=

> intended to make it easier for perl programmers to find answers to
> common questions. The core of this message represents an excerpt
> from the documentation provided with Perl.
>=20
> --------------------------------------------------------------------
>=20
> 8.0: What does "bad interpreter" mean?
>=20
>     The "bad interpreter" message comes from the shell, not perl. The a=
ctual
>     message may vary depending on your platform, shell, and locale sett=
ings.
>=20
>     If you see "bad interpreter - no such file or directory", the first=
 line
>     in your perl script (the "shebang" line) does not contain the right=
 path
>     to perl (or any other program capable of running scripts). Sometime=
s
>     this happens when you move the script from one machine to another a=
nd
>     each machine has a different path to perl---/usr/bin/perl versus
>     /usr/local/bin/perl for instance.

=2E.. or if the source machine has CRLF line terminators and the=20
destination machine has LF only: the system then tries to find=20
/usr/bin/perl<CR> and ... fails.
(Happens with other shebangs as well)

Josef, having seen this more than once
--=20
Josef M=F6llers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize
						-- T.  Pratchett



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

Date: 9 Mar 2005 12:06:46 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: goto& destroying @_ - Problem finally replicated
Message-Id: <d0mosm$i0v$1@mamenchi.zrz.TU-Berlin.DE>

Matthew Braid  <not@invalid.invalid> wrote in comp.lang.perl.misc:
> Hi all,
> 
> I previously posted a problem I was having with using chained goto's 
> (message ID <d08qqe$172u$1@bunyip2.cc.uq.edu.au>) and getting segfaults. 
> I'm reposting because I've _finally_ managed to reproduce the segfault.
> 
> To recap: I'm using a plugin system that basically works by having 
> packages dynamically loaded that either replace or update functions 
> inside standard (to the system) library packages. A custom import 
> function for these library packages ensures that once an extension is 
> loaded the changes it makes are noticed even inside packages that 
> imported the library functions _before_ the extension was loaded. See 
> the 'import' function of the Core.pm package below for info there.
> 
> In order to make sure the call stack could support 'infinite' 
> extensions, I was using goto& where possible for extensions that add 
> some functionality but still result in the core function being called, eg:

[demo code snipped]

> Now, once all the packages are in place if you run:
> 
> 	$ perl test.pl ExtX
> 	Subroutine Core::action redefined at ExtX.pm line 18.
> 	EXTX: GOT HASH KEYS 'That', 'TheOther', 'This'
> 	EXTX: NEW HASH BUILT - KEYS 'New', 'That', 'This', 'TheOther'
> 	Core: GOT HASH OF KEYS 'New', 'That', 'This', 'TheOther'
> 
> All well and good - the goto worked, and it handled the @_ = ($fake) 
> well. Now we try the more complex version - Ext3:
> 
> 	$ perl test.pl Ext3
> 	Subroutine Core::action redefined at Ext1.pm line 15.
> 	Subroutine Core::action redefined at Ext2.pm line 8.
> 	Subroutine Core::action redefined at Ext3.pm line 8.
> 	Ext3: GOT HASH KEYS 'That', 'TheOther', 'This'
> 	Ext3: NEW HASH BUILT - KEYS 'New', 'That', 'TheOther', 'This'
> 	Ext2: GOT HASH KEYS 'New', 'That', 'This', 'TheOther
> 	Segmentation fault (core dumped)
> 
> Ouch. Oddly enough this is not _quite_ what I was seeing in the full 
> code (@_ for Ext2 was full of some kind of faulty undef values), but it 
> has the same effect.

I can't reproduce this (Perl 5.8.1, Linux 2.0.36).  I get

    [anno4000@lublin Braid]$ perl test.pl Ext3
    Subroutine Core::action redefined at Ext1.pm line 15.
    Subroutine Core::action redefined at Ext2.pm line 8.
    Subroutine Core::action redefined at Ext3.pm line 8.
    Ext3: GOT HASH KEYS 'This', 'TheOther', 'That'
    Ext3: NEW HASH BUILT - KEYS 'This', 'TheOther', 'New', 'That'
    Ext2: GOT HASH KEYS 'This', 'TheOther', 'New', 'That
    EXT1: GOT HASH KEYS 'This', 'TheOther', 'New', 'That'
    Core: GOT HASH OF KEYS 'This', 'TheOther', 'New', 'That'

which, I suppose, is what it should be.

[snip more diagnostics]

> So it seems there is someting wrong with goto that involves depth of 
> chained goto's (ExtX working while Ext3 not suggests this) and assigning 
> to @_.
>
> Phew. Now I have to return to work. Hopefully this is enough info for 
> someone to work out the underlying problem :)

That's unlikely to happen on clpm.  You should probably send a bug report
through perlbug.

Anno


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

Date: 8 Mar 2005 21:53:19 -0800
From: vsnadagouda@yahoo.com (Vittal)
Subject: Help needed to write a regular expression.
Message-Id: <f9dcc290.0503082153.16db80a5@posting.google.com>

Hello All,

I am writing a simple perl script to scan C/C++ Makefiles and list all
the macros used in those Makefiles. For this I am using the below
mentioned regular expression. The problem with this RE is that it does
not show the complete macro definition. It cuts it short at new line
character. As per makefile rules, if a line ends with "/" means it
continues on to next line also. I want to add this portion into my RE
so that I can catch the whole macro definition.

Can someone help in this?

Thanks
-Vittal

open INFILE, $FILE || die "Failed to open $FILE file \n";
        while (<INFILE>)
        {
                # Exclude all the lines starting with # in the
makefile
                $temp .=$_ if (!/^#/); 
        }

                $str_macro .= "\n$FILE\n\n";
        while ($temp && $temp =~ /(\w+)\s*=(\t| )*([^\n]+)/ )
        {
                 print "\t$&\n";                  
                $temp = $';
        }


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

Date: Wed, 09 Mar 2005 06:23:28 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Help needed to write a regular expression.
Message-Id: <Xns9614E275F7BCasu1cornelledu@127.0.0.1>

vsnadagouda@yahoo.com (Vittal) wrote in 
news:f9dcc290.0503082153.16db80a5@posting.google.com:

> I am writing a simple perl script to scan C/C++ Makefiles and list all
> the macros used in those Makefiles. 

Do you mean macros used or defined? If you really do mean 'used' then 
the task is pretty complicated. 

There must be a specification somewhere of the exact grammar of a macro 
definition in makefiles. Of course, this depends on whose make you are 
using. You did not specify this either.

So, there is precious little information to go on. You would get better 
help if you helped others help you.

> mentioned regular expression. The problem with this RE is that it does
> not show the complete macro definition. It cuts it short at new line
> character. As per makefile rules, if a line ends with "/" means it
> continues on to next line also. 

Why don't you check for that then?

 ...

> open INFILE, $FILE || die "Failed to open $FILE file \n";

1. If you want to drop the parantheses in the call to open, you should 
use 'or' rather than '||'. 

D:\Home> cat f.pl
use strict;
use warnings;

open my $f, '<', $ARGV[0] || die $!;
print <$f>;

D:\Home> f non-existent-file
readline() on closed filehandle $f at D:\Home\f.pl line 5.

2. You might want to figure out why open failed if open failed.

D:\Home> cat f.pl
use strict;
use warnings;

open my $f, '<', $ARGV[0] or die "Cannot open $ARGV[0]: $!";
print <$f>;

D:\Home> f non-existent-file
Cannot open non-existent-file: No such file or directory at D:\Home\f.pl 
line 4.

Of course, the script you posted is useless as there is no way for us to 
run it without jumping through a whole bunch of loops.

>         while (<INFILE>)
>         {
>                 # Exclude all the lines starting with # in the
> makefile
>                 $temp .=$_ if (!/^#/); 
>         }

Why partially slurp the file?

> 
>                 $str_macro .= "\n$FILE\n\n";
>         while ($temp && $temp =~ /(\w+)\s*=(\t| )*([^\n]+)/ )
>         {
>                  print "\t$&\n";                  
>                 $temp = $';
>         }

You lost me.

Sinan.


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

Date: Wed, 09 Mar 2005 10:56:33 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Help needed to write a regular expression.
Message-Id: <BDAXd.23079$fc4.20716@edtnps89>

Vittal wrote:
> 
> I am writing a simple perl script to scan C/C++ Makefiles and list all
> the macros used in those Makefiles. For this I am using the below
> mentioned regular expression. The problem with this RE is that it does
> not show the complete macro definition. It cuts it short at new line
> character. As per makefile rules, if a line ends with "/" means it

Don't you mean if a line ends with '\'?  That is what the Makefiles on my 
system use.


> continues on to next line also. I want to add this portion into my RE
> so that I can catch the whole macro definition.
> 
> Can someone help in this?
> 
> Thanks
> -Vittal
> 
> open INFILE, $FILE || die "Failed to open $FILE file \n";

You have a precedence error.  As long as $FILE does not contain '' or '0' then 
the error message will never be printed.  You need to either use parentheses 
for the open() function or use the lower precedence 'or' operator.  You should 
also include the $! variable in the error message so you will know why it failed.

open INFILE, $FILE or die "Failed to open $FILE file: $!";


>         while (<INFILE>)
>         {
>                 # Exclude all the lines starting with # in the
> makefile
>                 $temp .=$_ if (!/^#/); 
>         }
> 
>                 $str_macro .= "\n$FILE\n\n";
>         while ($temp && $temp =~ /(\w+)\s*=(\t| )*([^\n]+)/ )
>         {
>                  print "\t$&\n";                  
>                 $temp = $';
>         }

my %macros;
while ( <INFILE> ) {

     if ( s/\\\n// ) {
         $_ .= <INFILE>;
         redo;
         }

     if ( /(\w+)\s*=[\t ]*(.+)/ ) {
         $macros{ $1 } = $2;
         }
     }

for my $key ( keys %macros ) {
     print "$key = $macros{$key}\n";
     }




John
-- 
use Perl;
program
fulfillment


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

Date: Wed, 09 Mar 2005 10:44:58 GMT
From: Geoff Cox <geoff.cox@notquitecorrectfreeuk.com>
Subject: HTML::Parser - duplicated text in <h2> .. </h2> ?
Message-Id: <dskt21dctr357ir4khjpoj61p1rb46jvji@4ax.com>

Hello

I am trying to get back into using HTML::Parser after a year's gap! 

In one html file I am getting a few instances of 

<h2>headingheading</h2>

ie the heading text is repeated.

Other <h2> headings in this same file are OK.

Any idea where I should start to look for the solution?!

Thanks

Geoff


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

Date: 9 Mar 2005 02:35:28 -0800
From: alythh@netscape.net
Subject: Re: include external perl program
Message-Id: <1110364528.254646.197180@g14g2000cwa.googlegroups.com>

thank you all people,

<I always find the Perl community the most helpful and friendly around
the web, it must be something in the language itself?>

I found the do $cfgfile the easiest and most straightforward - I didnt
know this form of do, and had some problems at first since I used 'my'
instead of 'our' - I still have some problems on scoping...

thank you all!

Alessandro



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

Date: Wed, 9 Mar 2005 06:45:23 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: include external perl program
Message-Id: <slrnd2trv3.ab5.tadmc@magna.augustmail.com>

alythh@netscape.net <alythh@netscape.net> wrote:

> I still have some problems on scoping...


Then see:

   "Coping with Scoping":

      http://perl.plover.com/FAQs/Namespaces.html


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


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

Date: Wed, 09 Mar 2005 05:57:19 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: infinite loop (newbie)
Message-Id: <Xns96149B8C1CB2asu1cornelledu@127.0.0.1>

"usaims" <usaims@yahoo.com> wrote in news:1110322079.482791.241100
@z14g2000cwz.googlegroups.com:

> I'm new to Perl.

Nothing wrong with that.

> Learning hashes will be my next objective, 

Nice of you to share that with us.

> sorry for the posts and thanks in advance.

You can show your appreciation for the help given here by reading and 
adhering to the posting guidelines for this group.

Sinan.


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

Date: Wed, 09 Mar 2005 07:39:05 -0600
From: Lars Eighner <eighner@io.com>
Subject: p5 manager for whole file backups
Message-Id: <slrnd2tusj.30ce.eighner@goodwill.io.com>

Is there a module to manage whole-file backups in some sort
of sane manner?

I have in mind something I could sent a filespec and have
a backup file with a unique name made, with old and/or supernumerary
backups pruned, or have the filespec for the most recent backup
returned, etc.  I'd just as soon not re-invent the wheel.


-- 
Lars Eighner              eighner@io.com           http://www.io.com/~eighner/
     "I have never made but one prayer to God, a very short one: 'O Lord,
        make my enemies ridiculous.' And God granted it."  --Voltaire


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

Date: Wed, 09 Mar 2005 04:30:18 +0000
From: Sisyphus <kalinaubears@iinet.net.au>
Subject: Re: perlpod/perldoc Q: I want asterisk bullets
Message-Id: <422e8b75$0$31484$5a62ac22@per-qv1-newsreader-01.iinet.net.au>

J Krugman wrote:
> OK, here's an example that exhibits some annoying behavior:
> 
> =over
> 
> =item *
> 
> whatever:
> 
> =over
> 
> =item *
> 
> first item
> 
> =item *
> 
> second item
> 
> =item *
> 
> etc., etc.
> 
> =back
> 
> =back
> 
> 
> 
> It looks like this when displayed using perl/perldoc v5.8.4:
> 
> 
> 
> TEST(1)        User Contributed Perl Documentation        TEST(1)
> 
> 
> 
>        o   whatever:
> 
>            o   first item
> 
>            o   second item
> 
>            o   etc., etc.
> 
> 
> 
> perl v5.8.4                 2005-03-08                    TEST(1)
> 

Try calling perldoc with the -t switch (calls pod2text). Fixes it for me 
- though I don't know how that relates to what you're doing.

My guess is that when you call these other pod files, you're using 
pod2text (somehow), and when you call your own pod file you're not using 
pod2text (somehow).

Cheers,
Rob

Cheers,
Rob


-- 
To reply by email u have to take out the u in kalinaubears.



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

Date: 9 Mar 2005 04:23:43 -0800
From: "invinity" <invinity@nvinity.net>
Subject: Re: Praesideo: Latin for 'to watch over'
Message-Id: <1110371023.435623.9050@l41g2000cwc.googlegroups.com>

John,

Thanks a bunch for the input.

I was under the impression that modules in the "Apache::" namespace
were deemed to be packages for mod_perl (i.e. Apache::RequestRec). Is
this not the case?

Matt



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

Date: 9 Mar 2005 04:40:03 -0800
From: "invinity" <invinity@nvinity.net>
Subject: Re: Praesideo: Latin for 'to watch over'
Message-Id: <1110372003.304902.53170@z14g2000cwz.googlegroups.com>

Tad McClellan wrote:
> What that is that that?
>
> It is customary to quote some context when composing a followup.

Thanks Tad. I'm not yet experienced with posting, but I will learn.



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

Date: 9 Mar 2005 04:53:35 -0800
From: mpe17@kth.se (Magnus)
Subject: Re: Q: Only put unique element in a HoL?
Message-Id: <74dd24f9.0503090453.5392366a@posting.google.com>

Thanks!

A HoH solved my problem. It's great to get help from you guys.

Regards,
Magnus


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

Date: 9 Mar 2005 05:31:19 -0800
From: john_ramsden@sagitta-ps.com
Subject: Struggling to install HTML::Mason (mod_perl would be a good start!)
Message-Id: <1110375079.386103.273640@g14g2000cwa.googlegroups.com>


I am trying to install HTML::Mason, for use with Apache 2.0.48
mod_perl v2. on Windows (using ActiveState perl v5.8.4) and wondered if
anyone had encountered the same problems with a similar combination.

When I try running apache.exe manually, it aborts with the following
error (lines wrapped for readability):

 Can't locate HTML/Mason/ApacheHandler.pm in @INC
 (@INC contains: C:\Program Files\ActiveState
          Perl Dev Kit 6.0\lib\
  . C:/Program Files/Apache Group/Apache2) at (eval 2) line 3.

I then try running perl manually, to see if this module is installed:

  perl -MHTML::Mason::ApacheHandler -e 1

which results in the following error message:

  Can't locate Apache/Constants.pm in @INC
 (@INC contains: C:\Program Files\ActiveState
         Perl Dev Kit 6.0\lib\
  C:/Perl/lib
  C:/Perl/site/lib .)
 at C:/Perl/site/lib/HTML/Mason/ApacheHandler.pm line 13.

So it appears the ApacheHandler.pm module is installed but references
another module, Apache::Constants.pm.

However, I can't for the life of me find this blasted
Apache::Constants.pm module, not via ppm or even a Google
search.

Any ideas?

I did see a note on one web page to the effect that something
in Mason or mod_perl didn't like spaces in file names (despite this
being the 2000s not the 1970s).

To rule out that possibility I'd be happy to change all the
file names in @INC paths to use the DOS 8.3 compatibility
ones, such as Progra~1 instead of 'Program Files'. Does
anyone know where to access the predefined @INC path list
for this purpose?



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

Date: 8 Mar 2005 23:56:39 -0800
From: jairagoo@gmail.com
Subject: Win32::TieRegistry Logon User Name
Message-Id: <1110354999.139379.310390@o13g2000cwo.googlegroups.com>

Hail All,
  I am trying to write a script that looks at all my windows computers
within  a subnet and return the "Computer Name and Logon on users". My
attempt below returns the computername appropriately but it doesn't
return the "Logon User Name". I physically look at the registry and see
the user's name there but this script does not return that value.
Someone please help ;-)

######OUTPUT########
10.2.4.29=> => COMPUTER5
10.2.4.30=> => COMPUTER0
10.2.4.31=> => COMPUTER6
10.2.4.32=> => COMPUTER9
10.2.4.33=> => COMPUTER4
10.2.4.35=> => COMPUTER2
#####################

#!c:\perl\bin\perl
use Win32::TieRegistry;

my @subnet =qw(4);
foreach $subnet (@subnet) {
  for (my $i=1;$i <100;$i++){
   $computer = qq(10.2.$subnet.$i);
   $pinger=`ping -n 1 $computer`;
   if($pinger=~ /Reply from/) {

$username=$Registry->{"\\\\$computer\\CUser\\Software\\Microsoft\\"
          ."Windows\\CurrentVersion\\Explorer\\\\Logon User Name"};
        $computerName=$Registry->{"\\\\$computer\\LMachine\\SYSTEM\\"
          ."CurrentControlSet\\Control\\ComputerName\\ComputerName\\\\"
          ."ComputerName"};
       print "$computer=> $username=> $computerName\n";
   }
 }
}

thank you.
Darth



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

Date: Wed, 09 Mar 2005 13:31:44 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Win32::TieRegistry Logon User Name
Message-Id: <d0mthe$1pp$1@sun3.bham.ac.uk>

jairagoo@gmail.com wrote:

>   I am trying to write a script that looks at all my windows computers
> within  a subnet and return the "Computer Name and Logon on users". My
> attempt below returns the computername appropriately but it doesn't
> return the "Logon User Name". I physically look at the registry and see
> the user's name there but this script does not return that value.

The 'CUser' top level registry key is a link to the user profile 
registry hive of the user that is looking at the registry.

AFAIK it can only be used for interrogating the local registry.  Even if 
it could be used on remote registries it would show you the content of 
_your_ user profile registry hive on that box, not the registry hive of 
the user sitting at the screen/keyboard.

You can traverse the 'HKEY_USERS' section of the registry to find out 
all the users who currently have profiles loaded but I do not know how 
to tell which (if any) have true interactive desktops.

Your problem has very little to do with Perl, if you need futher help I 
suggest you try a newsgroup that deals with the Windows operating system.




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

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


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