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
In reply to Re^4: sorting inside specific
by Limbic~Region
in thread sorting inside specific
by texuser74
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |