I've been at this for two days now and I can't get it to work. Scripting and perl are brand new to me, so I'm sure there are at least a few nuances I'm missing. Anyways, I need the script to do three things:

1. make a list of all (and only) directories within the current directory
2. cd into each directory in the list
3. run foo.exe in each directory and return to the main directory

The main directory includes files in addition to the target directories.

#!/usr/bin/perl -w @file=`find * -type d`; foreach (@file) { `cd $_;/somepath/foo`; }

It's been suggested that I use the following in place of find * -type d

$foo=`ls -d *`; @file = split'',$foo;

Let me know if I'm missing any crucial info here, this is my first post in the monastery!


In reply to problem running executable in subdirectories by apollo

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.