Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Perl beginnere

by evereno (Initiate)
on Feb 13, 2013 at 16:56 UTC ( #1018575=perlquestion: print w/ replies, xml ) Need Help??
evereno has asked for the wisdom of the Perl Monks concerning the following question:

I have been asked to input a text file ,, I have to display a number of lines and a number of words, display the longest and shortest word in each line , occurrencess of words in each document how do I do this please

Comment on Perl beginnere
Re: Perl beginnere
by choroba (Abbot) on Feb 13, 2013 at 17:00 UTC
    Welcome to the Monastery, evereno.

    Did not the person who asked you to do that also give you some materials to study?

    What have you tried? What did not work?

    لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
Re: Perl beginner
by toolic (Chancellor) on Feb 13, 2013 at 17:18 UTC
    • Start by reading perlintro.
    • Write some code.
    • Ask specific questions related to the code you have tried.
Re: Perl beginnere
by kennethk (Monsignor) on Feb 13, 2013 at 17:44 UTC
    Some useful starting information:
    1. Files and I/O in perlintro talks about how to open and read a file.
    2. You need to define what you mean by a 'word'. I know that sounds a bit strange at first, but that will control how you split your sentences up.
    3. length and split will probably be very useful functions, though you may use other variants on regular expressions for the line parsing.
    4. For all word counts, you'll definitely want to use a hash.

    Post code that you've written, and we'll be happy to give both syntactic and stylistic feedback. However, we're here to help you learn, and learning generally takes a lot of work on your part. See How do I post a question effectively?.


    #11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

Re: Perl beginnere
by sundialsvc4 (Abbot) on Feb 13, 2013 at 20:22 UTC

    Start by surfing for examples.   Start with the very simplest one:   a loop that reads a file and prints each line.   From there, you can see your way to how to count the lines.   Next, look at split, and write a separate experimental script that takes some string and splits it.   Figure out how to count the number of elements in that string, and how to write a loop to iterate through the list.   You can find examples of all of these things ... and this is the only way to learn how to do this stuff.   You’re going to stumble, you’re going to make mistakes, and you’re going to learn the craft from that.

Re: Perl beginnere
by blue_cowdawg (Monsignor) on Feb 13, 2013 at 20:44 UTC

    I wonder who the professor is because someone else asked me the same question almost word for word and here was my answer (external site) Equivalent for the *nix "wc" command)


    Peter L. Berghold -- Unix Professional
    Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1018575]
Approved by toolic
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (7)
As of 2014-12-25 02:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (159 votes), past polls