Reply to Re: deleting all the files in a directory

Your name:

Reply:


Posted by Bart the bear on 02/15/06 22:23

Mladen Gogala wrote:

> map { unlink($_) if -f $_; } glob("/mydir/*");

Speaking of this, is there any chance of references to functions in
PHP?
The "{ unlink($_) if -f $_; }" part of the code here is so called
"anonymous
subroutine" or "subroutine reference" which is sort of convenient if
you don't
want to clutter the namespace with unneeded function names. All you
need
to be able to implement your one-liner in PHP is an anonymous function
reference
to pass to array_walk, which is identical to Perl's "map".
Also, Perl has qr() construct which compiles regular expressions and
makes
things significantly faster. Is there any flag to compile regular
expression in
prreg_match? The only documented flag here is to capture offset. If I
need to
go through multiple lines in a loop, will PHP compile the regular
expression?
The situation I have in mind is something like this:

while ( $line=fread($file,128)) {
if preg_match("/$regexp/",$line,$found)....
}

As you can see, I'm a beginner with PHP. I have 5 years or so
experience
with Perl.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация