Got it, with a little help from Bill... he sent me a script that used File::find but 
it didn't like UNC paths, so I used it to fix my syntax...

this is the fixed script:

#####################################################################
#####################################################################

$server = "servername";
$drive = "C";

@dirs = `dir /A:D /B /-C /O:N /S \\\\$server\\$drive\$`;

foreach $dir ( @dirs )
        {
        ### use dir to get the directories and then split it up
        $dir =~ s/\\\\$server\\$drive\$\\//;
        @dirParts = split( /\\/, $dir );

        ### set up the strings for an eval statement
        $evalString = '$root->';
        $evalStringValue = ' = "\\\\\\\\'.$server.'\\\\'.$drive.'\\$';
        $i = 0;
        while ( $dirParts[$i] ne "" )
                {
                chomp  $dirParts[$i];
                ### use 'q' to include spaces, quotes, etc...
                $evalString .= '{q{'.$dirParts[$i].'}}';
                $evalStringValue .= '\\\\'.$dirParts[$i];
                $i++;
                }
        $evalString .= '{q{var_Path}}';
        $evalStringValue .= '";';

        print "Eval: ".$evalString.$evalStringValue."\n";
        eval $evalString.$evalStringValue;
        warn() if $@;
        }

### all now print as expected!
print 'test1 is '.$root->{workstn}->{log}->{apps}->{var_Path}." \n";
print 'test2 is '.$root->{workstn}{log}{apps}{var_Path}." \n";
print 'test3 is '.$root->{WINNT}{q{Temporary Internet Files}}{Cache1}{var_Path}." \n";
print 'test4 is '.$root->{WINNT}{q(Temporary Internet Files)}{Cache1}{var_Path}." \n";

#####################################################################
#####################################################################

-----Original Message-----
From: Hornyak, Douglas 
Sent: Wednesday, June 05, 2002 8:26 AM
To: [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Subject: RE: File System Hierarchy


$object would contain a permissions object (probably Win32::Perms) or more likely 
another has reference like so:

$root->{C}->{winnt}->{system}->{ACL} = $object;
$root->{C}->{winnt}->{system}->{path} = "\\server\c$\WINNT\SYSTEM";
$root->{C}->{winnt}->{system}->{time} = time();
$root->{C}->{winnt}->{system}->{size} = 11890;

I was messing around with using the eval statement, as I have made good use of it in 
the past in Javascript, but it isn't doing what I had hoped. I must be 
misunderstanding something...

#####################################################################
#####################################################################

$server = "servername";
$drive = "C";

@dirs = `dir /A:D /B /-C /O:N /S \\\\$server\\$drive\$`;

foreach $dir ( @dirs )
        {
        ### use dir to get the directories and then split it up
        $dir =~ s/\\\\$server\\$drive\$\\//;
        @dirParts = split( /\\/, $dir );

        ### set up the strings for an eval statement
        $evalString = '$root';
        $evalStringValue = ' "\\\\'.$server.'\\'.$drive.'$';

        ### loop through the directory aplit line array
        $i = 0;
        while ( $dirParts[$i] ne "" )
                {
                chomp  $dirParts[$i];

                ### add the hash reference to the eval string
                $evalString .= '->{'.$dirParts[$i].'}';

                ### add the directory to the eval value
                $evalStringValue .= '\\'.$dirParts[$i];
                $i++;
                }
        ### finish up the eval strings
        $evalString .= '->{var_Path} = ';
        $evalStringValue .= '"';

        ### this prints the command I wish to run
        print $evalString.$evalStringValue."\n";
        eval { $evalString.$evalStringValue  };
        }

### this tests whether or not the eval statement created the hash tree
### p.s. it didn't
print 'test is '.$root->{WINNT}->{System32}->{Logfiles}->{var_Path}." \n";

#####################################################################
#####################################################################

-----Original Message-----
From: $Bill Luebkert [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, June 04, 2002 5:28 PM
To: Hornyak, Douglas
Cc: [EMAIL PROTECTED]
Subject: Re: File System Hierarchy


[EMAIL PROTECTED] wrote:

> Does anyone have a descent way to convert a file hierarchy into a hierarchy of hash 
>references? I'd like to get the following:
> These folders:
> 
> C:\winnt
> C:\winnt\system32
> C:\winnt\system
> C:\winnt\system32\logfiles
> 
> become this:
> 
> %root= {};
> $root= \%root;
> 
> $root->{C} = $object;
> $root->{C}->{winnt} = $object;
> $root->{C}->{winnt}->{system} = $object;
> $root->{C}->{winnt}->{system32} = $object;
> $root->{C}->{winnt}->{system32}->{logfiles} = $object;
> 
> Does that make sense? Or does someone have a different way?


Depends, what does $object contain ?


How will you treat files and links vs dirs in the hash ?


-- 
   ,-/-  __      _  _         $Bill Luebkert   ICQ=14439852
  (_/   /  )    // //       DBE Collectibles   Mailto:[EMAIL PROTECTED]
   / ) /--<  o // //      http://dbecoll.tripod.com/ (Free site for Perl)
-/-' /___/_<_</_</_     Castle of Medieval Myth & Magic http://www.todbe.com/


Visit our website at http://www.ubswarburg.com

This message contains confidential information and is intended only 
for the individual named.  If you are not the named addressee you 
should not disseminate, distribute or copy this e-mail.  Please 
notify the sender immediately by e-mail if you have received this 
e-mail by mistake and delete this e-mail from your system.

E-mail transmission cannot be guaranteed to be secure or error-free 
as information could be intercepted, corrupted, lost, destroyed, 
arrive late or incomplete, or contain viruses.  The sender therefore 
does not accept liability for any errors or omissions in the contents 
of this message which arise as a result of e-mail transmission.  If 
verification is required please request a hard-copy version.  This 
message is provided for informational purposes and should not be 
construed as a solicitation or offer to buy or sell any securities or 
related financial instruments.

_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Visit our website at http://www.ubswarburg.com

This message contains confidential information and is intended only
for the individual named.  If you are not the named addressee you
should not disseminate, distribute or copy this e-mail.  Please
notify the sender immediately by e-mail if you have received this
e-mail by mistake and delete this e-mail from your system.

E-mail transmission cannot be guaranteed to be secure or error-free
as information could be intercepted, corrupted, lost, destroyed,
arrive late or incomplete, or contain viruses.  The sender therefore
does not accept liability for any errors or omissions in the contents
of this message which arise as a result of e-mail transmission.  If
verification is required please request a hard-copy version.  This
message is provided for informational purposes and should not be
construed as a solicitation or offer to buy or sell any securities or
related financial instruments.

_______________________________________________
Perl-Win32-Admin mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to