excellent ...thanks.... but as I was recoding I came up with another thought. How do I print a single string in front of this on line one time?
the file is now e3434 e4343 de3434 3545 now I want foostring 0,0,0 e3434 e4343 de3434 3545 I tried s/(^E+ ) foostring \t0,0,0/; thank you, Derek B. Smith OhioHealth IT UNIX / TSM / EDM Teams 614-566-4145 Jeff 'japhy' Pinyan <[EMAIL PROTECTED]> 06/16/2004 12:58 PM Please respond to japhy To: [EMAIL PROTECTED] cc: [EMAIL PROTECTED] Subject: Re: printing first 40 lines in one string On Jun 16, [EMAIL PROTECTED] said: >I have a file that looks like this: > >e4343 >d3434 >34344 >43434 >de434 > >and I am printing the first 40 lines using > >$foo = qw(my/file/with/40+lines); >print substr ( $foo,0,39 ); No, that's printing the first 39 characters of the string $foo. If you have a filename in $foo, and you want to print the first 40 lines, I would suggest doing: open FILE, "< $foo" or die "can't read $foo: $!"; while (<FILE>) { print if 1 .. 40; # ooh, magical } close FILE; >but how do I print all of these lines on one line with a space meaning If that's what you want, then do: open FILE, "< $foo" or die "can't read $foo: $!"; while (<FILE>) { chomp; print "$_ " if 1 .. 40; # ooh, magical } close FILE; print "\n"; -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ CPAN ID: PINYAN [Need a programmer? If you like my work, let me know.] <stu> what does y/// stand for? <tenderpuss> why, yansliterate of course.