in reply to Re^2: sorting inside specific
in thread sorting inside specific

No worries, I should have tested before I posted in the first place..too early and no morning coffee..sigh..at any rate it works now :P..it's still not as eloquent as your solution but I'm learning...still trying rap my head around the sort function


daN.

Replies are listed 'Best First'.
Re^4: sorting inside specific
by Limbic~Region (Chancellor) on Sep 10, 2004 at 13:52 UTC
    mutated,
    at any rate it works now

    No it doesn't. I understand that you are learning and am really not trying to beat you up here but before saying something works you should verify the output against the expected results. I have only slightly modified your code, but I left in your case sensitivity mistake SEP vs sep.

    #!/usr/bin/perl use strict; use warnings; my @array; while( <DATA> ) { @array = (@array,$_); if (/<sep>/) { print join '',sort {$a <=> $b} @array; print "<sep>\n"; @array=(); } } print join '',sort {$a <=> $b} @array; __DATA__ <sep> 22 1 3 <sep> 4 2 44
    Here is the output:
    Argument "<sep>\n" isn't numeric in sort at foo.pl line 14, <DATA> lin +e 8. Argument "<sep>\n" isn't numeric in sort at foo.pl line 14, <DATA> lin +e 8. <sep> <sep> 1 2 3 4 22 44

    Cheers - L~R

      with sort.in
      <SEP> 4 99 63 2 1 <SEP> 8 1 12 <SEP> 3 2 1
      my code produces this now
      <SEP> 1 2 4 63 99 <SEP> 1 8 12 <SEP> 1 2 3
      before it also seemed to be sorting it correctly but when I turned on warnings and strict I saw the errors you where talking about:
      Argument "\x{3c}\x{53}..." isn't numeric in sort at foo.pl line 8, <IN +> line 7. Argument "\x{3c}\x{53}..." isn't numeric in sort at foo.pl line 8, <IN +> line 11. Argument "\x{3c}\x{53}..." isn't numeric in sort at foo.pl line 14, <I +N> line 14.
      I appreciate the helpful critisim, thank you.


      daN.