gang,

If I'm tackling too much for a beginner, I realize you're not in the
business of doing someone else's work.  Here goes:  I'm attempting to use
find2perl using Binary build 522 provided by ActiveState Tool Corp.
http://www.ActiveState.com  Built 09:52:28 Nov  2 1999

problem/task:
# print the file names on an NT/IIS box in the d:/inetpub/wwwroot/ 
# dir structure that meet these criteria:
# modified more than 270 days ago (~ roughly 9 mos.)
# named 'default.html?' , 'index.html?' or 'welcome.html?'
# that exist in the top level subdirs only
# i.e.  d:/inetpub/wwwroot/site/default.htm would print, but not
# d:/inetpub/wwwroot/site/subdir/index.htm would not


steps taken:
I can use this command in Cygwin (bash):
$ find . -mtime +270 \( -name "default.htm" -o -name "index.htm" -o -name
"welcome.htm" \) -maxdepth 2 -print  # note: I didn't try to tackle the
regex issue in bash, e.g. htm v. html

...which outputs this:

./site1/default.htm
./site2/default.htm
./site3/default.htm
./site4/index.htm

Perhaps I should stop here!  I gave 'find2perl' the 'find' command and it
objected to some \'s (cygwin shell v. cmd shell issue) and it objected to
the '-maxdepth' argument.  OK, things get weaker here b/c I attempted to sub
'prune' for '-maxdepth' and I'm not dead certain how 'prune' works. Here's
what I gave find2perl and what it returned:

C:\WINNT\Profiles\rob\Desktop\perl>find2perl find . -mtime +270 ( -name
"default.htm" -o -name
"index.htm" -o -name "welcome.htm" ) -prune -print

--------------perl code returned (with some comments)--------------
#!perl     # will need full path
    eval 'exec P:AppsActivePerl eminMSWin32-x86-objectperl.exe -S $0
${1+"$@"}'
        if $running_under_some_shell;
        # should the line above stay or go?

require "find.pl";
        # is that perl 4 style, ie., equivalent to use File::Find; ?

# Traverse desired filesystems


&find('find','.');
        # I'm thinking of using either  my $dir = shift ( );  or hardcoding
in?
exit;
sub wanted {
    (($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_)) &&
    (int(-M _) > 270) &&
    (
        /^default\.htm$/  
        ||
        /^index\.htm$/
        ||
        /^welcome\.htm$/
    ) &&
    ($prune = 1) &&    #  don't know exactly how prune will work?
finddepth?
    print("$name\n");
}
----------------------------------

I know adjustments are needed, perhaps major ones. find2perl introduces a
lot of functions that I've yet to use extensively.  On a minor note, I'm not
sure whether using chdir ( 'c:/my/path' ) or my $dir = shift; is considered
better practice?  My current version reads:

------------ start -------------

#!c:/perl/bin/perl -w
use strict;
use File::Find;

my $dir = shift;
eval 'exec P:AppsActivePerl eminMSWin32-x86-objectperl.exe -S $0 ${1+"$@"}'
  if my $running_under_some_shell;

# require "find.pl";
# Traverse desired filesystems

&find( 'find', '$dir' );

exit;

sub wanted {
    ( ( my $dev, my $ino, my $mode, my $nlink, my $uid,  my $gid ) =
lstat($_) )
      && ( int( -M _ ) > 270 )
      && ( /^default\.html?$/ || /^index\.html?$/ || /^welcome\.html?$/ )
      # does the regex say 'match the preceding 'l' 0 or 1 times
      && ( my $prune = 1 ) && print("my $name\n");
}

------------ end --------------

error is:
C:\WINNT\Profiles\rob\Desktop\perl>file_find_wwwroot.pl r:\inetpub\wwwroot\
Global symbol "$name" requires explicit package name at
C:\WINNT\Profiles\rem27920\Desktop\perl\file
_find_wwwroot.pl line 21.
Execution of C:\WINNT\Profiles\rob\Desktop\perl\file_find_wwwroot.pl aborted
due to compilation
 errors.

That error and the syntax highlighting leads me to believe there's a problem
with print(" my $name\n").  I was able to eliminate several other variable
errors by inserting 'my'.

Can you assist with other problems you see? ..or would you approach the
problem differently?
I greatly appreciate the help provided in the past week or so.

Rob
--
Rob McCormick
GlaxoSmithKline
[EMAIL PROTECTED]



Reply via email to