#!/home/ben/software/install/bin/perl use warnings; use strict; use utf8; use File::Slurper 'read_text'; use Text::LineNumber; my $file = "test.c"; my $c = read_text ($file); my $tln = Text::LineNumber->new ($c); while ($c =~ /\b(bsearch[^;]*);/g) { my $match = $1; my $pos = pos ($c) - length ($match); my $line = $tln->off2lnr ($pos); print "$file:$line: '$match'.\n"; }