I am faced with the "worse is better" way in my current project. I have a piece of code that creates files with several thousand checksums in it.
One of the things it does is open a file thusly:
open (OUT, "|sort -u > $filename");
whereas I decided to use a hash and ditch the sort (1). This has been mostly successful, and cleaned up other areas of the code. I have a new problem in a similar vein, however:
$compare = `diff $file1 $file2 2>&1`;
$comapre =~ s/^\n$//;
if ($compare ne "") { #fail ... }
using diff (1) is very tempting, but I would rather not use any system calls in this case. I am, however, faced with adding, say, 10 lines of code instead of just using the diff.
I know that this is why the "worse is better" approach is sometimes taken by programmers, and I may just use it. But I'd really like to know if somebody has a solution that is simple and clear... Or opinions on using diff in this case <!- except I dont want to hear from you, tilly... ->.
thanks
brother dep.
--
Laziness, Impatience, Hubris, and Generosity.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.