P

 view release on metacpan or  search on metacpan

lib/P.pm  view on Meta::CPAN


	

	use constant NoBrHr => 0x83;					# Unicode codepoint="No Break Here"
	our	%_dflts;
	our (%mod_dflts, %types);
	BEGIN {
		%_dflts=(
			depth						=> 3, 
			ellipsis				=> '…', 
			expand_duprefs	=> 0,
			implicit_io			=> 0,
			maxstring				=> undef,
			noquote					=> 1, 
			seen						=> '🔁',		# 🔁
			undef						=> '∄',
		);

		my $bool	 = sub { $_[0] ? 1 : 0 };
		my $intnum = sub { $_[0] =~ m{^([0-9]+)$} ? 0 + $1 : 0 };
		my $string = sub { length($_[0]) ? "$_[0]"  : '' };
		my $true	 = sub { 1 };

		%types=(
			default					=> $true,
			depth						=> $intnum, 
			ellipsis				=> $string,
			expand_duprefs	=> $bool,
			implicit_io			=> $bool,
			maxstring				=> $intnum,
			noquote					=> $bool,
			seen						=> $string,
			undef						=> $string,
		);

		#global default copy
		$mod_dflts{""}	= \%_dflts;
	}

lib/P.pm  view on Meta::CPAN

	sub _Px($$;$) { my ($p, $v) = (shift, shift);
		local (*sw); *sw = sub (*):lvalue {
  		defined($p->{$_[0]}) 
              ?  $p->{$_[0]}
              : ($p->{$_[0]} = $mod_dflts{""}->{$_[0]});
		};
#    local (*sw_decr); *sw_decr = sub(*) { my $res;
#      0 >= ($res = sw($_[0])) and return $res;
#      --sw($_[0]); $res };

		unless (sw(expand_duprefs)) {
			if (ref $v && ! SCALAR $v) {
				if ($p->{__P_seen}{$v}) { return "*". sw(seen) . ":" . $v . "*" }
				else { $p->{__P_seen}{$v} = 1 }
			}
		}
		my ($nargs, $lvl, $ro) = (scalar @_, 2, 0);
		if ($nargs) {
			$lvl = $_[0];
			if ($nargs>1) { $ro = $_[1] }
		}



( run in 1.048 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )