You are here: Re: deleting all the files in a directory « PHP Programming Language « IT news, forums, messages
Re: deleting all the files in a directory

Posted by Mladen Gogala on 02/16/06 03:55

On Wed, 15 Feb 2006 21:18:58 +0000, Andy Hassall wrote:

> The closest is create_function() which isn't as good as Perl's ability to pass
> code blocks, as you have to embed the anonymous function source in a string.

Yes, but it is still much more cumbersome then Perl mechanism of
references. Quite frankly, the only thing that references are really
needed for is to model self-referential structures like doubly linked
lists and alike. Personally, I find "foreach" version much more
understandable then "map" version. Speaking of Perl, I have my
own personal style of coding. My former boss, now my friend finds
Perl idioms like:

$a ||= "default";

repugnant and disgusting. He will always write the same thing
like this:

if (!defined($a)) {
$a="default";
}

PHP doesn't allow the 1st form and that is a good thing because the
||= version is the best way to write an obfuscated code which will be
misunderstood by the maintainer coming after the author. One frequent
version of the code above is

bless $var1 ref($_[0])||$_[0];

which is something that will scare away anybody who dreams of
learning Perl. I believe that not being able to write things
as concisely as in Perl is not necessarily a bad thing. Emulating
obfuscating loops by "map" function and an anonymous references
is not something that should be hastily implemented. If you want
to learn PHP, it is an order of magnitude easier to learn then
Perl.

Here I am running a risk to turn this thread into a religious war
between PHP and Perl fans. That is not my intention, I use both as,
I believe, you do as well. Both languages have their strengths and
weaknesses. I find them well complementing each other. Perl has
a PHP module, containing many of the much coveted PHP functions,
while PHP has PECL Perl module which makes it possible to run
Perl scripts from PHP. No need for religious war from either side.

>
> http://uk2.php.net/create_function
>
>>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?
>
> Looking at the PHP source code, at least for PHP 5.1.2, it already compiles
> expressions on first use and keeps the results in a cache - subsequent calls
> use the cached compiled version. At least from a quick inspection of
> ext/pcre/php_pcre.c, e.g. line 438, within php_pcre_match:
>
> /* Compile regex or get it from cache. */
> if ((re = pcre_get_compiled_regex(regex, &extra, &preg_options
> TSRMLS_CC)) == NULL) {
> RETURN_FALSE;
> }

This I didn't know. Thanks for the info.
--
http://www.mgogala.com

 

Navigation:

[Reply to this 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

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