+sub uidvalidity { # read/write
+ my ($self, $val) = @_;
+ my ($scheme, $auth, $path, $query, $frag) = uri_split($$self);
+ if (defined $val) {
+ if ($path =~ s!;UIDVALIDITY=[^;/]*\b!;UIDVALIDITY=$val!i or
+ $path =~ s!/;!;UIDVALIDITY=$val/;!i) {
+ # s// already changed it
+ } else { # both s// failed, so just append
+ $path .= ";UIDVALIDITY=$val";
+ }
+ $$self = uri_join($scheme, $auth, $path, $query, $frag);
+ }
+ $path =~ s!\A/+!!;
+ $path =~ m!\A[^;]+;UIDVALIDITY=([1-9][0-9]*)\b!i ?
+ ($1 + 0) : undef;
+}
+
+sub uid {
+ my ($self, $val) = @_;
+ my ($scheme, $auth, $path, $query, $frag) = uri_split($$self);
+ if (scalar(@_) == 2) {
+ if (!defined $val) {
+ $path =~ s!/;UID=[^;/]*\b!!i;
+ } else {
+ $path =~ s!/;UID=[^;/]*\b!/;UID=$val!i or
+ $path .= "/;UID=$val";
+ }
+ $$self = uri_join($scheme, $auth, $path, $query);
+ }
+ $path =~ m!\A/[^;]+(?:;UIDVALIDITY=[^;/]+)?/;UID=([1-9][0-9]*)\b!i ?
+ ($1 + 0) : undef;
+}