in reply to shell to perl question

you can use the backticks to capture the output from some command:
@files = `find ./Images | egrep '\.jpe?g$'`; chomp(@files);
or
@files = grep /\.jpe?g$/i, `find ./Images`; chomp(@files);

Replies are listed 'Best First'.
Re^2: shell to perl question
by reasonablekeith (Deacon) on Aug 18, 2005 at 08:40 UTC
    In case you're wondering exactly how that works, perl is implicitly splitting the output on a newline character, because it's being assigned to an array. The following is an equivalent, explicit version of what's going on.
    my $files = `find ./Images | egrep '\.jpe?g$'`; my @files = split(/\n/, $files);
    UPDATE: My split was slightly off, as corrected below. Who does this guy think he is, correcting my code? ;-)
    ---
    my name's not Keith, and I'm not reasonable.
      Close. Actually, it's equivalent to
      my @files = split(/^/, $files);
      since it leaves the newlines on each indivdual list element.