Jump to content



Welcome to AstaHost - Dear Guest , Please Register here to get Your own website. - Ask a Question / Express Opinion / Reply w/o Sign-Up!

Toggle shoutbox Shoutbox Open the Shoutbox in a popup

@  yordan : (19 June 2013 - 02:28 PM) Long Life To Asta New Era
@  agyat : (19 June 2013 - 01:58 PM) New Era Start At Asta Or Asta Start In New Era. :unsure:
@  yordan : (16 June 2013 - 05:41 PM) You're Welcome, Agyat!
@  agyat : (16 June 2013 - 07:38 AM) Thanks Yordan...
@  velma : (16 June 2013 - 12:06 AM) I Have Asked Opa To Check For A Backup.. He'll Let Me Know Soon :)
@  velma : (16 June 2013 - 12:05 AM) T_T It Seems That Someone Has Deleted That Topic Since I Found The Url Of The Topic But It Gives Me An Error
@  yordan : (15 June 2013 - 10:31 PM) @velma : It's A Tuto On How To Create A Login Program.
@  yordan : (15 June 2013 - 10:31 PM) Happy Birthday To Youuuuuu Agyat!
@  yordan : (15 June 2013 - 10:31 PM) Ba$
@  agyat : (15 June 2013 - 04:41 PM) :(
@  agyat : (15 June 2013 - 04:41 PM) Where The Hall I Were? 15Th Is Almost At End And No-One Wished Me "happy Birthday"!!!
@  velma : (14 June 2013 - 10:39 AM) Which Tutorial Is He Searching For?
@  velma : (14 June 2013 - 10:38 AM) Which Tutorial Is He Searching For?
@  yordan : (14 June 2013 - 07:47 AM) Ok, Have A Look Tomorrow.
@  yordan : (13 June 2013 - 03:19 PM) @velma, Can You Have A Look At Feelay's Problem? Seems That His Tutorial Is Not Searchable Today.
@  Feelay : (13 June 2013 - 08:11 AM) Oh, Haha
@  velma : (12 June 2013 - 05:39 PM) T_T Lately My Levels Of Procrastination..... **sigh**
@  velma : (12 June 2013 - 05:38 PM) I'll Do It Later
@  velma : (12 June 2013 - 05:38 PM) Procrastinators.. People Who Keep Saying "i'll Do This In A Bit"
@  Feelay : (12 June 2013 - 02:05 PM) Deal Punishments To What?

Replying to Strange Perl Behavior


Post Options

    • Can't make it out? Click here to generate a new image

  or Cancel


Topic Summary

wisestone

Posted 15 July 2005 - 12:21 PM

Its seriously just reeding the file in, try:

for(1..2)
{
my @lines;
open(FILE, file1.txt);
while(<FILE>)
{
push(@lines, $_);
}
}

It doesn't have to be opening the same file again but I used that just to make it easier.

vizskywalker

Posted 13 July 2005 - 04:34 AM

Could you either post the script here so I can a) test it myself, and :P check it out, or PM it to me if it is too large to post (more than maybe 50 or so lines tops). I promise to try and help to the best of my ability.

~Viz

wisestone

Posted 13 July 2005 - 01:26 AM

The file loads are in the same script and I have 2 gb of ram.

vizskywalker

Posted 12 July 2005 - 05:40 AM

Could you be more specific? Is this multiple file loads in the same script? Also, how much RAM do you have? I have an idea as to why this may be occuring but I need those pieces of information to help.

~Viz

wisestone

Posted 12 July 2005 - 12:00 AM

I have been working on a strange problem I've been having. I am reading
a series of large files (50 mb or so) in one at a time with:
@lines = <FILE>;
or (same behavior with each)
while(<FILE>){
push(@lines, $_);
}
The first time I read a file it will read into the array in about 2
seconds. The second time I try to read a file in (the same size) it
takes about 20 seconds. Everything is declared locally inside the loop
so, everything is leaving scope. I am not sure why it is taking so much
longer the second time. I need to read the entire file in because I am doing a series of operations on the lines that is not known at compile time.

I have narrowed the problem down to a few different areas:

1. It seems that if I read the file into a large scaler by $/ = undef,
the file gets read faster. So, I assume the slow down is taking place
inside the spliting of the lines.

2. If I try to append to one large array, rather then rewritting to a
different array, the slow down does not occur. So it seems Perl has a
hard time with the memory it already has but its fine with memory it
just took from the system?

3. The problem does not seem to happen in Linux, but I'm working
Windows.

Any suggestions for a workaround? Has anyone else seen this? Thanks in
advance.

Ben

Review the complete topic (launches new window)