I think the ingredients you need are a while loop, a regular expression and possibly an array to push your answers into.
#!/usr/local/bin/perl -w
use strict;
my @hold;
while (<DATA>) {
push(@hold, $1) if (m/(\w+\.bld)/);
}
print join("\n", @hold), "\n";
__DATA__
nbssbase/acn/bld/libacnsGH040.bld:22:acnss.cxx
foo
nbssbase/acn/bld/libacnsGH040btsc.bld:23:acnss.cxx
bar
nbssbase/acn/bld/libacnsGH040eel.bld:24:acnss.cxx
nbssbase/acn/bld/libacnsGH040mm.bld:22:acnss.cxx
nbssbase/acn/bld/libacnsGH060.bld:21:acnss.cxx
If you truly only want one, then just change
push(@hold, $1) if (m/(\w+\.bld)/);
to
push(@hold, $1) && last if (m/(\w+\.bld)/);
|