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
|