in reply to Re: Determine target file format looking at one link
in thread Determine target file format looking at one link

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
  • Comment on Re^2: Determine target file format looking at one link

Replies are listed 'Best First'.
Re^3: Determine target file format looking at one link
by Perlbotics (Archbishop) on Jul 31, 2008 at 13:38 UTC
    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.
Re^3: Determine target file format looking at one link
by moritz (Cardinal) on Jul 31, 2008 at 10:26 UTC
    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.