Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
This looks like a perl based rsync(1) kind of thing.
Unless I'm horribly wrong here, this is really not that ugly. About the only thing ugly is the memory usage for the various lists. That could get big, if the file lists are long. Yours is pretty easily understood code, and unless it runs many many times a second, should not be a huge problem. But if you wanted to trim up the memory usage, perhaps looking at processing the lists sequentially, and storing only exceptions would be better/faster/more elegant.
# assuming %existing_files is a hash of existing # filenames and descriptions # and we recieve the new list of files on stdin while (<STDIN>) { chomp; if ($existing_files{$_}) { delete $existing_files{$_}; } else { $existing_files{$}="Newly Added file $_"; } } # at this point %existing_files contains the files that # should be deleted, and the newly added ones, # with the description used to differentiate them foreach (sort keys %existing_files} { if ($existing{$_} =~ /^Newly/ ) { print "Added $_;"; } else { print "Delete $_"; } }
Jay "Yohimbe" Thorne, alpha geek for UserFriendly

In reply to Re: Better way? by Yohimbe
in thread Better way? by the_slycer

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

  • 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, 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, 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others about the Monastery: (5)
    As of 2018-04-20 08:55 GMT
    Find Nodes?
      Voting Booth?