XML-XSH2
view release on metacpan or search on metacpan
XML::XSH2::Functions::node_id(xsh_context_node());
}
elsif ($1 eq 'd') {
xsh_context_var();
}
elsif ($1 eq 'n') {
my $node = xsh_context_node();
if ($node and $node->can('getName')) {
eval { $node->getName };
} else {
'';
}
}
elsif ($1 eq 'N') {
my $node = xsh_context_node();
if ($node and $node->can('localname')) {
$node->localname;
} else {
'';
}
}
elsif ($1 eq 'c') {
XML::XSH2::Functions::node_address(undef,1);
}
elsif ($1 eq 'y') {
XML::XSH2::Functions::node_type(xsh_context_node());
}
elsif ($1 eq 'h') {
require Sys::Hostname;
my $host = Sys::Hostname::hostname();
$host=~s/^.*\.//;
$host;
}
elsif ($1 eq 'H') {
require Sys::Hostname;
Sys::Hostname::hostname();
}
elsif ($1 eq 's') {
my $shell = $0;
$shell=~s{^.*/}{};
$shell;
}
elsif ($1 eq 't') {
my ($s,$m,$h)= localtime(time);
sprintf("%02d:%02d:%02d",$h,$m,$s);
}
elsif ($1 eq 'T') {
my ($s,$m,$h)=localtime(time);
sprintf("%02d:%02d:%02d",($h < 13 ? $h : $h-12), $m, $s);
}
elsif ($1 eq 'A') {
my ($s,$m,$h)=localtime(time);
sprintf("%02d:%02d",$h, $m);
}
elsif ($1 eq '@') {
my ($s,$m,$h)=localtime(time);
sprintf("%02d:%02d",($h < 13 ? $h : $h-12), $m);
($h>12 ? 'pm' : 'am');
}
elsif ($1 eq 'u') {
scalar getpwuid($<)
}
elsif ($1 eq 'v') {
$XML::XSH2::Functions::VERSION;
}
elsif ($1 eq 'V') {
my $rev = $XML::XSH2::Functions::REVISION;
$rev =~ s{.*:\s*|\s*\$\E}{}g;
$rev;
}
elsif ($1 eq 'w') {
require Cwd;
Cwd::getcwd();
}
elsif ($1 eq 'W') {
require Cwd;
my $cwd = Cwd::getcwd();
$cwd =~ s{.*/}{};
$cwd;
} else {
'%'.$1;
}
}eg;
$prompt = eval { XML::XSH2::Functions::_expand($prompt) };
if ($@) {
my $err = $@;
chomp $err;
$err =~ s/ at .*//;
warn $err."\n";
return 'prompt-error>';
}
$prompt =~ s{\\(\d{3})|\\(.)}{
defined($1) ? chr(oct($1)) :
($::prompt_char{$2}||'\\'.$2)
}eg;
return $prompt;
}
__END__
=pod
=head1 xsh
xsh - XML Editing Shell
=head1 SYNOPSIS
xsh [options] script_or_command
xsh [options] -al script [arguments ...]
xsh [options] -aC command [arguments ...]
xsh [options] -p commands < input.xml > output.xml
xsh [options] -I input.xml -O output.xml commands
xsh [options] -P file.xml commands
xsh [options] -cD compiled_script.pl ...
xsh -u for usage
xsh -h for help
xsh --man for the manual page
( run in 1.840 second using v1.01-cache-2.11-cpan-f56aa216473 )