WWq has asked for the wisdom of the Perl Monks concerning the following question:
I have a file (file A) which contains different libraries shown as below. Each row is a different library (eg. b05_ln_rmmm_0.85v_0.00c_core is a library name). I would like to open each library in .lib format in unix. I have tried the coding below. However It doesn't work as what I want. I failed to insert words (.lib) behind those library names and save new library names in an array. And how to open these library files in perl?
file A:
b05_ln_rmmm_0.85v_0.00c_core /p/ldb/ln/b05_ln_rmmm_0.85v_0.00c_c +ore.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_c +ore.ldb:b05_un_rsss_0.66v_0.44c_core
Coding:
while (@arr2 = <CF>){ foreach $line (@arr2) { if ($line =~ m/(.*) (.*)/) { $libn = "$1"; #$libn =~ s/^\s+//; $libn =~ s/ /${1}.lib/x; print "$libn\n"; push (@arr3, $libn); $string = "vi $libn"; system ($string); } } } }
expected result:
b05_ln_rmmm_0.85v_0.00c_core.lib b05_nn__rmmm_g9v_098c_core.lib b05_un_rsss_0.66v_0.44c_core.lib
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Perl: how to insert words at the end of each line and open the file?
by toolic (Bishop) on Oct 31, 2013 at 17:53 UTC | |
by WWq (Novice) on Nov 01, 2013 at 02:39 UTC | |
by Anonymous Monk on Nov 01, 2013 at 02:48 UTC | |
by WWq (Novice) on Nov 01, 2013 at 08:19 UTC | |
|
Re: Perl: how to insert words at the end of each line and open the file?
by Laurent_R (Canon) on Oct 31, 2013 at 18:20 UTC | |
by WWq (Novice) on Nov 01, 2013 at 02:42 UTC |