For starters, declaring
my $ret twice in the same scope isn't going to work as expected. Consider this:
sub myohmy {
my $y = shift;
my $x = "true" if ($y);
my $x = "not true" if (!$y);
return $x;
}
print "myohmy(0) = ", myohmy(0), "\n";
print "myohmy(1) = ", myohmy(1), "\n";
__END__
# outputs:
myohmy(0) = not true
myohmy(1) =
use warnings will catch this problem. To fix it you'll need to re-write it as:
my $ret;
$ret = ... if ($put_try == 0);
$ret = ... if ($put_try > 0);
but I'd probably just use an
if...else... construct.
Another issue with your retry logic is that if you want to recover from a failed put by appending data, you need to:
- figure out how much data was transfered by the put operation.
- open the source file and seek to that location
- perform an append operation using the opened file handle (as opposed to the source file's name)
It might be easier just to re-
put the file (depending on its size.)
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.