| 1 | package Perl::Critic::Utils::Perl; | ||
| 2 | |||
| 3 | 40 | ▶ | use 5.010001; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 40 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 40 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | 40 | ▶ | use Exporter 'import'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | |||
| 9 | 40 | our $VERSION = '1.150'; | |
| 10 | |||
| 11 | #----------------------------------------------------------------------------- | ||
| 12 | |||
| 13 | 40 | our @EXPORT_OK = qw( | |
| 14 | symbol_without_sigil | ||
| 15 | ); | ||
| 16 | |||
| 17 | 40 | our %EXPORT_TAGS = ( | |
| 18 | all => \@EXPORT_OK, | ||
| 19 | ); | ||
| 20 | |||
| 21 | #----------------------------------------------------------------------------- | ||
| 22 | |||
| 23 | sub symbol_without_sigil { | ||
| 24 | 97 | ▶ | my ($symbol) = @_; |
|
Subroutine
symbol_without_sigil: called CC=1 SCAR=0.0
Pod
documented
| |||
| 25 | |||
| 26 | 97 | (my $without_sigil = $symbol) =~ s< \A [\$@%*&] ><>xms; | |
| 27 | |||
| 28 | 97 | return $without_sigil; | |
| 29 | } | ||
| 30 | |||
| 31 | #----------------------------------------------------------------------------- | ||
| 32 | |||
| 33 | 40 | 1; | |
| 34 | |||
| 35 | __END__ | ||
| 36 | |||
| 37 | =pod | ||
| 38 | |||
| 39 | =for stopwords | ||
| 40 | |||
| 41 | =head1 NAME | ||
| 42 | |||
| 43 | Perl::Critic::Utils::Perl - Utility functions for dealing with Perl language issues. | ||
| 44 | |||
| 45 | |||
| 46 | =head1 SYNOPSIS | ||
| 47 | |||
| 48 | use Perl::Critic::Utils::Perl qw< :all >; | ||
| 49 | |||
| 50 | my $name = symbol_without_sigil('$foo'); # $name is "foo". | ||
| 51 | |||
| 52 | |||
| 53 | =head1 DESCRIPTION | ||
| 54 | |||
| 55 | This handles various issues with Perl, the language, that aren't necessarily | ||
| 56 | L<PPI|PPI> related. | ||
| 57 | |||
| 58 | |||
| 59 | =head1 INTERFACE SUPPORT | ||
| 60 | |||
| 61 | This is considered to be a public module. Any changes to its | ||
| 62 | interface will go through a deprecation cycle. | ||
| 63 | |||
| 64 | |||
| 65 | =head1 IMPORTABLE SUBROUTINES | ||
| 66 | |||
| 67 | =over | ||
| 68 | |||
| 69 | =item C<symbol_without_sigil( $symbol )> | ||
| 70 | |||
| 71 | Returns the name of the specified symbol with any sigil at the front. | ||
| 72 | The parameter can be a vanilla Perl string or a L<PPI::Element|PPI::Element>. | ||
| 73 | |||
| 74 | |||
| 75 | =back | ||
| 76 | |||
| 77 | |||
| 78 | =head1 AUTHOR | ||
| 79 | |||
| 80 | Elliot Shank <perl@galumph.com> | ||
| 81 | |||
| 82 | |||
| 83 | =head1 COPYRIGHT | ||
| 84 | |||
| 85 | Copyright (c) 2007-2011 Elliot Shank. | ||
| 86 | |||
| 87 | This program is free software; you can redistribute it and/or modify | ||
| 88 | it under the same terms as Perl itself. The full text of this license | ||
| 89 | can be found in the LICENSE file included with this module. | ||
| 90 | |||
| 91 | =cut | ||
| 92 | |||
| 93 | # Local Variables: | ||
| 94 | # mode: cperl | ||
| 95 | # cperl-indent-level: 4 | ||
| 96 | # fill-column: 78 | ||
| 97 | # indent-tabs-mode: nil | ||
| 98 | # c-indentation-style: bsd | ||
| 99 | # End: | ||
| 100 | # ex: set ts=8 sts=4 sw=4 tw=78 ft=perl expandtab shiftround : | ||