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

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; ... }

Replies are listed 'Best First'.
Re^3: Opinion: where Perl5 wasn't attractive for me
by roboticus (Chancellor) on Nov 20, 2014 at 12:38 UTC

    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.

Re^3: Opinion: where Perl5 wasn't attractive for me
by Anonymous Monk on Nov 20, 2014 at 13:26 UTC
    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.