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

comment on

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

I'll give you a 4-year observation. Having done something very similar to what the OP is asking, and not only for sort and uniq, but for many things that could be done in shell (I know, because I used to maintain the shell script that did it), I'll tell you that portability can be problematic. It's difficult enough ensuring portability for perl ;-), nevermind a whole host of subcommands.

I make extensive, extensive use out of trivial-looking modules such as File::Copy, and especially File::Spec, and grepping through files is commonplace.

However, that's just the 1-year view. The following 3-years of the view is that once you've started down the road of conversion to pure-perl, you'll find better, faster, and easier ways of doing things. You'll find out, perhaps, that you don't really need the sort. In shell, you need the sort to make uniq work the way you want. In perl, you don't - just use a hash. Bang! Speed improvement. In shell, you need to use temporary files if you want to feed the same input into multiple filters (sort it for one output, sort and uniq for another output, then diff, just to see what is duplicated). In perl, you can keep it in memory (if it's small enough). Bang! More speed improvement.

Reducing, and outright removing, your dependancy on the shell is just the first step to cleaner, faster, and easier to maintain scripting.

Or, at least, that's my experience with perl.

In reply to Re^3: perl functionality like unix's "sort -u" and "uniq -c" by Tanktalus
in thread perl functionality like unix's "sort -u" and "uniq -c" by Steve973

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 How to display code and escape characters are good places to start.
Log In?

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (6)
As of 2023-11-30 14:09 GMT
Find Nodes?
    Voting Booth?

    No recent polls found