Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

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


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

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

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others studying the Monastery: (3)
    As of 2017-11-25 05:00 GMT
    Find Nodes?
      Voting Booth?
      In order to be able to say "I know Perl", you must have:

      Results (355 votes). Check out past polls.