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

As the first part of johngg’s suggestion gave what I wanted, I copied the Perl into a file and ran this in an MSDOS window.

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;
Perl ran but sadly did not give the sorted data at the end.

Can you tell me where it is stored and how to store this in an array? I did add lines to print out @data but that, probably as expected, gave me the what was stored with the ‘qw’ at the beginning of the code.

I have used Perl for many years but I have never got to grips with this sort of coding!

Replies are listed 'Best First'.
Re^3: Sorting text-number values
by Corion (Patriarch) on Nov 30, 2016 at 09:25 UTC

    So, what did Perl output?

      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