Home  |  Linux  | Mysql  | PHP  | XML
From:John Delacour Date:Thu Jan 29 15:58:15 2004
Subject:Re: [MacPerl-AnyPerl] Sorting a file list
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

Navigate in group perl.macperl.anyperl at sever nntp.perl.org
Previous Next




  
© No Copyright
You are free to use Anything
Site Maintained by PHP Developer
Powered By PHP Consultants