Python/C++ vs. Perl/C++

Slurping a File

Here's a little exercise that should demonstrate that Python is a more natural scripting language option for C/C++ programmers (and human beings in general) than Perl. This is but one of many possible examples.

The task: Read the entire contents of a file into a variable.

Comment on this topic

my $text = do { local( @ARGV, $/ ) = $file ; <> } ;

I had to look this one up (thanks Perl). Even then, I don't understand it (but the above does work--I had to use it in a script!). What the hell is "ARGV" doing in there?? Utterly inscrutable. I found several alternatives to the above (see Perl slurps):

local( *FH ) ;
open( FH, $file ) or die "Problem\n"
my $text = do { local( $/ ) ; <FH> } ;
And here's yet another from elsewhere online:
my $holdTerminator = $/;
undef $/;
my $buf = <FH>;
$/ = $holdTerminator;

I'm not even sure what to say here. Perl should be embarrassed.

fileContents = file("filename").read()

Mindlessly simple. And why shouldn't it be?