in reply to Sorting, recursion, and tail-call optimizations

I wonder if it's related to having a bareword (my_sort) while strict subs is in use? I changed your code slightly:
@data = map { join '/', @$_ } sort {my_sort} @data;

... and got this error:
Bareword "my_sort" not allowed while "strict subs" in use

Replies are listed 'Best First'.
Re^2: Sorting, recursion, and tail-call optimizations
by Limbic~Region (Chancellor) on Jan 06, 2006 at 17:01 UTC
    kwaping,
    I doubt it. The barewords error only comes into play when you put a block around my_sort without the parens. It becomes ambigous to parser and the parens are needed to tell it that it is a function call. This doesn't explain (to me at least) why
    @data = map { join '/', @$_ } sort { my_sort() } @data; # works @data = map { join '/', @$_ } sort my_sort @data; # breaks

    Cheers - L~R

      Well, this is purely speculation, but I was just thinking that maybe there was an error generated that was somehow internal to the sort function and wasn't elegantly passed along to $!. For what it's worth, the error received on OSX was "Bus error".

        "Bus error" is likely to translate to "Invalid access": using a bad pointer.


        DWIM is Perl's answer to Gödel