in reply to Should I ask this question?

Welcome to PerlMonks!

Your indenting is a bit funky. I think you might find it easier to read if you used a more conventional style. There are two basic styles: cuddled and uncuddled, but both indent the code within the braces. This makes it easier to see which flow-of-control statements control which lines.

Here is an example using cuddled curly braces:

sub Wanted { my $orig_dir = cwd; if (-d $_) { chdir $_; # more code ... foreach my $file (@music_files) { chdir $_; $file =~ s/ /%20/g; #more code here } } }

And here is the uncuddled version

sub Wanted { my $orig_dir = cwd; if (-d $_) { chdir $_; # more code ... foreach my $file (@music_files) { chdir $_; $file =~ s/ /%20/g; #more code here } } }

Your code sample actually uses a mix of both the cuddled and uncuddled style. It is generally a good idea to be consistant and follow one style or another. That way your readers don't have to do mental flip-flops while reading the code. They can also focus on your code rather than trying to remember that you prefer cuddled for foreach but uncuddled for if...else or vice versa.

Best, beth