Scanning the code quickly, I see you use goto escape1, and the label escape1 appears at the end of block. This means you can replace the statement by a last or next instead. This is much more maintainable (which you state as a goal). People will have to have to ask themselves whether to add code before or after the label, and wonder what the difference is.

At the end of the script, there is another unconditional goto to somewhere above. This would be much better written as a while(1) { ... } loop or even { ...; redo}.

The comments are useless. You can't do anything with them, apart from reading them when looking at the code. If you want to comment that much, you should be doing it in POD. That way you can extract the documentation and do something with it with external tools

You are not checking to see whether your open calls are succeeding or not. Things could be broken and you wouldn't know about it.

I would write:

$excpdir=$defdev."/wxyzprod/wxyzexcp/"; $logfile=$defdev."/wxyzprod/wxyzlog.txt"; $indir=$defdev."/wxyzprod/wxyzin/"; $outdir=$defdev."/wxyzprod/suppliers/"; $archive=$defdev."/wxyzprod/wxyzarch/";
as
my $dir = '/wxyzprod'; $excpdir="$defdev$dir/wxyzexcp/"; $logfile="$defdev$dir/wxyzlog.txt"; $indir="$defdev$dir/wxyzin/"; $outdir="$defdev$dir/suppliers/"; $archive="$defdev$dir/wxyzarch/";

Factor out the common substrings. Use interpolation. It's easier to maintain (one change) and easier on the eyes (less keystrokes). I'd also use whitespace air the code visually.

If your statting a file to get its mtime, just say so.

($device,$inode,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctim +e, $blksize,$blocks) = stat($getinfile); my($timenow)=time; $delta=$timenow-$mtime; # versus $delta = time - (stat($getinfile))[9];

That way you don't have all those unused variables lying around.

And look for a way to factor out the blocks beginning with if (index($line,"ISA") == -1) into a subroutine. Any time you have large slabs of lines doing the same thing, it will be far more maintainable to have only one copy, and pass the information that changes via parameters.

Hope this helps.


print@_{sort keys %_},$/if%_=split//,'= & *a?b:e\f/h^h!j+n,o@o;r$s-t%t#u'

In reply to Re: EDI Store and Forward System (what's with the gotos?) by grinder
in thread EDI Store and Forward System by diskcrash

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.