#! /usr/bin/perl use strict; use warnings; my $text = do { local $/; }; my @matches; while ( $text =~ m<\\includegraphics(?:\[.*?\])?\{(.+?)\}>gc ) { push @matches, $1; } { local $\ = local $, = $/; print @matches; } __DATA__ Schau mal dies: \includegraphics{bild1.jpg} Oder dieses: \includegraphics[2,"second"]{bild2.jpg} Aber nicht das hier: \includegraphicsNew{no_pic.jpg}