Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
The readdir() function will return ., and .. as directories, in addition to the other directories on under that directory.. I'm not sure you want to use that, as you may end up coding a reverse recursive function, until you have done this to every directory you have access to. To fix this you may wish to do something as simple as greping to check if your result is actually there.

Also: Instead of -d $dirname, it may be simpler to just die, if the directory can't be opened?
opendir(DIR, $some_dir) || die "can't opendir $some_dir: $!";
Or you can write a function to nicely die, and output the reason for it to the user. Just remember to exit;, with that function.

so: instead of
if ( -d $dirname) { print "$dirname is a directory thankyou \n"; opendir(DIR, $dirname); @filenames = readdir(DIR); blah blah blah blah blah
You Could Use:
opendir(DIR, $dirname) || die "can't opendir $dirname: $!"; my @directory = readdir(DIR); my @filenames = grep { -f "$dirname/$_" } @directory; # Either use th +e array @directory, or rewinddir(DIR) here, and grep readdir(DIR) twi +ce. my @directories = grep {-d "$some_dir/$_" && !/^\.$/ && !/^\..$/} @di +rectory; closedir DIR;

And you'd have a list of everything in the directory, without . and .., and with diff arrays for directories and files. In fact, since you're only editing certain types of files, you could change the first grep to suit your needs, with a regex, or you could add a few greps for the differant types of files, which would let you change shtml files to html files rather easily. If you want to have only two greps, then use && regex.

It's also my opinion that your teacher will not be very happy if you use a ton of perl modules, as the point of this excersize seems to be to test your knowledge of perl, not the writer of a perl modules' knowledge. Using a perl module is like using somebody else code, which is alright in the GNU/perl world, but is not alright in school. I would advise hard coding much of it, and adding comments to show your teacher that you know perl modules.
Gyan Kapur

In reply to Re: help please by Revelation
in thread help please by Anonymous Monk

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others scrutinizing the Monastery: (7)
    As of 2018-06-25 10:48 GMT
    Find Nodes?
      Voting Booth?
      Should cpanminus be part of the standard Perl release?

      Results (126 votes). Check out past polls.