Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

I think it might be worth trying to figure out what you'd like to learn, as that might help point you in the right direction. The quotation from the book rightly point that there's lots of wisdom to be learnt from the core modules and others on CPAN. Let's assume a somewhat false distinction between learning about problem solving in Perl, idioms and good manners.

"Look at how Perl Programmers view problems and furthermore, how they solve them"

If you're keen to figure out (generally) how to do (specific) things in Perl, find a CPAN module that does something that you know about from elsewhere, as other posters have suggested. For example, let's say you've got an interest in Linguistics: take a look at the Lingua family of modules, which do clever things with natural language. Or if you're hot on HTML, take a look at the HTML family. Then you can see how a problem whose parameters you understand well (let's say, cleaning up HTML) can be solved using the specific tools and resources which Perl kindly offers you.

"Examine the way they structure their programs"

It's nice to be nice, to yourself and other people. There's lots of conventions about writing perl, from the syntax to the structuring of a module's files that will help you avoid heartache. I guess here, you might want to follow Zaxo's advice, and look for CPAN modules by authors of good repute. For example, you could find out how to use packages to stop variables from different bits of a program bumping into each other.

"get familar with the idioms they use"

You might like to know how to use some less obvious features of Perl to do specific things concisely. For example, suppose you wanted to store some English text for use in your program, but didn't want to have to constantly have to move another file around with your Perl program:

my $text; { local $/; $text = <DATA>; } ... rest of your program here __DATA__ foo bar bla bla foo bar

I think of this as something that's useful, concise, but not immediately obvious from the bare syntax and functions of Perl. If this is what you're after, again, take a look at widely-used modules by well-known authors, or (some) of the core modules, but...

I suppose I'd be a bit wary of just picking a random core module and looking at it for ideas, even though, as other monks have pointed out, they're very well tested. After 5 years, I still find some of the core modules a bit intimidating, as you'd expect from modules written by super-experts. Furthermore, some of them depend on C-extensions, so though you might learn something about writing nice, polite interfaces, you can't learn much about algorithms or idioms. Finally, lots of them deal with problems and deep internals you probably won't ever have to worry about, because somebody else already has, as evidenced by the fact that module exists and is in core. There are some exceptions - for example, the Net family, which are very useful, especially if you're interested in that sort of thing anyway.

Happy browsing


In reply to Re: Learning from modules by ViceRaid
in thread Learning from modules by mooseboy

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (2)
As of 2021-07-28 01:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?