sub upload {
use strict;
use warnings;
use 5.010;
use Net::FTP;
use Data::Dumper;
my ($rvars, $rftp) = @_;
my %vars = %$rvars;
# get local files into an array
my @filetypes = qw/jpg jpeg png ogv mp4 m4v webm/;
my $pattern = join '|', map "($_)", @filetypes;
my @matching;
opendir my $eh, $vars{"to_vids"} or warn "can't open vids $!\n";
while (defined ($_ = readdir($eh))){
next if m/~$/;
next if -d;
if ($_ =~ /($pattern)$/i) {
push(@matching, $_);
}
}
closedir $eh;
# stat local files, create hash
#my %stat = map {
# lstat($_) or die "Can't lstat $_: $!";
# $_ => {
# s => ( -s _ ),
# }
#} @matching;
#my $hashref = \%stat;
#print Dumper($hashref);
$rftp->cwd("/pages/eh5v.files") or warn "cwd failed in main $!\n";
my $rlist = $rftp->ls();
say "list is @$rlist";
$rftp->binary or warn "binary failed$!\n";
for ( @matching) {
#say "matching is @matching";
my $a = file($vars{"to_vids"},$_);
my $sa = $a->stringify;
#$rftp->put($sa, $_) or warn "put failed $@\n";
}
$rftp->ls();
return $rftp;
}
####
loading vids
list is . .. kitchen.jpg kitchen.m4v kitchen.webm stairs.jpg stairs.m4v
####
$ perl -MCPAN -e shell
Set up gcc environment - 3.4.5 (mingw-vista special r3)
cpan shell -- CPAN exploration and modules installation (v1.9800)
Enter 'h' for help.
####
Fred@Psiborg ~/pages2/krov
$ sudo cpan
-bash: sudo: command not found
Fred@Psiborg ~/pages2/krov
$ cpan
-bash: cpan: command not found
Fred@Psiborg ~/pages2/krov
$ cpan My :: Module
-bash: cpan: command not found
Fred@Psiborg ~/pages2/krov
$