my $file_text = do { local $/ = undef; open my $fh, '<', 'data.txt'; <$fh> };
I have absolutely no idea what this line does. local? undef? '<'?, <$fh>? This is how you read a file in Perl? my $file_text = do { local $/ = undef; open my $fh, '<', 'data.txt'; <$fh> };
I have absolutely no idea what this line does. local? undef? '<'?, <$fh>? This is how you read a file in Perl?Nope. I use Path::Class from CPAN...
use Path::Class 'file';
my $file_text = file('data.txt')->slurp;If you don't know Perl, why should you expect to? I didn't know that #(...) represented a lambda in Scala until a moment ago.
Yes, lots of tutorials explain it badly, and yes, lots of people say "Why should a programming language take cues from natural language?", but implicit variables and context are concepts that primary school children have mastered. They're not that difficult.
Seriously, in what other language don't you ever finish discovering what's on the default namespace, what side-effects any given statement, or hell, expression has, or which syntactic forms are supported, and on and on?
Well, PHP, but we know what the connotations of that are.
And by the way, I'm doing rather 'fine' in Perl, if not for the ever-present worrying about type mismatches (particularly arrays), the frustration of how dirty many operations are (unless you are using a recent version, regex substitution must mutate a variable), the laboriousness of the stock error handling mechanisms (make your own stack trace!) and so on.