For example, try comparing the process of getting the contents of a text file into a variable in Perl vs. PHP. Hint: In PHP, you only need one function in a short line of code.
This really has nothing to do with the point I was making, but I'll bite. I'll agree that many things are easier in PHP. This flows from PHP's philosophy of shoving everything in as individual built-in functions. I have many problems with this philosophy, but it's pretty clear that it makes many things easier.
The example you chose, though, isn't quite as dramatic as you make it to be. As others mentioned, the best answer (in terms of effort) is probably to use File::Slurp, but it's not very difficult to do in core Perl, either:
my $foo = do { local (@ARGV, $/) = "bar.txt"; <> };
Now, the PHP code is simpler and more obvious, but the Perl is no great feat. It's common enough that most good Perl programmers should recognize it immediately. Again, I'm not trying to say your main point about PHP being easier is wrong, but I don't think this is the best example of it.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|