Loading ...
Sorry, an error occurred while loading the content.
 

RE: [PBML] Find::File

Expand Messages
  • Fish, David
    Thanks Shlomi! It worked pefectly. Go Fish!!!! David Fish Senior Systems Analyst Property Systems Services Work (301) 380-3331 Fax (301) 644-7521 BlackBerry
    Message 1 of 4 , Jan 10, 2011
      Thanks Shlomi! It worked pefectly.

      Go Fish!!!!


      David Fish
      Senior Systems Analyst
      Property Systems Services
      Work (301) 380-3331
      Fax (301) 644-7521
      BlackBerry (301) 646-8985
      david.fish@...

      This communication contains information from Marriott International,
      Inc. that may be confidential. Except for personal use by the intended
      recipient, or as expressly authorized by the sender, any person who
      receives this information is prohibited from disclosing, copying,
      distributing, and/or using it. If you have received this communication
      in error, please immediately delete it and all copies, and promptly
      notify the sender. Nothing in this communication is intended to operate
      as an electronic signature under applicable law.



      -----Original Message-----
      From: perl-beginner@yahoogroups.com
      [mailto:perl-beginner@yahoogroups.com] On Behalf Of Shlomi Fish
      Sent: Friday, January 07, 2011 11:43 PM
      To: perl-beginner@yahoogroups.com
      Subject: Re: [PBML] Find::File

      Hi David,

      Hmmm... another guy called Fish here - see below for my response.

      On Saturday 08 Jan 2011 00:28:20 Fish, David wrote:
      > Hello! I am trying to delete all the files and folders under a
      > specified folder, without deleting the specified folder. The problem
      I
      > am having is the Fill::Find::dir is stuck on the $dir and not showing
      > the full path of the subdirectory. According the Perl documentation
      I
      > should set no_chdir => 1 but when I do I see no difference. Is there
      > something I am missing or would rmtree under File::Path be a better
      > option?

      File::Path's rmtree would certainly be a better option. Use it something
      like
      that:

      {{{
      use strict;
      use warnings;

      use File::Path qw(rmtree);

      my $dir = 'c:/downloads';

      rmtree($dir, { keep_root => 1 }); # Not sure when keep_root was
      introduced.
      }}}

      A few comments on your code:

      > use File::Find;
      >

      Add strict and warnings.

      > $dir = "c:/downloads";

      Declare the variable using "my";
      > find(\&wanted, no_chdir => 1, $dir);
      > print STDOUT ">$dir<\n";

      The STDOUT is uneeded here..


      > sub wanted {
      > $file = $_ ;

      Do my $file = $_;

      > if (-f $file) {
      > print STDOUT "This is a file: $file \n";
      > print STDOUT "Fullfilename:$File::Find::name \n";
      >
      > }
      > if (-d $file) {
      > print "This is a directory:>$file< \n";
      > print STDOUT "Fulldirname:>$File::Find::dir< \n";
      > }
      >
      > }
      >
      > Thanks,
      > David Fish
      >

      For more about best practices, see:

      http://perl-begin.org/tutorials/bad-elements/

      Regards,

      Shlomi Fish

      --
      -----------------------------------------------------------------
      Shlomi Fish http://www.shlomifish.org/
      Best Introductory Programming Language - http://shlom.in/intro-lang

      Chuck Norris can make the statement "This statement is false" a true
      one.

      Please reply to list if it's a mailing list post - http://shlom.in/reply
      .


      ------------------------------------

      Unsubscribing info is here:
      http://help.yahoo.com/help/us/groups/groups-32.htmlYahoo! Groups Links
    Your message has been successfully submitted and would be delivered to recipients shortly.