in reply to Re^3: sorting inside specific
in thread sorting inside specific
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.
Here is the output:#!/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
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: sorting inside specific
by mutated (Monk) on Sep 10, 2004 at 14:00 UTC |