QM has asked for the wisdom of the Perl Monks concerning the following question:
which gives me (after spitting out the results of dir . ..):find2perl . -exec "dir {} \;" | perl
Here is the output from find2perl:Use of uninitialized value in chdir at - line 47.
#! C:\Perl\bin\perl.exe -w eval 'exec C:\Perl\bin\perl.exe -S $0 ${1+"$@"}' if 0; #$running_under_some_shell use strict; use File::Find (); # Set the variable $File::Find::dont_use_nlink if you're using AFS, # since AFS cheats. # for the convenience of &wanted calls, including -eval statements: use vars qw/*name *dir *prune/; *name = *File::Find::name; *dir = *File::Find::dir; *prune = *File::Find::prune; sub wanted; sub doexec ($@); # Traverse desired filesystems File::Find::find({wanted => \&wanted}, '.'); exit; sub wanted { doexec(0, 'dir {} \;'); } use Cwd (); my $cwd = Cwd::cwd(); sub doexec ($@) { my $ok = shift; my @command = @_; # copy so we don't try to s/// aliases to consta +nts for my $word (@command) { $word =~ s#{}#$name#g } if ($ok) { my $old = select(STDOUT); $| = 1; print "@command"; select($old); return 0 unless <STDIN> =~ /^y/; } chdir $cwd; #sigh system @command; chdir $File::Find::dir; return !$?; }
Now I may have missed some portability issues, but it seems to me that $cwd never gets set, because its assignment happens at line 33, while execution of "main" ends at the exit at line 24. I've checked this in the debugger by trying a breakpoint at line 33, to no avail.chdir $cwd; #sigh
Am I off base, or is this broken?
How would I fix this without editing the find2perl output directly?
Is there a real Windows version of find2perl?
Meanwhile, I'm wondering why find2perl.bat comes with the AS install if I can't do things like:
find2perl . -ls # getpwent, etc. not ported find2perl . -exec ... # $cwd not initialized
-QM
--
Quantum Mechanics: The dreams stuff is made of
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: find2perl -exec on Windows
by sandfly (Beadle) on Feb 11, 2005 at 22:57 UTC | |
by QM (Parson) on Feb 12, 2005 at 00:21 UTC |