Date: 4 Oct 2001 00:34:34 GMT From: damian@qimr.edu.au (Damian James) Subject: Re: opening directories Message-Id: On Wed, 3 Oct 2001 14:29:28 GMT, catherine mullen said: >Hi kind people > WARNING: while most people here are trying to be kind, sometimes it may be difficult to tell that :-). >[snip program details] > >Another directory called 'structures' is created which in turn creates >directories, which in turn have more objects You might find it easier to describe things clearly if you forbid yourself to use the passive voice. That way, you force yourself to be clear about 'who is doing what to whom'. I don't understand how a directory can create directories, and you don't say what is creating $username/structures. >my problem: > >when the code below checks the eLectures to find that username, if it finds >it a home page is printed. Okay, so the username is listed in a file. So far so good. >I want to then check the 'eLectures\\structures'to see if the username has >any structures, if they have the normal home page can be called, if not I >want a different homepage to be invoked with more direction to uploading >files. I am not sure here whether you want to test for the existence of $username/structures or you want to test for the existence or files and/or subdirectories under $username/structures. in case of the former, try print "$username/structures exists!\n" if -d "$username/structures"; in case of the latter: print "$username/structures contains stuff!\n" if glob "$username/structures/*"; See: perldoc -f '-X' perldoc -f glob >What do you think? Can I open more than one file and test for occupancy!? I am not sure what you mean here. >sub testLogin { > >my $username = param('username'); >my $password = param('password'); >open(FILE, "c:\\electures\\info\\lecturers.dat") or print "Can't DO it"; Note that you don't need to keep using escaped backwhacks in you specified path: you will be fine using normal slashes. Also, if open() does indeed fail, you will probably want to know why: my $file = 'c:/electures/info/lecturers.dat'; open(FILE, "$file") or print "Can't open $file: $!\n"; See `perldoc perlvar` and look at $!. >@pwd = ; >close FILE; >@match = grep {/^$username/} @pwd; >(my @results) = split(/\t/, $match[0]); You could rewrite this to avoid slurping the whole file: my @results; while (my $line = ) { if ( /^$username/ ) { @results = split(/\t/, $line); last; } } close FILE; >if ($username eq $results[0]) { >#makeCookie($username); >printFrameset($username); >}else { >register(); >} >} You might try using indentation to make your code more readable. If you are really using the cgi-supplied $username data to do things to your file system, then you probably want to find out about taint checking. See `perldoc perlsec` and `perldoc perlrun` and look at the '-T' command line option. Anyway, good luck and all that. HTH, Cheers, Damian -- @:=grep!(m!$/|#!..$|),split//,;@;=0..$#:;while($:=@;){$;=rand $:--,@;[$;,$:]=@;[$:,$;]while$:;push@|,shift@;if$;[0]==@|;select$,, $,,$,,1/80;print qq x\bxx((@;+@|)*$|++),@:[@|,@;],!@;&&$/} __END__ Just another Perl Hacker,### http://home.pacific.net.au/~djames.hub