Lee thanks for the persistence.... so let me re-explain.
Beginners and or Lee,
 
Here is my code....

        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





"JupiterHost.Net" <[EMAIL PROTECTED]>
06/16/2004 06:19 PM

 
        To:     [EMAIL PROTECTED]
        cc:     [EMAIL PROTECTED]
        Subject:        Re: string insertion




[EMAIL PROTECTED] wrote:

> People of the Perl, 
> 
> I have this file that looks like:
> 
> e4933 e4343 e3435 e9809
> 
> and I am printing the first 40 lines using
> 
> open FILE ..... ;
> while ( <FILE> ) {
> chomp
> print "$_ " if 1 .. 40;
> 
> and it gets me what I want as above on one line, but the end result 
needs 
> to be
> 
> eject 0,0,0 e4933 e4343 e3435 e9809 ........
> 
> I tried to shift the array to populate it with the eject string but with 


not exactly clear what you want your end result to be but:

my $cnt = 1;
my $string = 'eject 0,0,0';
while (<FILE>) {
    last if $cnt =< 40;
    chomp;
    $string .= $_;
    $cnt++;
}

or if you want it in an array

open FILE;
my @lines = <FILE>;
close FILE;

HTH :)

Lee.M - JupiterHost.Net

> no luck.
> 


Reply via email to