[perltidy]
authorHeiko Schlittermann <hs@schlittermann.de>
Wed, 23 Dec 2015 00:21:19 +0100
changeset 57 4edd34dee93d
parent 56 39c4a5f4ac33
child 58 adf016ea4348
[perltidy]
once.pl
--- a/once.pl	Wed Dec 23 00:20:03 2015 +0100
+++ b/once.pl	Wed Dec 23 00:21:19 2015 +0100
@@ -94,8 +94,8 @@
     if ($ENV{PATH_INFO} =~
         m{/(?<path>(?<store>(?<view>$rxVIEW)/$rxFILE)/(?<base>.*))})
     {
-#        use Data::Dumper;
-#        die Dumper \%+;
+        #        use Data::Dumper;
+        #        die Dumper \%+;
         my $view  = deslash realpath catfile $ONCE_VAR, $+{view};
         my $store = deslash realpath catfile $ONCE_VAR, $+{store};
         my $file  = deslash realpath catfile $ONCE_VAR, $+{path};
@@ -135,6 +135,7 @@
       or die "Can't write to $ONCE_VAR: $!\n";
 
     my ($view, $user_dir) = do {
+
         # view: display name
         #       anonymous | hans | …
         # user_dir: the directory name, becomes part of the
@@ -151,6 +152,7 @@
         #
         my ($v, $d);
         if ($ENV{REMOTE_USER} =~ /^\s*(.+)\s*$/) {
+
             # Known users get a directory name based user name.
             # Yes, if somebody can guess the user names, they can guess
             # the directory names too. But they can't guess the
@@ -187,14 +189,15 @@
         my ($delete, $expires, $days) = do {
             my ($d, $e);
             my $days = param('expires');
+
             # sanitize expires
             $days =~ /.*?([+-]?\d+).*/;
             $days = $1 // 10;
             $e = base62 time + $days * 86400;
 
-            if ($days == 0) { $d = 'd' }       # at first [d]ownload
-            elsif ($days < 0) { $d = 'm' }     # only [m]anually
-            else { $d = 'e' }                  # if expired
+            if    ($days == 0) { $d = 'd' }    # at first [d]ownload
+            elsif ($days < 0)  { $d = 'm' }    # only [m]anually
+            else               { $d = 'e' }    # if expired
             ($d, $e, $days);
         };
 
@@ -243,7 +246,8 @@
               length $ONCE_VAR;    # make it relative to $ONCE_VAR
 
             # FIXME: use the rx* patterns from above
-            $dir =~ m{/(?<expires>[a-z\d]{6})-(?<hash>[a-z\d]+)-(?<delete>.)}i or next;
+            $dir =~ m{/(?<expires>[a-z\d]{6})-(?<hash>[a-z\d]+)-(?<delete>.)}i
+              or next;
             my ($hash, $expires, $delete) = @{+}{qw/hash expires delete/};
             if (${expires} <= time and $delete eq 'e') {
                 /(.*)/;
@@ -291,7 +295,7 @@
       @footer,
       end_html;
 
-      return 0;
+    return 0;
 }
 
 sub deletedir {
@@ -361,11 +365,11 @@
 sub base62 {
     my $n = shift // $_;
     die 'input is >MAXINT' if $n == $n - 1 or $n == $n + 1;
-    state $digits = [0..9, 'a'..'z', 'A'..'Z'];
+    state $digits = [0 .. 9, 'a' .. 'z', 'A' .. 'Z'];
     state $base = @$digits;
     my @result;
 
-    for (;$n >= $base; $n = int($n/$base)) {
+    for (; $n >= $base ; $n = int($n / $base)) {
         my $mod = $n % $base;
         unshift @result, $digits->[$mod];
     }
@@ -373,8 +377,8 @@
     join '', @result;
 }
 
+sub gen_uuid {
 
-sub gen_uuid {
     #open my $f, '/dev/urandom' or croak;
     #read $f, my($_), 128/8;
     #/^(.*)$/;