I used this code. and got the error Substitution replacement not terminated at filefind_pm1.pl line 16. I changed the code to
#!/usr/local/bin/perl -w # force taint checks, and print warnings use strict; use File::Find; my $Start_dir = shift; die ">$Start_dir< is not a directory\n" if ! -d $Start_dir; find(\&process, $Start_dir); sub process { return if -d $File::Find::name; return if -f $File::Find::name; # This is success - the file exist print ">$File::Find::name< is not a file or was not found\n"; }

this gave the error for every file in the directory.

>testdir/nitcnitc Folder/nitcnitc/0wireless.html< is not a file or was not found

It looks like the -f and the -d flags are not working.

I'm using osx I maybe i should be using mac:perl. I thought this was just for people using classic but it looks like im wrong.

Acually running returns the expected results

#!/usr/local/bin/perl -w # force taint checks, and print warnings use strict; use File::Find; my $Start_dir = shift; die ">$Start_dir< is not a directory\n" if ! -d $Start_dir; find(\&process, $Start_dir); sub process { return if -e $Start_dir # return if -f $File::Find::name; # This is success - the file ex +ist # return if -e $File::Find::name; print ">$File::Find::name < is not a file or was not found\n"; }

It looks like $File::Find::name cannot be used as a value for a file test.

If i save the strings returned from £file::find::name, to an array then work through the array then filetests seem to work. Why is this

#!/usr/local/bin/perl -w # force taint checks, and print warnings use strict; use File::Find; my $Start_dir = shift; my @found =(); die ">$Start_dir< is not a directory\n" if ! -d $Start_dir; find(\&process, $Start_dir); sub process { push(@found, $File::Find::name) } foreach (@found){ if (-d $_ ) { print "This is success - the directory $_ exist\n"}; if ( -f $_) { print "This is success - the file $_ exist\n"}; }

In reply to Re^2: Why doesnt the string returned by $File::Find::name find point to files by richill
in thread Why doesnt the string returned by $File::Find::name find point to files by richill

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.