my @list=qw(http://foo.bar/Aufbruch/Gegen-die-Diktatur/01-Dissidenten-in-Europa_de.htm http://foo.bar/Aufbruch/Gegen-die-Diktatur/02-Test_de.htm http://foo.bar/Aufbruch/Gegen-die-Diktatur/index_de.htm http://foo.bar/Aufbruch/Index_de.htm http://foo.bar/Aufbruch/Jugend/01-Dieses-Land-Ist-es-nicht_de.htm http://foo.bar/Aufbruch/Subkultur/Artikel01_de.htm http://foo.bar/Aufbruch/Subkultur/Index_de.htm http://foo.bar/Aufbruch/Subkultur/TestGalerie_de.htm); @list=map{ s!/\0\0\0__([^/]+?)$!/$1!i; $_ } sort map{ s!/(index.*?\.htm.*?)$!/\0\0\0__$1!i; $_ }@list; print join("\n",@list)."\n";