in reply to Re^2: Sorting text-number values
in thread Sorting text-number values

So, what did Perl output?

Replies are listed 'Best First'.
Re^4: Sorting text-number values
by merrymonk (Hermit) on Nov 30, 2016 at 10:12 UTC
    Without the addtional print nothing.

      That's really weird, because for me, the program outputs the following:

      #!perl -w use strict; use 5.010; my @data = qw{ this_5_string_12 some_12_garbage_23 this_5_string_8 17 this_5_string_23 some_12_garbage_6 102 this_5_string_19 5 this_5_string_101 }; my $width = 50; say for map { substr $_, 54 } sort map { do { no warnings qw{ uninitialized }; pack qq{A${width}NA*}, m{(.*\D)?(\d+)$}, $_; } } @data;
      Output:
      5 17 102 some_12_garbage_6 some_12_garbage_23 this_5_string_8 this_5_string_12 this_5_string_19 this_5_string_23 this_5_string_101
        If I use exactly your Perl, I get the output.

        If I ‘hash’ out your ‘use 5.010;’ - I get the following error message on the MSDOS screen

        Bareword "say" not allowed while "strict subs" in use at ………..amonk_f_sort.pz line 28.

        Using

        use strict; print "perl version $^V\n";
        and the output is perl version v5.20.2

        Therefore it seems it is something to do with the version of Perl being used.

        It would be good to know how to change your Perl so that it works using 'use strict;" and with my current version of Perl (and I would like to know where the sorted data is stored or how I can store it in an array).