Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!asuvax!ncar!elroy.jpl.nasa.gov!usc!zaphod.mps.ohio-state.edu!rpi!uupsi!cmcl2!cmcl2 From: lixj@acf4.NYU.EDU (Xiaojian Li) Newsgroups: comp.lang.perl Subject: Re: Reading a file into a string Message-ID: <9101292234.AA11782@acf4.NYU.EDU> Date: 29 Jan 91 22:34:21 GMT Lines: 47 From lixj@acf4.NYU.EDU Tue Jan 29 17:34:44 1991 Received: from ACF4.NYU.EDU by cmcl2.NYU.EDU (5.61/1.34) id AA00907; Tue, 29 Jan 91 17:34:44 -0500 Received: by acf4.NYU.EDU (5.61/1.34) id AA11782; Tue, 29 Jan 91 17:34:21 -0500 Date: Tue, 29 Jan 91 17:34:21 -0500 From: lixj@acf4.NYU.EDU (Xiaojian Li) Message-Id: <9101292234.AA11782@acf4.NYU.EDU> To: rnews@cmcl2.NYU.EDU Relay-Version: version nyu B notes v1.6.1 1/11/90; site acf4.NYU.EDU From: lixj@acf4.NYU.EDU (Xiaojian Li) Date: 29 Jan 91 17:34 EST Date-Received: 29 Jan 91 17:34 EST Subject: Re: Reading a file into a string Message-ID: <2540002@acf4.NYU.EDU> Path: acf4!lixj Newsgroups: comp.lang.perl Posting-Version: version nyu B notes v1.6.1 1/11/90; site acf4.NYU.EDU Organization: New York University References: <5231@taux01.nsc.com> > >How do I read an entire file into a string other than the obvious way of >reading it line by line and concatenating it. > >Please email since I don't usually have the time to read this newsgroup. > >Thanks > >Avi Bloch >National Semiconductor (Israel) >avi@taux01.nsc.com >-- > Avi Bloch I am new to perl(just two days old :-). Well, I have to say the manual is very hard, or impossible to read for non expert. Anyway, I do find by accident that the following might solve your problem: #!/bin/perl open(TMP, "$ARGV[0]"); @array = ( ); # put the whole file into an array. I don't know if # this is correct, but it seems to work. Correct me if # I am wrong. chop(@array); print @array, "\n";