|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today! |
|
#1
|
|||
|
|||
|
what is this command in Perl? what does it do? i was just wondering what it did, as I am using it in a CGI, but am not sure exactly what it does. any info on this at all would be appreciated. if you need more info, please let me know. CujoRbd |
|
#2
|
|||
|
|||
|
Well, its not that easy to explain grep() or map() functions in Perl. The Perl Archive has a really cool article that deals with grep at:
http://tlc.perlarchive.com/0008/01.shtml Basically, the grep() functions uses regular expressions to make a list out of another list. This is a somewhat blunt explanation, so you should really go and read the article. HTH. ![]() |
|
#3
|
|||
|
|||
|
thanks! that answered alot of my questions. to explain further what i am doing, i am basically adapting an old script of mine, but don't remember why I had put in the 'grep()' command. with that page you gave me, i figured out that i must've put it in to count the amount of users i have under a specific list. though this answers my question, it now brings up another one. i am trying to basically get a printout of every user, along with some info within their specified user file. the grep command i had there was this: <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre> @members = grep(/.cgi/, @members);[/code] which had just sprung off of this: <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">code:</font><HR><pre> opendir (MEMBERDIR, "$MembersPath"); @members = readdir(MEMBERDIR); closedir (MEMBERDIR);[/code] so, basically i've opened up a certain directory and counted the amount of files that end in "cgi" (or the amount of users that are there, to be more specific). what i was hoping to do for this was to add a "foreach" statement and basically print out each user's info. but as the grep counts files and doesn't really distinguish between them, i'm not really sure what to do. what can i do instead then? is there a certain function/command that i should use? or what? please help me here, as I'd really like to finally get this script complete. THANKS!!! Cujo |
|
#4
|
|||
|
|||
|
^^^
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Perl Programming > grep() command? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|