in reply to How do i take the first 4 characters of any file name in a specified directory?

In the spirit of TMTOWTDI:
$name =~ /^(.{0,4})/ && print "$1\n";
In the matter of obtaining the filenames, I fully agree with dHarry, use readdir & co.
  • Comment on Re: How do i take the first 4 characters of any file name in a specified directory?
  • Download Code

Replies are listed 'Best First'.
Re^2: How do i take the first 4 characters of any file name in a specified directory?
by moritz (Cardinal) on Sep 17, 2008 at 07:59 UTC
    Don't forget the /s modifier on your regex, because a file name could actually contain a newline character (at least on unix-like platforms that's allowed).