Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

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

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

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

Title:
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!
  • 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?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others about the Monastery: (6)
    As of 2015-07-05 10:49 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









      Results (61 votes), past polls