Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^4: Mean, Median and Mode

by 2teez (Vicar)
on Jun 16, 2014 at 07:30 UTC ( [id://1090003]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Mean, Median and Mode
in thread Mean, Median and Mode

With split, chomp job here would have been taken care off.

More so, it would be wonderful, if the OP tell what the content of his file 'faketext.txt' is. Is he counting the numbers of lines in the file? Is he getting different value from each line? Maybe a peek into the file would have helped.

If the OP file is CSV file, then Text::CSV_XS would be alot better than splitting on commas.

If you tell me, I'll forget.
If you show me, I'll remember.
if you involve me, I'll understand.
--- Author unknown to me

Replies are listed 'Best First'.
Re^5: Mean, Median and Mode
by vinoth.ree (Monsignor) on Jun 16, 2014 at 07:36 UTC

    Yes, I agree 2teez, first we need to understand his requirement fully, it will not help him, if we assuming ourself something and answering him?


    All is well
Re^5: Mean, Median and Mode
by Noob@Perl (Novice) on Jun 16, 2014 at 07:36 UTC

    contents of faketext.txt. after I enter "data" as in 1,2,3 (pertaining to lines 1,2,3 of txt file) it should print the mean median and mode

    Far far away, behind the word mountains, far from the countries Vokali +a and Consonantia, there live the blind texts. Separated they live in + Bookmarksgrove right at the coast of the Semantics, a large language + ocean. A small river named Duden flows by their place and supplies i +t with the necessary regelialia. It is a paradisematic country, in wh +ich roasted parts of sentences fly into your mouth. Even the all-powerful Pointing has no control about the blind texts it + is an almost unorthographic life One day however a small line of bli +nd text by the name of Lorem Ipsum decided to leave for the far World + of Grammar. The Big Oxmox advised her not to do so, because there we +re thousands of bad Commas, wild Question Marks and devious Semikoli, + but the Little Blind Text didn’t listen. She packed her seven versal +ia, put her initial into the belt and made herself on the way. When she reached the first hills of the Italic Mountains, she had a la +st view back on the skyline of her hometown Bookmarksgrove, the headl +ine of Alphabet Village and the subline of her own road, the Line Lan +e. Pityful a rethoric question ran over her cheek, then she continued + her way. On her way she met a copy. The copy warned the Little Blind Text, that where it came from it woul +d have been rewritten a thousand times and everything that was left f +rom its origin would be the word "and" and the Little Blind Text shou +ld turn around and return to its own, safe country. But nothing the c +opy said could convince her and so it didn’t take long until a few in +sidious Copy Writers ambushed her, made her drunk with Longe and Paro +le and dragged her into their agency, where they abused her for their + projects again and again. And if she hasn’t been rewritten, then the +y are still using her.
      this is what is needed to be accomplished -> Using the FakeText.txt ,write a script that opens the file and reads all of the lines. As each line is read in, split it into words and send each word to subroutines that will calculate the mean, median, and standard deviation for the lengths of those words. Print the total mean, median, and standard deviation to the screen after the entire file has been processed

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1090003]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (3)
As of 2024-04-24 22:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found