in reply to problem running executable in subdirectories

Thank you for the pointers!

The script is run on a linux system, I used foo.exe to illustrate the fact that it is an executable- what's a less confusing way to designate an executable for unix/linux? The foo executable must be run from within the target directory, I don't believe it can be run on a directory.

For the sake of improving my perl abilities I figured this would be a good script to write in perl, however the actual shell is tcsh.

I've included the error message below; each time I run the script I get hundreds of these errors all with different and seemingly random characters after "cd:"- if "cd: 0:" means that it is attempting to cd into directory "0", then something must be wrong with the list, because the first scalar on that list should be 00112.

sh: line 0: cd: 0: No such file or directory

Replies are listed 'Best First'.
Re^2: trouble with a simple script
by ikegami (Patriarch) on Jul 07, 2010 at 19:31 UTC

    however the actual shell is tcsh

    No, system and backticks execute sh (cmd on Windows). You can always execute another shell explicitly (e.g. system(tcsh => (-c => $tcsh_command));) but you didn't.

Re^2: trouble with a simple script
by ikegami (Patriarch) on Jul 07, 2010 at 19:46 UTC

    if "cd: 0:" means that it is attempting to cd into directory "0", then something must be wrong with the list, because the first scalar on that list should be 00112.

    I'm guessing that error is from using split'',$foo;. It should be split ' ', $foo.

    $ perl -E'say join ":", split "", "abc def"' a:b:c: :d:e:f $ perl -E'say join ":", split " ", "abc def"' abc:def

    That said, if you're going to use ls,

    my $dirs = `ls -d *`; my @dirs = split ' ', $dirs;
    can be simplified to
    chomp( my @dirs = `ls -d *` );

    Update: hum, it's not really any simpler.