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 07: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