On 10/27/07, sam <[EMAIL PROTECTED]> wrote: > print "What Lesson are you on? "; > chop($lesson = <STDIN>);
Although there's nothing really "wrong" wrong with that code, the use of chop() instead of chomp() is antiquated. Are you reading a book printed more than ten years ago? Maybe even a book about Perl version 4? Things have changed more than a little since those days.... If your book doesn't cover modern basics like my() and 'use strict', it's probably a good time to look for newer study materials. (But, mostly, modern perl is backward compatible; although such old code may not be the best way to do something, it generally will get the job done.) > umask 0022; > The problem I'm having is that the permissions on the files being > created are 644 and not 755. I know it has something to do with octals > but I'm not sure what else. Have you seen the documentation for umask? You can type 'perldoc -f umask' at a prompt to see the documentation for that function, or see this page: http://perldoc.perl.org/functions/umask.html The key is that the umask shows disabled permission bits, but there's no automatic way to ENable permission bits. That's so that another programmer (say, someone writing a library) can't accidentally or intentionally trick your code into turning on more permissions than you'd expect, such as the setgid bit. It's a security thing. The idea behind the umask is that programs should generally leave it under the user's control. Directories are usually created with default permissions of 0777, while files have 0666. (In Perl, the default permission bits are sometimes implicit, sometimes explicit, depending upon the choice of function.) The umask lets the user choose to take some of those bits away; since many users have a umask of 0022, their directories and files are created as 0755 and 0644, which is often what they want. If a user is working more closely than usual with others, the group may choose to use a umask with fewer bits set; conversely, the user may wish to turn on more umask bits before running your program when they know they're working with confidential data. But if your program needs to create a file that's private (for example, if you had to store a password in a file), you'd want to set some bits in the umask to ensure that it's kept secret, even if the user had a liberal umask: my $old_umask = umask 0077; # block everybody else open SECRET_DATA, ">seekret.dat" or die "Can't create file: $!"; umask $old_umask; print SECRET_DATA "pa\$\$word\n"; close SECRET_DATA; Because of this security feature, if you want a file to have execute permission, or any other extra permission bits turned on, you have to explicitly use chmod(), maybe something like this: chmod 0755, @programs; # everybody can run them Hope this helps! --Tom Phoenix Stonehenge Perl Training -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/