Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!lll-winken!ames!aplvax!acf4!lixj From: lixj@acf4.NYU.EDU (Xiaojian Li) Newsgroups: comp.lang.perl Subject: Re: Reading a file into a string Message-ID: <2540002@acf4.NYU.EDU> Date: 29 Jan 91 22:34:00 GMT References: <5231@taux01.nsc.com> Organization: New York University Lines: 25 To: rnews@cmcl2.NYU.EDU > >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";