Beefy Boxes and Bandwidth Generously Provided by pair Networks vroom
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^4: Another prediction of Perl's demise

by Dylan (Monk)
on Nov 26, 2004 at 02:08 UTC ( [id://410520]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Re^3: Another prediction of Perl's demise
in thread Another prediction of Perl's demise

use Fatal qw( :void open close ); sub slurp { local $/ = undef; my ($s, $file); open $file, $_[0]; $s = readline $file; close $file; return $s; } $foo = slurp("bar.txt");
That's not very much code. Or, use CPAN.
use Slurp; my $foo = slurp("bar.txt", "baz.txt");

Replies are listed 'Best First'.
Re^5: Another prediction of Perl's demise
by apotheon (Deacon) on Nov 26, 2004 at 02:18 UTC

    Your "that's not very much code" example is, in terms of a size ratio, a staggering increase in "effort". If you happen to be writing something involving a lot of tasks that compare similarly between the two languages, the difference can really pile up.

    I'm afraid I don't really know anything about the Slurp module, and don't feel like looking it up right now. Thus, I can't really comment on the second example at this time.

    In any case, my point was that some things are easier in PHP. Perhaps there are easier ways (or means that have roughly the same ease) to do these things in Perl, but if so, I certainly don't know them all. I suppose there's always the possibility that I'm just Wrong, and all PHP sucks ass horribly beside comparable use of Perl, but I tend to think that's not so — else the PHP language would never have been created in the first place.

    - apotheon
    CopyWrite Chad Perrin

      Well, some things are. However $foo = $bar || $baz doesn't work in PHP. Or even $foo ||= $bar.

        Great. So, when your choice of language for a given task is determined entirely by your ability to use that particular expression (or equivalent), use Perl. That's no strict declaration that you should always use Perl for everything, all the time, though.

        The fact that hammers are better at pounding nails is not an indication that you should always use a hammer for every task, eschewing the use of screwdrivers. Use the right tool for the job at hand.

        - apotheon
        CopyWrite Chad Perrin

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://410520]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.