#! /usr/bin/perl use strict; use warnings; my $text = do { local $/; }; my @matches; print $text; while ( $text =~ m<\\includegraphics(?:\[.*?\])?\{(.+?)\}>gc ) { push @matches, $1; print "Treffer bei Position ", pos($text), "\n"; } print "Stehe nun bei Position ", pos($text), "\n"; # ohne /c ist hier pos($text) nicht definiert... { 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}