Compress::Raw::Lzma provides a low-level Perl interface for reading and writing of lzma and xz files/buffers.