in reply to Re^2: no of lines in uploaded text file
in thread no of lines in uploaded text file
When I used suggestion given by moritz my $count = 0; while( <$fh> ) { $count++; } I was unable to get content of file. I think the reason for this was that you cant reuse file handle. Can anyone tell me why this is so?You've read in the entire file. The pointer is at the end of the file. Use seek to rewind. Or, if it's your intention to suck in the entire file anyway, do it on the first pass.
I tried to use this $content = ` wc -l $Filehandle` but I could not get output in $count as it should be.Out of Define "did not work". What did you try? What did you get? What did you expect? Did you get an error? If so, what was it? What did you try to fix the error? you only answered the first question. Partially. $Filehandle sounds very fishy - is that a file handle, or does the variable $Filehandle actually contain the name of the file?
This worked fine on command prompt bt not on browser.I give you one more chance: what did happen? Did you get an error? If so, which error? Check your error log as well. Or do you have some miracle wc which says, "Hmmm, I'm called by code written by Prafull. When he's running interactively I'm going to behave. But when it's run from a webserver, I'm going to return a random number!"?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: no of lines in uploaded text file
by prafull (Novice) on May 13, 2010 at 08:58 UTC | |
by JavaFan (Canon) on May 13, 2010 at 12:51 UTC |