foreach my $tmp_name (`dcop amarok playlist filenames`) {
$tmp_string .= "[$tmp_idx]\t";
# remove common suffixes
chomp $tmp_name;
for my $suffix ( '.mp3', '.flac', '.shn', '.ogg' ) {
$tmp_name =~ s/$suffix$//;
}
# and append the filename
$tmp_string .=
( $playing =~ /$tmp_name/ ) ? "*** $tmp_name ***\n" : "$tmp_name\n";
$tmp_idx++;
}
####
$ perl -e'
my @files = ( "egg_nogg.mp3\n", "egg_nogg\n", "stupid file.ogg.shn.flac.mp3\n", "stupid fileloggashnoflacamp3\n" );
foreach my $tmp_name ( @files ) {
print "\$tmp_name = $tmp_name\t=>";
# remove common suffixes
chomp $tmp_name;
for my $suffix ( ".mp3", ".flac", ".shn", ".ogg" ) {
$tmp_name =~ s/$suffix$//;
}
print "\t$tmp_name\n";
}
'
$tmp_name = egg_nogg.mp3
=> egg_
$tmp_name = egg_nogg
=> egg_
$tmp_name = stupid file.ogg.shn.flac.mp3
=> stupid file
$tmp_name = stupid fileloggashnoflacamp3
=> stupid file
##
##
foreach my $tmp_name (`dcop amarok playlist filenames`) {
$tmp_string .= "[$tmp_idx]\t";
# remove common suffixes
chomp $tmp_name;
$tmp_name =~ s/\.(?:mp3|flac|shn|ogg)\z//;
# and append the filename
$tmp_string .=
( $playing =~ /$tmp_name/ ) ? "*** $tmp_name ***\n" : "$tmp_name\n";
$tmp_idx++;
}