Acme-CPANModules-InterestingTies

 view release on metacpan or  search on metacpan

lib/Acme/CPANModules/InterestingTies.pm  view on Meta::CPAN

This module allows you to do `sprintf()` by accessing a hash key, e.g.:

    print $format{17, "%03x"};

will output:

    011

The nice thing about this is that the `$format{...}` term can be put inside
double quote, although you have to use a different quote inside the quote, e.g.:

    print "The value is: $format{17, '%03x'}";
    print qq(The value is: $format{17, "%03x"});

The module advertises the functionality as "printf inside print", although the
author chose to accept a different argument order than printf. Instead of:

    FORMAT, LIST

the FORMAT is put at the end:

    LIST, FORMAT

MARKDOWN
        },

        {
            module => 'Regexp::Common',
            description => <<'MARKDOWN',

This module contains a collection of regular expression patterns. To access the
patterns, you can use the tied hash %RE, e.g.:

    $RE{quoted}
    $RE{num}{real}

You can also give arguments to customize the generated pattern:

    $RE{delimited}{-delim=>'/'}]

The advantage, again, is being able to be used inside a regular expression
pattern.

Note that the module also offers subroutine-based interface. I also created an
alternative module called <pm:Regexp::Pattern> which opts for the non-magical
subroutine-based interface and offers smaller startup overhead.

MARKDOWN
        },

    ],
};

1;
# ABSTRACT: List of interesting uses of the tie() interface

__END__

=pod

=encoding UTF-8

=head1 NAME

Acme::CPANModules::InterestingTies - List of interesting uses of the tie() interface

=head1 VERSION

This document describes version 0.001 of Acme::CPANModules::InterestingTies (from Perl distribution Acme-CPANModules-InterestingTies), released on 2023-10-31.

=head1 DESCRIPTION

The perl's tie interface allows you to create "magical" scalar, array, hash, or
filehandle. When you read or set the value of these variables, various things
can be triggered.

This L<Acme::CPANModules> list catalogs some of the interesting uses of the
tie() interface.

=head1 ACME::CPANMODULES ENTRIES

=over

=item L<Acme::Tie::Formatted>

Author: L<MCMAHON|https://metacpan.org/author/MCMAHON>

This module allows you to do C<sprintf()> by accessing a hash key, e.g.:

 print $format{17, "%03x"};

will output:

 011

The nice thing about this is that the C<$format{...}> term can be put inside
double quote, although you have to use a different quote inside the quote, e.g.:

 print "The value is: $format{17, '%03x'}";
 print qq(The value is: $format{17, "%03x"});

The module advertises the functionality as "printf inside print", although the
author chose to accept a different argument order than printf. Instead of:

 FORMAT, LIST

the FORMAT is put at the end:

 LIST, FORMAT


=item L<Regexp::Common>

Author: L<ABIGAIL|https://metacpan.org/author/ABIGAIL>

This module contains a collection of regular expression patterns. To access the
patterns, you can use the tied hash %RE, e.g.:

 $RE{quoted}
 $RE{num}{real}



( run in 2.941 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )