Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Stupid Q: Read complete file into variable or string

Reply
Thread Tools

Stupid Q: Read complete file into variable or string

 
 
Franzl Wisseworst
Guest
Posts: n/a
 
      07-09-2006
Sherm Pendley wrote:

[..]

> answers to the same (or similar) questions as you asked.


You are totally right. Point taken and acted upon!
 
Reply With Quote
 
 
 
 
Franzl Wisseworst
Guest
Posts: n/a
 
      07-09-2006
DJ Stunks wrote:

[...]

> also pointed out to you.


Thank you, I did glance over the various documentations of course, but only
with a fraction of understanding... At least now I know where to look.
 
Reply With Quote
 
 
 
 
Franzl Wisseworst
Guest
Posts: n/a
 
      07-09-2006
Dr.Ruud wrote:

[...]

> But what holds you back from processing the file line-by-line?


Nothing except my lack of know-how. I did get the general impression this
would be the better methology however, and will take your advise. Thank you.
 
Reply With Quote
 
DJ Stunks
Guest
Posts: n/a
 
      07-09-2006
Franzl Wisseworst wrote:
> Dr.Ruud wrote:
>
> [...]
>
> > But what holds you back from processing the file line-by-line?

>
> Nothing except my lack of know-how. I did get the general impression this
> would be the better methology however, and will take your advise. Thank you.


I think your case is a good use of slurp; you need the complete
contents of the file, and your file is relatively small. All I
suggested was slurping into a scalar rather than into an array.

Line by line processing is generally "better" if you are, in fact,
processing the lines. Simply concatenating strings together, line by
line, is not as efficient as a slurp.

Anyway, it sounds like you're there. Enjoy.

-jp

 
Reply With Quote
 
Franzl Wisseworst
Guest
Posts: n/a
 
      07-09-2006
DJ Stunks wrote:

[..]

> line, is not as efficient as a slurp.


Yes, I generally understood from articles that line-by-line may be slower.

> Anyway, it sounds like you're there. Enjoy.


Thanks for the words of encouragement! I shall try the slurpy route too.

 
Reply With Quote
 
Dr.Ruud
Guest
Posts: n/a
 
      07-09-2006
Franzl Wisseworst schreef:

> I generally understood from articles that line-by-line may be
> slower.


Decide on what you need to do per line. If what you need to do is easier
on the whole file at once, then slurp. See also Tie::File.

Don't assume there is a disk-io for every line: normally data is read
from disk in big chunks (by the gnomes).

--
Affijn, Ruud

"Gewoon is een tijger."


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to read a text file into a string variable ad ASP .Net 3 02-23-2006 03:39 PM
Stupid question. Please, only stupid responders. If you're not sureif you're stupid, you probably aren't. =?ISO-8859-1?Q?R=F4g=EAr?= Computer Support 6 07-18-2005 05:11 AM
stupid stupid stupid kpg MCSE 17 11-26-2004 02:59 PM
Stupid is as Stupid Does! Michael P Gabriel Digital Photography 3 06-26-2004 12:49 PM
Need to concatenate all files in a dir together into one file and read the first 225 characters from each file into another file. Tony Perl Misc 5 04-19-2004 03:28 PM



Advertisments