my @ejectapes = qw(/usr/local/bin/perld/lvimgGH_ms0_tapes.orig); #($^I, @ARGV) = ('.bak', @ejectapes); open (FILE, "< @ejectapes") or die "cannot open @ejectapes: $!"; while (<FILE>) { chomp; print "$_ " if 1 .. 40; } #s/(^E+)/eject\t0,0,0 \t$1/ close FILE; print "\n";
The file has 41 lines with Exxxxx strings in it. My goal is to open this file while taking the first 40 lines ( as you showed me earlier) which then I will insert the eject 0,0,0 string at the very beginning one time. The regular expression as above is commented out and has worked for me in the past but it places an eject in from of every E string. Here is a picture of what I need. eject 0,0,0 Exxxxx Exxxxx Exxxxx Exxxxx Exxxxx .....( Exxx x40) and currently it looks like this which is NOT what I want eject 0,0,0 Exxxx eject 0,0,0 Exxxxx eject 0,0,0 Exxxx (x40) thanks, derek

In reply to insertion of string one time infront of a larger string by drock

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!
  • 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, details, 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, summary, 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.