#load html file to server my $server_dir = $vars{"server_dir"}; say "server dir is $server_dir"; my $return1 = createDir( $server_dir, $sftp ); say "return1 is $return1"; $sftp->setcwd("/$server_dir") or warn "setcwd1 failed $!\n"; $sftp->put( $vars{html_file} ) or die "html put failed $!\n"; #load css file to server $sftp->setcwd("/css") or warn "setcwd2 failed $@\n"; my $path3 = path( $vars{css_path}, $vars{"css_file"} ); say "path3 is $path3"; my $remote_css = $vars{"css_file"}; $sftp->put( "$path3", $remote_css ) or warn "css put failed $@\n"; # upload images my $image_dir = $vars{"image_dir"}; say "image dir is $image_dir"; my $return2 = createDir( $image_dir, $sftp ); say "return2 is $return2"; $sftp->setcwd("/$image_dir") or warn "setcwd2 failed $!\n"; my $return3 = createDir( $vars{remote_dir}, $sftp ); say "return3 is $return3"; $sftp->setcwd( $vars{remote_dir} ) or warn "setcwd3 failed $!\n"; print $sftp->cwd(), "\n"; #### sub createDir { use 5.011; use Net::SFTP::Foreign; my ( $dirName, $sftp ) = @_; if ( $sftp->test_e($dirName)) { if ( $sftp->test_d($dirName)) { say "execution was here"; return "Directory $dirName already exists!"; } else { return "Can't create $dirName because there's a file in the way!"; } } my $success = $sftp->mkdir($dirName) or return $!; return $success; } #### Put file to server(y/n)?: y server dir is perlmonks execution was here return1 is Directory perlmonks already exists! path3 is /home/bob/2.scripts/pages/1.timeout/template_stuff/1.timeout1.css image dir is pmimage execution was here return2 is Directory pmimage already exists! return3 is 1 /pmimage/1.timeout6