News for hackers. Stuff that matters.
Re:Larry Wall has approved renaming Perl 6 to Raku by kbenson on Friday October 11, 2019 @07:41PM (#21229403)
> while (<>) { ($h{$_}++ == 1) && push (@outputarray, $_); };

That's a business culture thing. If you set the expectation, that it's okay to do that, people might do that. If you set the expectation that it's not okay, people shouldn't.

The equivalent C and Python are likely just as ugly (given that the equivalent python might be using a far too complex range statement or put it on a single line using : and ;, which is possible...).

That said, as bad code goes, that's not really that bad. The only non-standard things are <> and $_, and if you don't know what those are, you really haven't done the minimum of learning about the language (<> might be somewhat exotic in that form depending on the codebase, but $_ is not something you can get way with not knowing about). In all, the major problem with it is that it's not commented and uses poor variable names, which is something every language needs to deal with. I would write it like so if I wanted it on a single line (but I would probably use 2-3 lines):

    # Report each duplicated line once
    my (%lineseen,@linedups); # This was required in yours too right? I assume you're using strict...
    while (<>) { (++$lineseen{$_}==2) && push(@linedups, $_); };
But I would likely opt for the following if doing it myself:

    # Report duplicate lines once
    my %lineseen;
    my @linedups = grep { ++$lineseen{$_}==2 } (<>);
Assuming I was using <>, which I generally don't since File::Slurp is usually available and clearer.
Re:Larry Wall has approved renaming Perl 6 to Raku by cutler on Saturday October 12, 2019 @01:20AM (#21230853)
There's always <STDIN> if <> is too cryptic. I think what most fail to grok, if they've only glanced at Perl, is context. Above all Perl is a context-based language. It's the opposite of Python's spell-everything-out approach but just as valid. Perl also excels at whipupitude.
Re:Larry Wall has approved renaming Perl 6 to Raku by kbenson on Saturday October 12, 2019 @01:36AM (#21230907)
Except that <> isn't just <STDIN>, it reads from each line of each file specified as an argument on the command line or STDIN if no files were specified. This dual use (and magical-ness) is why I shy away from it in actual programs (but it is useful for one liners, which is why it does this), as it can be confusing.

Some people will look at this as evidence that Perl should be relegated to one-liners, but I find immense usefulness in combining my more engineered aspects with one-liners, and providing myself with a "project evaluator". What I do is create a simple bash script which just calls perl and sets the library include path to the project lib, includes a few useful things to always have (Path::Tiny, Try::Tiny, Data::Dumper, etc), and passed the rest of the args to Perl. Using DBIx::Class for SQL manipulation and/or using complex API client libraries I've written combined with the abilities of perl to do things easily as a one-liner is amazing.

Re:Larry Wall has approved renaming Perl 6 to Raku by Grinnz on Saturday October 12, 2019 @09:43PM (#21237707)
<> is actually <ARGV>. And actually the least cryptic spelling IMO is "readline(*ARGV)" or just bare readline, which still compiles to the same opcodes. Sure, <> is more common, but it's easier to find what readline and ARGV mean.
Re:Larry Wall has approved renaming Perl 6 to Raku by mst on Saturday October 12, 2019 @10:27AM (#21233373)
File::Slurp is broken AF though, and obsoleted by File::Slurper since the original can't be fixed without breaking accidentally working code in the wild.

Still mostly fine so long as you know you're only dealing with 7-bit ASCII, IIRC, but Caveat Emptor.

Re:Larry Wall has approved renaming Perl 6 to Raku by kbenson on Saturday October 12, 2019 @02:12PM (#21235036)
Ah, well I actually use Path::Tony's slurp functionality mostly, depending on if it's already available in the project (which it is in any I set up).

It's easier to just say File::Slurp in mixed company so people immediately know what it is if they look it up, rather than them be confronted with a grab-bag of functions.

Re:Larry Wall has approved renaming Perl 6 to Raku by Grinnz on Saturday October 12, 2019 @09:41PM (#21237705)
File::Slurper is just as immediately obvious, and happens to not be fundamentally misdesigned :) Path::Tiny is also great.