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


In reply to Re: Should I ask this question? by ELISHEVA
in thread Should I ask this question? by thecryoflove

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.