Just to update - I had to revisit this block of code recently with slightly more experience. Wrapping the code in an eval and viewing the resulting $@ revealed that the mkdir was in fact firing twice in immediate succession, producing the 501 error on the second attempt.
$ftp->cwd($i2) or die "change directory $i2: ".$ftp->message." / ".$ft +p->code; my @nfiles = $ftp->dir; if(grep {$_ eq $i3} @nfiles){ die "make $i3: already exists"; } else { $ftp->mkdir($i3) or die "make directory ".$ftp->code; }
Although still not obvious to me exactly where, it looks like code elsewhere was looping over the mkdir without being caught, so I rewrote, removing the eval/dies, which seems to behave as expected.
push @errs,"cannot change directory from $ftp->pwd to i2: $ftp->messag +e" unless $ftp->cwd($i2); my @nfiles = $ftp->dir; push @errs,"cannot list directory $ftp->pwd: $ftp->message" unless @nf +iles; push @errs,"directory $n2 already exists in $ftp->pwd: $ftp->message" +if grep {$_ eq $n2} @nfiles; push @errs,"cannot make directory $n2 in $ftp->pwd: $ftp->message $ftp +->code" unless $ftp->mkdir($n2); $ftp->quit; if(@errs){ print join "<br />",@errs; }

In reply to Re^2: NET::ftp mkdir succeeds but then dies with 501? by rjc_thatsthat
in thread NET::ftp mkdir succeeds but then dies with 501? by rjc_thatsthat

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.