Thread 0 in string einfügen
(8 answers)
Opened by Alexander at 2012-03-07 04:18 2012-03-07T13:13:44 Alexander Hi Alexander, Deine Bescheidenheit stünde mir auch mal gut :) Die aus der Hüfte geschossene RegEx oben sieht nur professionell aus, funktioniert so aber nicht ... Für Dich nachvollziehbar ist vielleicht das: Code (perl): (dl
)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 use warnings; use strict; use File::Basename qw(fileparse); #Beispielnamen my @files = qw(123.txt foo123456789.txt bar123456789.tst.txt); for my $filename (@files) { # Dateinamen zerlegen (an der letzten Extension) my ($name, $dir, $ext) = fileparse($filename, qr/\.[^.]*/); if (length($name) > 8) { $name = substr($name, 0, 7) . '~'; } print "$filename => $name$ext\n"; } Ausgabe: Code: (dl
)
1 123.txt => 123.txt Gruß FIFO Last edited: 2012-03-07 17:09:22 +0100 (CET) Everyone knows that debugging is twice as hard as writing a program in the first place. So if you're as clever as you can be when you write it, how will you ever debug it? -- Brian Kernighan: "The Elements of Programming Style"
|