in reply to list dir contents, w/o some stuff
What you need to read is perlop, look for the "eq" operator, and then check out perlfunc:scalar (cause that be the "context" you're putting @files in), perldata and of course perlsyn.
I mentioned all of the above just cause I like pod very much, and you should read them in either case.
Also, see perlfunc:die, cause die print "blah" is not what you want. die writes to STDERR, print writes to STDOUT, so you'd get 'blah' on STDOUT (the browser), and 1 in the error log. you either want to "die", or print "blah" and die;
Remember that foreach you got for @files, you need one for @noshow (btw - like perlsyn says, for is an alias for foreach ;D). It might not be apparent, but you can also use perlfunc:grep to do what you want. Monks usually use it like so (untested, but should work):
#!/usr/bin/perl -w use strict; # always use strict, or die opendir(DIR,'./') or die "couldn't open directory"; my $noshow = join '|', map { quotemeta } ('.','..',__FILE__); my @files = grep !/$noshow/, readdir(DIR); print "$_<BR>" for @files;
PS - You, and every monk there is, should also read How to RTFM. It is invaluable.
update: hey, everybody decided to reply to this, and I'm last, whohooo.
update: One of the most inportant things to understand about perl, besides references, is "context", and japhy's article sums it up pretty nicely. Also, you might wanna check out perlfunc:map and perlfunc:quotemeta. I assume you are familiar with $_;
| ______crazyinsomniac_____________________________ Of all the things I've lost, I miss my mind the most. perl -e "$q=$_;map({chr unpack qq;H*;,$_}split(q;;,q*H*));print;$q/$q;" |
|
|---|