in reply to mkdir mode troubles

First, you're not chomping $_ so there's going to be trailing newlines in your directory names.

Second, mkdir has a return value -- use it. mkdir||warn is a good place to start.

Third, mkdir takes 777 and combines that with the value from umask to figure out the permissions on newly created directories (it's in the manual page). If you want to be certain, use chmod after creating the directory.

Last, if (after you fix the chomp) you still have ??'s after the directory names being created try printing $_ as you're creating the directories. It may have special characters or ??'s in them.

Replies are listed 'Best First'.
Re: Re: mkdir mode troubles
by newatperl (Acolyte) on May 15, 2001 at 04:09 UTC
    I did print out the $_ as I was printing, and I found that there are two non printable letters. So I did:
    open PUB_CAT, 'pub_cat.txt' or die "Can't open file: $!\n"; foreach (<PUB_CAT>) { local $/ = "\n"; chomp; local $/ = "\r"; chomp; print "(<br> $_)"; mkdir "../Online_Library/$_", 0777; }
    which works but seems ugly. Is there a better way? i.e. is there a way to test the end of a string for all common dividers?
      Instead of changing $/ and chomping, why not just say

      s/\s+$//;

      This should remove all trailing whitespace.
        that worked perfectly. Can you explain (briefly) how it works? or point me to somewhere where I can look it up? Thanks