https://github.com/dnmfarrell/devel-didyoumean
https://github.com/dnmfarrell/devel-didyoumean
Last synced: 3 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/dnmfarrell/devel-didyoumean
- Owner: dnmfarrell
- License: other
- Created: 2014-10-25T15:13:31.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2014-11-05T14:06:03.000Z (over 11 years ago)
- Last Synced: 2025-04-09T00:51:28.135Z (about 1 year ago)
- Language: Perl
- Size: 169 KB
- Stars: 4
- Watchers: 2
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.pod
- Changelog: Changes
- License: LICENSE
Awesome Lists containing this project
README
=pod
=encoding UTF-8
=head1 NAME
Devel::DidYouMean - Intercepts failed function and method calls, suggesting the nearest matching alternative.
=head1 VERSION
version 0.05
=head2 SYNOPSIS
#!/usr/bin/env perl
# somescript.pl
use Data::Dumper;
use Devel::DidYouMean;
print Dumpr($data); # wrong function name
*Run the code*
$ somescript.pl
Undefined subroutine &main::Dumpr called at somescript.pl line 7.
Did you mean Dumper?
Or as a one liner:
$ perl -MData::Dumper -MDevel::DidYouMean -e 'print Dumpr($data)'
Undefined subroutine &main::Dumpr called at -e line 1.
Did you mean Dumper?
Or trap the error and extract the matching subs
use Devel::DidYouMean;
use Try::Tiny;
try
{
sprintX("", $text); # boom
}
catch
{
my $error_msg = $_;
my @closest_matching_subs = @$Devel::DidYouMean::DYM_MATCHING_SUBS;
# do something cool here
}
=head2 DESCRIPTION
L intercepts failed function and method calls, suggesting the nearest matching available subroutines in the context in which the erroneous function call was made.
=head2 THANKS
This module was inspired by Yuki Nishijima's Ruby gem L.
Chapter 9 "Dynamic Subroutines" in L second edition by brian d foy was a vital reference for understanding Perl's symbol tables.
tipdbmp on L for pointing me in the direction of signal handling instead of the previous AUTOLOAD approach.
=head2 SEE ALSO
L is a similar module that catches invalid subroutine names and then executes the nearest matching subroutine it can find. It does not export AUTOLOAD to all namespaces in the symbol table.
Mark Jason Dominus' 2014 !!Con L and 2008 blog L about a similar function.
=head1 AUTHOR
David Farrell
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2014 by David Farrell.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=cut