On Sun, Jan 27, 2013 at 11:30 AM, Mike Flannigan <mikef...@att.net> wrote: > > I have written some CGI applications that start > with this code: > > > BEGIN { > my $homedir = ( getpwuid($>) )[7]; > my @user_include; > foreach my $path (@INC) { > if ( -d $homedir . '/perl' . $path ) { > push @user_include, $homedir . '/perl' . $path; > } > } > unshift @INC, @user_include; > } > > > I have failed to document exactly what this section > is doing and would like to correct that. Am I correct > when I say that this code includes all the directories > where Perl is located (C:/Perl in my case) in @INC, so > there is little chance of not finding a module I have > installed and am calling in this CGI script? > > > Mike Flannigan >
Hi, I may be wrong, as I haven't used CGI or done much web programming, but here is my take. getpwuid seems like a unix call - are you sure this code is running on Windows. This call is returning the home directory of the effective user of the script. It the loops through each directory in the Perl include directories (@INC). If a directory with the same name as a directory in the Perl include path exists under the a perl subdirectory of the effective user's home directory, it is added to the Perl include directories. More importantly, it is 'unshifted', so it is placed ahead of the usual include directory that it matches. Thus the user's Perl subdirectory will be used instead of the standard Perl installation library. I do not think this would work on Windows, as the include directories include the drive (C:,etc) in their name. Not sure whether it would work on Unix (linux, etc), but that seems like what it was designed for. HTH, Ken HTH, Ken -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/