in reply to Opinion: where Perl5 wasn't attractive for me

I've read some of the OP's previous posts, and it appears to me that most of their dissatisfaction with Perl stems from desire to use the minimum number of characters while coding. Perl is actually pretty good at that, and many critics of Perl say that this is a big flaw. Still,
1) Perl does not have integer division operator. It must call "use/no integer" to change type. Python has: / - normal division, // - integer division. Sugar.
True.
2) It is not problem for me to read dollars in single variables. But it is annoying to read them in some-dimensional arrays (it's noisy), e.g. $array[$i][$j] > $array[$i][$j-1]
Some find $array->[ $i ][ $j ] easier to read, but it adds some typing.
It is strongly recommended to "use strict" and make variables "my", then why it is not default? Whay all the code must have so much my my my my...?
There are some reasons, but true, even more typing.
Doesn't work - "$_ = reverse";
$_ = scalar reverse works. Additional word.
If in subroutine I can write "$_ = shift", why can't I write so in main (I need to write "$_ = shift @_").
@_ is meaningless at the top level. Not true, shift shifts from @ARGV there.
5) It was strange that "cho(m)p" returns last symbol, not a string w/o last symbol. Ruby's cho(m)p I like more, because I can proceed on string: gets.cho(m)p.split.do_smth...
True, that's very terse. Idiomatic Perl is different and longer.
Can't use blocks using "and/or": "$i > 5 or {print "No"; last}"
True, need to use or do { ... }
(overcome - "$i > 5 or (print "No"), last"; comma is tighter than "or" but it is counter-intuitive for me)
Not true, || is tighter then comma. Nothing 'counter-intuitive' about that. perl -E 'for (;;) { 10 > 5 || say( "No" ), last }' works like the OP seems to want it to work.
It was suprise for me that when I used "$hash{length}" it interpreted (length $_) as "length"; Surprise was that ++ has magic (I need to know exceptions) and -- has not; Surprise that "use bigint" doesn't DWIM in some cases.
Well, there're surprising thing in all languages. Let's say, true, even if those particular surprises are not very convicing, there are many more examples.

perl -CO -Mutf8 -wE 'my ( $x, $y ) = qw( a а ); say ++$x; say ++$y'

Difficult exception is that "print (1+1)*2" != "print 2*(1+1)" == "print STDOUT (1+1)*2". I think "print(..." should better wait until the end of block or ";".
Not true, as been said, print has a return value. Omitting parens save characters, that's a good thing.

I think some of their critisim is not justified. Still, it appears to me that the OP would be happier with something like Forth

Replies are listed 'Best First'.
Re^2: Opinion: where Perl5 wasn't attractive for me
by Anonymous Monk on Nov 20, 2014 at 06:41 UTC
    Doesn't work - "$_ = reverse";
    Come to think of it... I became puzzled why it doesn't work.
    $ perl -E '$_ = "skrow"; $_ = reverse; say' works
    Perhaps the OP meant print reverse or something. So, not true.

      Probably something to do with reverse operating on scalars or lists and print operating on a list. Using scalar forces scalar context so that reverse operates on $_; not sure what it defaults to operating on in list context :-s

      $ perl -Mstrict -Mwarnings -le ' $_ = q{skrow}; print reverse;' $
      $ perl -Mstrict -Mwarnings -le ' $_ = q{skrow}; print scalar reverse;' works $

      I hope this is of interest.

      Cheers,

      JohnGG

        Yes, excuse me, I was using "print reverse", and I was expecting scalar variable but forgot that print induces reverse to take array as an argument, so I need to add "scalar" or "q{}.".
Re^2: Opinion: where Perl5 wasn't attractive for me
by rsFalse (Chaplain) on Nov 20, 2014 at 12:23 UTC
    I agree that I dislike excessive keystrokes. I dislike to write $num = ($x - $x % $y) / $y. I think that not having sqrt is bad, but not having integer division is awful. How much newcomers didn't find integer division and go to search other language to learn? Idk...

    If someone use my my my near the all variables, why shouldn't it be default? I don't know how often others use my. If >80% variables precede by "my" it could be stated as default, if not then not.

    >> $_ = scalar reverse works. Additional word.
    In book from where I started to learn Perl (it is translated to my language and shortened) there were some tables: [special symbols], [logical operators], [other operators], [precedence operators](my favourite), [regex metacharacters], [regex modifiers], [special variables],... but there were no table where are written: function + what for it asks (scalar or list). Maybe it would be useful table for newcomers...

    "$i > 5 or (print "No"), last"
    This works as I wanted. For example:

    while(<>){ /^i'm tired$/i and (print "Good by!"), last; ... }

      rsFalse:

      Rather than $num = ($x - $x % $y) / $y, why not use $num = int $x / $y? I agree that having to use the former would be a bit troublesome. When you mentioned integer division in the OP, I couldn't figure out exactly what was so troublesome about using int. Seeing this, I'm thinking that maybe you're just not aware of it.

      Update: I forgot to mention, perl has the sqrt function.

      ...roboticus

      When your only tool is a hammer, all problems look like your thumb.

        Yes, I forgot about that :( . But now I tried and it makes a little different results with negatives:
        $/ = " "; $y = 2; while($x = <DATA>){ chop $x; print $num = ($x - $x % $y) / $y xor print " " xor print $num = int $x / $y xor print "\n" } __DATA__ -3 -2 -1 0 1 2 3
        Output: -2 -1 -1 -1 -1 0 0 0 0 0 1 1 1 1
        Yes. I like that Perl has sqrt.

        UPDATE: seems that my approach was not int_div, but floor.

      think that not having sqrt is bad, but not having integer division is awful. How much newcomers didn't find integer division and go to search other language to learn? Idk...
      That's correct. Perl is not the right tool for all jobs. It excels in some things, notably processing text, and this is what I use it for. I wouldn't use Perl for some numerical work (actually, I probably would but I already know Perl; I wouldn't learn it for that).
      If someone use my my my near the all variables, why shouldn't it be default? I don't know how often others use my. If >80% variables precede by "my" it could be stated as default, if not then not.
      Party due to historical reasons; the early versions of Perl didn't have lexical variables, so they couldn't be the default (and a LOT of thing in Perl are the way they are due to history). Another (perhaps bigger) part is that many (most?) Perl programmers find it a genuinly useful feature.

      I'm conviced that it would be very good if strictures and warnings were always enabled by default, and it's really unfortunate that that can't happen.

      In book from where I started to learn Perl (it is translated to my language and shortened) there were some tables: special symbols, logical operators, other operators, precedence operators(my favourite), regex metacharacters, regex modifiers, special variables,... but there were no table where are written: function + what for it asks (scalar or list). Maybe it would be useful table for newcomers...
      I don't see how perlop, perlre, or indeed, perlfunc can be reasonably shortened, compared to the originals.

      Perl is a big and complex language. It perhaps would be better in some respects if it were smaller and easier to learn... It is what it is, though.