I'm trying to do this on a windows box:
find2perl . -exec "dir {} \;" | perl
which gives me (after spitting out the results of dir . ..):
Use of uninitialized value in chdir at - line 47.
Here is the output from find2perl:
#! 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 !$?; }
Line 47 is:
chdir $cwd; #sigh
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.

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


In reply to find2perl -exec on Windows by QM

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.