view release on metacpan or search on metacpan
lib/App/perlfind/Plugin/UseModule.pm view on Meta::CPAN
C<Foo::Bar::some_function> or a module that's not installed but whose
namespace-parent might be installed. For example, if C<Foo::Bar> is installed
but C<Foo::Bar::Baz> isn't, we don't want think that there is a function
C<Baz()> in the package C<Foo::Bar>; rather we want to show the docs for
C<Foo::Bar::Baz>. To distinguish between a function and a module, use a simple
heuristic, which means it's a guess and won't always work: if the final symbol
starts with an uppercase character, we assume it's a package, otherwise we
assume it's a function.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/App/perlimports/Document.pm view on Meta::CPAN
sub _has_import_switches {
my $self = shift;
my $module_name = shift;
# If switches are being passed to import, we can't guess as what is correct
# here.
#
# Getopt::Long uses a leading colon rather than a dash. This overrides
# Exporter's defaults. You would normally assume that :config is an export
# tag, but instead it's something entirely different.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/App/perlmv/scriptlet/according_to_containing_dir.pm view on Meta::CPAN
summary => q[Rename file according to its containing directory's name, e.g. foo/1.txt to foo/foo.txt, or foo/somejpeg to foo/foo.jpg],
description => <<'MARKDOWN',
In addition to renaming the file according to the name of its container
directory, if the file does not have an extension yet, an extension will be
given by guessing according to its MIME type using <pm:File::MimeInfo::Magic>,
similar to what the `add_extension_according_to_mime_type` scriptlet does.
MARKDOWN
code => sub {
package
lib/App/perlmv/scriptlet/according_to_containing_dir.pm view on Meta::CPAN
if (-d $_) {
warn "Directory '$_' skipped\n";
return;
}
# guess file extension
my ($ext) = /\.(\w+)\z/;
GUESS_EXT: {
if (defined $ext) {
warn "DEBUG: File '$_' already has extension '$ext', skipped guessing extension\n" if $ENV{DEBUG};
last;
}
require File::MimeInfo::Magic;
my $arg;
if (-l $_) { open my $fh, "<", $_ or do { warn "Can't open symlink $_: $!, skipped\n"; return }; $arg = $fh } else { $arg = $_ }
my $type = File::MimeInfo::Magic::mimetype($arg);
unless ($type) {
warn "Can't get MIME type from file '$_', skipped guessing extension\n";
last;
}
my @exts = File::MimeInfo::Magic::extensions($type) or die "Bug! extensions() does not return extensions for type '$type'";
warn "DEBUG: extensions from extensions($type) for file '$_': ".join(", ", @exts)."\n" if $ENV{DEBUG};
lib/App/perlmv/scriptlet/according_to_containing_dir.pm view on Meta::CPAN
=head1 DESCRIPTION
In addition to renaming the file according to the name of its container
directory, if the file does not have an extension yet, an extension will be
given by guessing according to its MIME type using L<File::MimeInfo::Magic>,
similar to what the C<add_extension_according_to_mime_type> scriptlet does.
=head1 ENVIRONMENT
=head2 DEBUG
view all matches for this distribution
view release on metacpan or search on metacpan
lib/App/perlmv/scriptlet/add_extension_according_to_mime_type.pm view on Meta::CPAN
our $DATE = '2023-06-30'; # DATE
our $DIST = 'App-perlmv-scriptlet-add_extension_according_to_mime_type'; # DIST
our $VERSION = '0.607'; # VERSION
our $SCRIPTLET = {
summary => q[Guess the file content's MIME type using File::MimeInfo::Magic then if type can be guessed and file doesn't yet have extension or has unmatching extension then add an extension],
code => sub {
package
App::perlmv::code;
require File::MimeInfo::Magic;
lib/App/perlmv/scriptlet/add_extension_according_to_mime_type.pm view on Meta::CPAN
},
};
1;
# ABSTRACT: Guess the file content's MIME type using File::MimeInfo::Magic then if type can be guessed and file doesn't yet have extension or has unmatching extension then add an extension
__END__
=pod
=encoding UTF-8
=head1 NAME
App::perlmv::scriptlet::add_extension_according_to_mime_type - Guess the file content's MIME type using File::MimeInfo::Magic then if type can be guessed and file doesn't yet have extension or has unmatching extension then add an extension
=head1 VERSION
This document describes version 0.607 of App::perlmv::scriptlet::add_extension_according_to_mime_type (from Perl distribution App-perlmv-scriptlet-add_extension_according_to_mime_type), released on 2023-06-30.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/App/perlmv/scriptlet/add_suffix_imgsize.pm view on Meta::CPAN
my ($name, $ext);
if ($file =~ /\A(.+)((?:\.\w+)+)\z/) {
($name, $ext) = ($1, $2);
#say "ext=<$ext>";
} else {
warn "File does not have extension, won't guess if it's image, skipped: $file\n";
return $file;
}
#my $existing_suffix;
if ($name =~ s/(\.\d+x\d+)\z//) {
view all matches for this distribution
view release on metacpan or search on metacpan
lib/App/perlrdf/FileSpec/InputRDF.pm view on Meta::CPAN
{
return 'RDF::TrineX::Parser::Pretdsl'
if $self->uri->file =~ /\.(pret|pretdsl)/i;
return RDF::Trine::Parser
-> guess_parser_by_filename($self->uri->file);
}
if ($self->can('response'))
{
return $self->response->content_type
if $self->response->content_type;
return 'RDF::TrineX::Parser::Pretdsl'
if (($self->response->base // $self->uri) =~ /\.(pret|pretdsl)/i);
return RDF::Trine::Parser->guess_parser_by_filename(
$self->response->base // $self->uri,
);
}
return 'RDF::TrineX::Parser::Pretdsl'
if $self->uri =~ /\.(pret|pretdsl)/i;
return RDF::Trine::Parser->guess_parser_by_filename($self->uri);
}
sub _build_parser
{
my $self = shift;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/App/Phoebe/StaticFiles.pm view on Meta::CPAN
return 1;
}
return;
}
# cheap MIME type guessing; alternatively, use File::MimeInfo
sub mime_type {
$_ = shift;
return 'text/gemini' if /\.gmi$/i;
return 'text/plain' if /\.te?xt$/i;
return 'text/markdown' if /\.md$/i;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/App/plx.pm view on Meta::CPAN
my ($oval, $eval) = ($orig_env{$key}, $ENV{$key});
if (!defined($eval) or ($oval//'') ne $eval) {
push @env_change, [ $key, $eval ];
}
}
my $shelltype = local::lib->guess_shelltype;
my $shellbuild = "build_${shelltype}_env_declaration";
foreach my $change (@env_change) {
print +local::lib->$shellbuild(@$change);
}
}
view all matches for this distribution
view release on metacpan or search on metacpan
bin/pod2gfm view on Meta::CPAN
L<Pod::Markdown>
=back
These are similar utilities but they try to guess the language syntax for the
fenced code blocks, unlike L<Pod::Markdown::Githubert> (which lets you specify
a language in POD).
=over 4
view all matches for this distribution
view release on metacpan or search on metacpan
script/_ppgrep view on Meta::CPAN
# my $self = shift;
# $self->{stream} .= join '', @_;
#}
#
## Emit a string value. YAML has many scalar styles. This routine attempts to
## guess the best style for the text.
#sub _emit_str {
# my $self = shift;
# my $type = $_[1] || 0;
#
# # Use heuristics to find the best scalar emission style.
view all matches for this distribution
view release on metacpan or search on metacpan
avoid ualarm.
smoketesting fails where it is absent (Win32 strawberry),
and I chose ualarm by analogy with usleep,
not realising that Time::HiRes::alarm could do what I need,
and I now guess that alarm($frac) is supported on win32.
warn reader of the delay, although it should generally be short;
s/ualarm/alarm/ , but still from Time::HiRes;
check also that it didn't take too long
view all matches for this distribution
view release on metacpan or search on metacpan
lib/App/rdapper.pm view on Meta::CPAN
=item * C<--reverse> - if you provide an IP address or CIDR prefix, then this
option causes C<rdapper> to display the record of the corresponding
C<in-addr.arpa> or C<ip6.arpa> domain.
=item * C<--type=TYPE> - explicitly set the object type. C<rdapper> will
guess the type by pattern matching the value of C<OBJECT> but you can override
this by explicitly setting the C<--type> argument to one of : C<ip>,
C<autnum>, C<domain>, C<nameserver>, C<entity> or C<url>.
=over
view all matches for this distribution
view release on metacpan or search on metacpan
script/_reposdb-inline view on Meta::CPAN
# my $self = shift;
# $self->{stream} .= join '', @_;
#}
#
## Emit a string value. YAML has many scalar styles. This routine attempts to
## guess the best style for the text.
#sub _emit_str {
# my $self = shift;
# my $type = $_[1] || 0;
#
# # Use heuristics to find the best scalar emission style.
view all matches for this distribution
view release on metacpan or search on metacpan
1.006 2025-01-08T03:05:31Z
* first release of a little program I use instead of which(1).
My version takes a regex and looks in all the directories.
1.006 2022-01-08T08:56:01Z
* First release, I guess? I use this as a pattern-aware which(1)-like
utility.
1.005 2021-01-13T11:14:01Z
* freshen distro, remove Travis CI, add Github Actions
view all matches for this distribution
view release on metacpan or search on metacpan
packages somewhere inside your home directory while still using your
favorite distribution.
Till this day, I still haven't tried systemd once, I don't know one single
objective reason why I don't use it, but it's true enough that it's the
very first motivation that got all these things started. I guess that's just
how the world is, few things are objective while basically everything is
subjective. Nevertheless, the goal of B<rs> is to avoid all these subjective
feelings and views on how a distribution should be made, which init system
should be used, what configure switches, compiling flags should be passed,
whether stable version should be preferred over bleeding edge version or the
view all matches for this distribution
view release on metacpan or search on metacpan
lib/App/sdview/Parser/Pod.pm view on Meta::CPAN
$text .= "\n" . $_ for @lines;
my $language = $para->language;
if( ( $language // "" ) eq "__AUTO__" ) {
# Try to detect the language. It doesn't have to be perfect, just a good
# guess is enough.
undef $language;
if( $text =~ m/^use [A-Za-z_]|^package [A-Za-z_]/ ) {
$language = "perl";
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/App/sh2p/Here.pm view on Meta::CPAN
package App::sh2p::Here;
# I expect only one active here doc at a time,
# but I guess they could be in nested loops
# while read var1
# do
# while read var2
# do
# ...
view all matches for this distribution
view release on metacpan or search on metacpan
lib/App/shcompgen.pm view on Meta::CPAN
};
our @supported_shells = qw(bash fish zsh tcsh);
our %shell_arg = (
shell => {
summary => 'Override guessing and select shell manually',
schema => ['str*', {in=>\@supported_shells}],
tags => ['common'],
cmdline_aliases => {
fish => {summary=>"Shortcut for --shell=fish", is_flag=>1, code=>sub { $_[0]{shell} = "fish" }},
zsh => {summary=>"Shortcut for --shell=zsh" , is_flag=>1, code=>sub { $_[0]{shell} = "zsh" }},
lib/App/shcompgen.pm view on Meta::CPAN
}
$envres->as_struct;
}
$SPEC{guess_shell} = {
v => 1.1,
summary => 'Guess running shell',
args => {
},
};
sub guess_shell {
my %args = @_;
my $setdef_res = _set_args_defaults(\%args);
return $setdef_res unless $setdef_res->[0] == 200;
lib/App/shcompgen.pm view on Meta::CPAN
=item * B<prog>* => I<str>
=item * B<shell> => I<str>
Override guessing and select shell manually.
=back
Returns an enveloped result (an array).
lib/App/shcompgen.pm view on Meta::CPAN
The default behavior is to skip if an existing completion script exists.
=item * B<shell> => I<str>
Override guessing and select shell manually.
=item * B<stdout> => I<bool>
Output completion script to STDOUT.
lib/App/shcompgen.pm view on Meta::CPAN
Return value: (any)
=head2 guess_shell
Usage:
guess_shell() -> [$status_code, $reason, $payload, \%result_meta]
Guess running shell.
This function is not exported.
lib/App/shcompgen.pm view on Meta::CPAN
This is possible for only some types of scripts, e.g. L<Perinci::CmdLine>-
(that does not have subcommands) or L<Getopt::Long::Descriptive>-based ones.
=item * B<shell> => I<str>
Override guessing and select shell manually.
=item * B<tcsh_global_dir> => I<array[str]> (default: ["/etc/tcsh/completions"])
Directory to put completions scripts.
lib/App/shcompgen.pm view on Meta::CPAN
This is possible for only some types of scripts, e.g. L<Perinci::CmdLine>-
(that does not have subcommands) or L<Getopt::Long::Descriptive>-based ones.
=item * B<shell> => I<str>
Override guessing and select shell manually.
=item * B<tcsh_global_dir> => I<array[str]> (default: ["/etc/tcsh/completions"])
Directory to put completions scripts.
lib/App/shcompgen.pm view on Meta::CPAN
Can contain path (e.g. C<../foo>) or a plain word (C<foo>) in which case will be
searched from PATH.
=item * B<shell> => I<str>
Override guessing and select shell manually.
=item * B<tcsh_global_dir> => I<array[str]> (default: ["/etc/tcsh/completions"])
Directory to put completions scripts.
view all matches for this distribution
view release on metacpan or search on metacpan
script/skos2jskos view on Meta::CPAN
}
else {
info "Reading RDF files";
my $size = 0;
foreach my $file (@ARGV) {
my $parser = RDF::Trine::Parser->guess_parser_by_filename($file);
$parser->parse_file_into_model( "file://$file", $file, $source );
debug $source->size - $size . " triples from $file";
$size = $source->size;
}
}
view all matches for this distribution
view release on metacpan or search on metacpan
script/soapcli.pl view on Meta::CPAN
The first argument is a request data as a JSON string or a name of file which
contains data in JSON or YAML format.
The second argument is an URL address to WSDL data or a filename of WSDL data
file or a file which contains an URL address to WSDL data. This filename is
optional and can be guessed from first argument.
The third argument is an URL address of endpoint with a name of a webservice
port. The URL address of endpoint is optional if is already a part of WSDL
data. The name of port is optional if it is unambiguous for called method. The
name of port should start with C<#> character.
view all matches for this distribution
view release on metacpan or search on metacpan
bin/sourcepan view on Meta::CPAN
=over 4
=item --dist
Clarifies that the items named on the commandline are distribution names (i.e.
base names of archives). Usually not required, as this will be guessed if the
item name contains a C<-> character.
=item --module
Clarifies that the items named on the commandline are module names (i.e. perl
view all matches for this distribution
view release on metacpan or search on metacpan
DOS we can use these alternate names for tools that don't take spaces
into account.
spaceless converts PATH style environment variables on windows into
equivalents that do not have spaces. By default it uses Shell::Guess to
make a reasonable guess as to the shell you are currently using (not
your login shell). You may alternately specify a specific shell type
using one of the options below.
spaceless will not convert long directory (non 8.3 format) names that
do not have spaces, as these are usually handled gracefully by scripts
--login
Use the your default login shell (as determined by Shell::Guess) On
Unix style systems this consults the GECOS field in the /etc/passwd
file or uses NIS. On other platforms it may use another means to
determine your login shell, or simply make an informed guess based on
the platform.
--no-cygwin
Remove any cygwin paths. Has no affect on non cygwin platforms.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/App/tkispell.pm view on Meta::CPAN
program should save the spell-checked file and the replacement words
in the user's personal dictionary if necessary.
The entry box at the lower right contains replacement text for
misspelled words. The text in the entry is either a selection
from the word guesses or a word entered by the user.
Buttons on the right side of the window select options for replacing
possibly misspelled words.
=head2 Accept
view all matches for this distribution
view release on metacpan or search on metacpan
lib/App/tldr.pm view on Meta::CPAN
$self->{argv} = \@argv;
if ($language) {
$language = $language =~ /^\./ ? $language : ".$language";
}
$self->{language} = $language || '';
if (!$no_pager and -t STDOUT and my $guess = $self->_guess_pager($pager)) {
$self->{pager} = $guess;
}
push @{$self->{platform}}, $self->_guess_platform, "common";
$self;
}
sub _guess_pager {
my $self = shift;
my $cmd;
for my $try (grep $_, @_, $ENV{PAGER}, "less", "more") {
if (my $found = File::Which::which($try)) {
lib/App/tldr.pm view on Meta::CPAN
$out;
}
# XXX
sub _guess_platform {
$^O =~ /darwin/i ? "osx" :
$^O =~ /linux/i ? "linux" :
$^O =~ /sunos/i ? "sunos" : ();
}
view all matches for this distribution
view release on metacpan or search on metacpan
}
elsif ( $arg =~ $ENTITY_PATTERN or $arg =~ $SITELINK_PATTERN ) {
'lookup';
}
else {
my $guess = () = $arg =~ /[a-z]+:[^\s]/gi;
$guess += () = $arg =~ /<[^>]+>/g;
$guess += () = $arg =~ /[?\$][^\s]/g;
if ( $guess > 2 ) {
warning("ignoring additional command line argument")
if $OPT{query} or @ARGV > 1;
'query';
}
else {
=head1 MODES
Request mode C<query> (default), C<lookup>, C<serch>, or C<psearch> can
explicitly be set via first argument or it's guessed from arguments.
=head2 query
Read SPARQL query from STDIN, option C<--query|-q>, or argument. Namespace
definitions and C<SELECT> clause are added if missing.
view all matches for this distribution
view release on metacpan or search on metacpan
lib/App/week.pm view on Meta::CPAN
}
sub argv {
my $app = shift;
for (@{$app->ARGV}) {
call \&guess_date,
for => $app,
with => [ qw(year mon mday show_year) ];
}
return $app;
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/App/wmiirc/Backlight.pm view on Meta::CPAN
use App::wmiirc::Plugin;
with 'App::wmiirc::Role::Key';
# So on my vaio the down works here, but up doesn't(?!), I've hacked it into the
# acpi stuff instead -- urgh. Serves me right for buying proprietary Sony stuff
# I guess.
sub key_backlight_down(XF86MonBrightnessDown) {
system qw(xbacklight -steps 1 -time 0 -dec 10);
}
view all matches for this distribution
view release on metacpan or search on metacpan
lib/App/wordlist/wordle.pm view on Meta::CPAN
delete $_[0]{'x.doc.faq'};
$_[0]{description} = <<'MARKDOWN';
This is a wrapper to <prog:wordlist> designed to be a convenient helper to solve
Wordle puzzle. By default it greps from the `EN::Wordle` wordlist. It accepts
a series of guesses in a format like the following:
A^R^isE^
Pound
might
blA^ck
PR^ivY^
where lowercase means wrong guess, uppercase means correct letter and position,
while (uppercase) letter followed by a caret (`^`) means the letter exists in
another position. It will convert these guesses to regex patterns and the
`--chars-unordered` option and pass it to `wordlist`.
MARKDOWN
$_[0]{examples} = [
{
argv => ['cR^eEk'],
summary => 'One guess',
test => 0,
'x.doc.show_result' => 0,
},
{
argv => ['A^R^isE^', 'Pound', 'might', 'blA^ck', 'PR^ivY^'],
summary => 'Five guesses',
test => 0,
'x.doc.show_result' => 0,
},
];
},
lib/App/wordlist/wordle.pm view on Meta::CPAN
my @chars = split //, $arg;
my $re = '';
my %letter_exists;
while (@chars) {
my $char = shift @chars;
return [400, "Invalid letter '$char' in guess '$arg'"] unless $char =~ /[A-Za-z]/;
my $caret = @chars && $chars[0] eq '^' ? shift(@chars) : '';
my $uc = $char eq uc $char;
$char = lc $char;
if ($caret) { # letter is in another position
my $letters = $possible_letters;
$letters =~ s/$char//;
$re .= "[$letters]";
$letter_exists{$char}++;
$chars_unordered .= $char unless index($chars_unordered, $char) >= 0;
} elsif ($uc) { # correct guess
$re .= $char;
$letter_exists{$char}++;
$chars_unordered .= $char unless index($chars_unordered, $char) >= 0;
} else { # wrong guess
my $letters = $possible_letters;
$letters =~ s/$char//;
$possible_letters =~ s/$char// unless $letter_exists{$char};
$re .= "[$letters]";
}
lib/App/wordlist/wordle.pm view on Meta::CPAN
Examples:
=over
=item * One guess:
wordlist_wordle(arg => ["cR^eEk"]);
=item * Five guesses:
wordlist_wordle(arg => ["A^R^isE^", "Pound", "might", "blA^ck", "PR^ivY^"]);
=back
This is a wrapper to L<wordlist> designed to be a convenient helper to solve
Wordle puzzle. By default it greps from the C<EN::Wordle> wordlist. It accepts
a series of guesses in a format like the following:
A^R^isE^
Pound
might
blA^ck
PR^ivY^
where lowercase means wrong guess, uppercase means correct letter and position,
while (uppercase) letter followed by a caret (C<^>) means the letter exists in
another position. It will convert these guesses to regex patterns and the
C<--chars-unordered> option and pass it to C<wordlist>.
This function is not exported.
Arguments ('*' denotes required arguments):
view all matches for this distribution
view release on metacpan or search on metacpan
lib/App/wordlist.pm view on Meta::CPAN
Included in the distribution is the <prog:wordlist-wordle> script for
convenience. This CLI defaults to grepping the "EN::Wordle" wordlist and you
specify something like `wt_S_` for the pattern (lowercase for letter in
incorrect position, uppercase for letter in correct position, underscore for
unguessed):
% wordlist-wordle 'wt_S_'
_
};
view all matches for this distribution