Re: [MacPerl-AnyPerl] Sorting a file list
[email protected] (John Delacour) Thu, 29 Jan 2004 22:58:15 +0000
| Newsgroups | perl.macperl.anyperl |
|---|---|
| Message-ID | <p06100b09bc3f3ff59eee@[10.0.0.1]> |
At 11:19 pm +0100 29/1/04, Eelco Alosery wrote:
>the strings are formated this way
>
>01-12-2003|some text|soem other text|
>03-12-2003|some text|soem other text|
>10-12-2003|some text|soem other text|
Then it's very simple:
my @temp;
my @lines = split "\n", <<_;
01-12-2003|some text|soem other text|
03-12-2003|some text|soem other text|
10-12-2003|some text|soem other text|
06-12-2003|some text|soem other text|
04-12-2003|some text|soem other text|
_
for (@lines) {
s~^(..)-(..)-(....)(.+)~$3$2$1$4~;
push @temp, $_ ;
}
for (sort @temp) {
s~(....)(..)(..)(.+)~<div>$3-$2-$1$4</div>\n~;
print;
}
You would substitute <FILEHANDLE> for @lines
JD