Something like this for the last if
# This isn't perlish at all but if you need a faithfull emulation... my $date = `date '+%m%d%y'|sed s/\ /_/g`; chomp($date); print "checking the existence of log"; if (-e "/local/home/admin/log${date}_box_50") { rename "/local/home/admin/temp_log_copy", "/local/home/admin/log$ +{date}_box_50a" or die "Failed to rename"; } else { rename "/local/home/admin/temp_log_copy", "/local/home/admin/log$ +{date}_box_50" or die "Failed to rename"; }
But really this is horrible! Stop trying to program for shell in perl and learn perl properly! I promise you you'll never look back. In fact whenever I'm writing a shell script now-a-days and I'm thinking about a loop or ...| awk {print $1} or something like that I'll reach for perl!

In reply to Re: convert shell to perl by ncw
in thread convert shell to perl by ergowolf

Title:
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, 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:
    & &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.