CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Excluding certain lines when writing from an array

 



Mel
Deleted

May 21, 2000, 6:17 AM

Post #1 of 2 (353 views)
Excluding certain lines when writing from an array Can't Post

This is what I need help with: this is waht I have:
opendir(USRS, "$rootdir");
@usrs = readdir (USRS);
closedir(USRS);
open(USRS, ">$rootdir\/usrstemp.dat");

That above opens the folder, reads all of it's contents into @usrs and then closes and the dir and then opens the file I want to print @usrs to. Now, I want it to print
<OPTION SELECTED>$line</OPTION>\n to USRS for each $line that IS the "name of a folder", or it could just print "any line that doesnot contain a period somewhere in it". I have tried and tried and I can't figure out a way to do this. If you could help it would be great!

Thanks, Mel


UKWebs
Deleted

May 21, 2000, 8:58 AM

Post #2 of 2 (353 views)
Re: Excluding certain lines when writing from an array [In reply to] Can't Post

Try this:

<BLOCKQUOTE><font size="1" face="Arial,Helvetica,sans serif">code:</font><HR>

opendir(USRS, "$rootdir");
@usrs = readdir (USRS);
closedir(USRS);
open(USRS, ">$rootdir\/usrstemp.dat");
foreach $line (@usrs) {
if ((-d "$rootdir/$line") and ($line !~ /\./)) {
print USRS "<OPTION SELECTED>$line</OPTION>\n";
}
}
close (USRS);</pre><HR></BLOCKQUOTE>

Regards,
Jonathan Michaelson

Way to the Web Ltd
Web Hosting, E-Commerce and CGI Scripting
http://www.waytotheweb.com


[This message has been edited by UKWebs (edited 05-21-2000).]

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives