Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • He is mostly just complaining about the syntax. So, he is saying that:

    ${$arrayRef}[0]=4;

    Is uglier than (I agree):

    array[0]=4;

    And

    $x=func(1,\@array);

    Is uglier than (meh):

    x=func(1,array)

    Reference handling is one of the few things I really don't like about Perl. In a high level language like Perl, you shouldn't have to worry about what's a reference what isn't (most of the time). It goes against DWIM.

    He also complains about having to change the prefix on the array to access the individual element.

    •     $x=func(1,\@array);
      ...
          x=func(1,array)
      I like that you have to specify that you're passing a reference. I like that by default, perl flattens arrays into the argument list. I seem to do that more often than passing in references. When I was playing with Ruby, a gotcha for me was that you had to add extra syntax to flatten the array in an argument list. So what are these people complaining about? You gotta have it one way or the other, I like the perl way, but I could adjust to the other way (WITHOUT COMPLAINT!).
      • Besides, you could say:

        $x = func(1, @array);

        sub func {
        my ( $x, @array ) = @_;
        ...
        }
        You only get into trouble this way if you want to pass in more than one array or hash.
        • Though I forgot one of the points of this whole thread was about passing by reference...oh well. I hardly ever want to do that anyway except in OO programming. And in perl, objects are always references.