6 use File::Path qw/ make_path /;
8 my $root_dir = '/mnt/Shared/Personal/My art';
9 my $link_dir = '/var/www/html/public';
10 my $http_uri = 'http://136.63.171.222/public';
17 my @chars = ( 'a' .. 'z', 'A' .. 'Z', '0' .. '9' );
19 push @path, $chars[ rand @chars ] for 1 .. 10;
21 return join '', @path;
26 my $path = File::Spec->catdir($link_dir, $nonce);
27 make_path($path, { chmod => 0777 });
32 # get list of files matching name from root directory
34 or die "Need filename!\n";
36 opendir DIR, $root_dir;
37 my @files = grep /$name/, readdir(DIR);
40 # exit if no files found
41 die "No match: $name\n" unless @files;
43 # create nonce dir and add symbolic links
45 my $nonce_dir = makeNonceDir($nonce);
47 for my $file (@files) {
48 my $root_filepath = File::Spec->catfile($root_dir, $file);
49 my $link_filepath = File::Spec->catfile($nonce_dir, $file);
51 symlink $root_filepath, $link_filepath
52 or die "Unable to create symlink: $root_filepath -> $link_filepath";
54 my $uri_link = join '/', ($http_uri, $nonce, $file);