| Server IP : 216.92.14.13 / Your IP : 216.73.216.171 Web Server : Apache System : Linux vps4089.pairvps.com 5.15.0-190-generic #200-Ubuntu SMP Fri Aug 7 15:06:04 UTC 2026 x86_64 User : rmlac2fmr ( 1040637) PHP Version : 8.2.32 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/local/bin/ |
Upload File : |
#!/usr/bin/perl
use strict;
use warnings;
use YAML::PP::Highlight;
use Encode;
use Getopt::Long;
GetOptions(
'help|h' => \my $help,
'expand-tabs|et!' => \my $expand_tabs,
) or usage(1);
$expand_tabs = 1 unless defined $expand_tabs;
usage(0) if $help;
my ($file) = @ARGV;
my $yaml;
unless ($file) {
$yaml = do { local $/; <STDIN> };
$yaml = decode_utf8($yaml);
}
my $error;
my $tokens;
if (defined $file) {
($error, $tokens) = YAML::PP::Parser->yaml_to_tokens( file => $file );
}
else {
($error, $tokens) = YAML::PP::Parser->yaml_to_tokens( string => $yaml );
}
my $highlighted = YAML::PP::Highlight->ansicolored($tokens, expand_tabs => $expand_tabs);
print encode_utf8 $highlighted;
if ($error) {
die $error;
}
sub usage {
my ($rc) = @_;
print <<"EOM";
Usage:
$0 [options] < file
$0 [options] file
Options:
--expand-tabs --et Expand tabs to 8 spaces (default true)
--no-expand-tabs --no-et Don't expand tabs
EOM
exit $rc;
}