http://www.perlmonks.org?node_id=1060615


in reply to Perl: how to insert words at the end of each line and open the file?

This gives you the output you want:
use warnings; use strict; while (my $line = <DATA>) { if ($line =~ /(\S+)/) { my $libn = "$1.lib"; print "$libn\n"; } } __DATA__ b05_ln_rmmm_0.85v_0.00c_core /p/ldb/ln/b05_ln_rmmm_0.85v_0.00c_core. +ldb:b05_ln_rmmm_0.85v_0.00c_core.ldb b05_nn__rmmm_g9v_098c_core /p/ldb/nn/b05_nn__rmmm_g9v_098c_core.ldb: +b05_nn__rmmm_g9v_098c_core b05_un_rsss_0.66v_0.44c_core /p/ldb/un/b05_un_rsss_0.66v_0.44c_core. +ldb:b05_un_rsss_0.66v_0.44c_core