in reply to Determine target file format looking at one link

What kind of link are you talking about? symbolic links on unixish file systems?? Hyper links on web pages?

And how do you want to determine the type? Just by looking at the extension? Or by looking into the file?

Also try Super Search, and the perl documentation.

  • Comment on Re: Determine target file format looking at one link

Replies are listed 'Best First'.
Re^2: Determine target file format looking at one link
by Anonymous Monk on Jul 31, 2008 at 10:17 UTC
    I'm sorry I didn't specify correctly my problem.

    I'm talking about symbolic links, and I want to determine the type just by looking at the extension.

    (I don't mind looking into the file but I need the fastest way and I have the file extension in target file, so I think it would be better to use it...)
    Im working in linux.

    Thanks
      I guess you're looking for readlink. A match for /\.jpe?g$/i should do the rest. However, if you cannot trust the suffix or if you are going for a more robust program, you should give the File::MMagic module a try.
        Readlink just solved my problem. It was exactly what I was looking for. Thank you.
      I don't know if there's a pure perl solution, but you can install the program chase and parse its output in perl. Getting the extension should be a simple matter of regexes or split.