Sean wrote:
"I've been trying to wrap my brain around this for a little while, and I
don't think I've been completely successful, but here's my stab at what's
wrong.

You stated, I think, that line 27 worked and line 29 did not.  Line 27 
was
properly escaped...

 >      27         #chdir("/Volumes/Music\ Tunes/Toad\ Music") || die 
"cant
 > open that, sorry: $!";

.... so are you sure you did that to $folder_a?  If the path in that
variable isn't properly escaped, you'll be sunk.  Bear in mind, it may 
look
correct when printed, but you'll need those escape sequences to stick
spaces in the path (I think.)  My experience with MacOS is *extremely*
limited, so I may be making that up.  I make a lot of similar contortions
on Win32 to make paths with spaces work.

Another shot in the dark: you might want to check out File::Spec, for 
some
help cleaning up your paths.

If you could explain some more about what the function needs to do that
might help.  You might be going about something awkwardly.  As for no 
chdir
on MacOS, I did a few Google searches and didn't come up with anything
indicating that chdir was broken or nonexistent on any platform Perl 
supports.

Later,

Sean."


Sean, Thanks for the time i really appreciate it. It's a class (package) 
file you can have a look if you want. I got an external drive from 
someone with a bunch of music on it (many gb), folders inside of 
folders, etc, many of these are duplicate folders, sort of, there may be 
a few unique tunes in each duplicate folder. Rather then go through it 
by hand, I thought it sounds like a fun perl project. I am doing it 
utilizing  a class structure because i need the OOP practice.


       1 ######## This is a class(packaged-constructor-object) to look at 
a directory. It will ask you what directory(folder) you want to open.
       2 ######## It will then ask you to open another folder, so that 
you can compare the contents of the first with the second.
       3 ######## It will then  show you any files that the two have in 
common (duplicates) and ask you if you would like to delete the 
duplicates.
       4 ######## I guess it should delete the older files, i'll try to 
put that in.
       5 ########
       6 ################# This does not work SEE LINE # 29 chdir will 
not open a $var but will open the path if written out? what the? yes i 
have escaped it correctly when prompted for path (also tried many ways)
       7 package TestOpenFolders;
       8 #use strict;
       9 #use diagnostics;
      10
      11 sub new {                                       # This is where 
the class is defined (constructed) and created
      12         my $class = shift @_;
      13         my $self={};
      14         bless($self,$class);
      15         return $self;
      16 };
      17
      18
      19 sub openfolder_a {                              # This is where 
you are asked what file to open
      20         my $self = shift @_;
      21         my($folder_a, $folder_b, $checkit_a);
      22         print "What folder do you want to open? (Need complete 
path name: /Volumes/OS\ X\ Users/etc,...)\n";
      23         $folder_a=<>;
      24         chomp $folder_a;
      25         #$folder_a ="\"$folder_a\"";
      26         chomp $folder_a;
      27         #chdir("/Volumes/Music\ Tunes/Toad\ Music") || die "cant 
open that, sorry: $!";
      28         print $folder_a;
      29         #chdir($folder_a) || die "cant open that, sorry: $!";
      30 #       opendir(FOLDER_A,"$folder_a") || die "cant open 
$folder_a: $!";
      31 #       $checkit_a = readdir(FOLDER_A);
      32         print "This is a little system check, you are here:\n";
      33         system("pwd");
      34 #       print "And these are the contents of the first folder 
you opened: $checkit_a \n";
      35 #       print "What Folder do you want to compare to this 
one?\n";
      36 #       $folder_b = <>;
      37 #       chomp $folder_b;
      38 #       openfolder_b($folder_b);
      39 };
      40
      etc,...

   i could probably use a system() call it there. i haven't tried that 
yet.

Reply via email to