You can also look for the =~ operator and then print the next significant
token:
#!/usr/bin/perl
use strict;
use PPI;
# warnings should always go last
# https://stackoverflow.com/a/38639882/78259
use warnings;
my $file = shift or die "Need a file name!\n";
my $document = PPI::Document->new( $f
On 06/13/2017 05:14 PM, Chas. Owens wrote:
> Two notes:
>
> Firstly, $document->find will return undef if no regexes are found, not an
> empty arrayref, so you should say
[snip]
> Secondly, PPI does not catch all things that can be considered regexes, for
> instance:
[snip]
Thanks. I appreciate
Two notes:
Firstly, $document->find will return undef if no regexes are found, not an
empty arrayref, so you should say
my $regex = $document->find('PPI::Token::Regexp') || [];
or
for my $expr ( @[ $regex || [] ] ) {
or even
print qq(\n$file :\n);
if (my $regex = $document->find('PPI::Token:
Ok. Thanks, Paul and David.
I think I see how I can benefit from Text::Balanced but I now have my
start with PPI and can list the expressions.
Regards,
Lars
#!/usr/bin/perl
use strict;
use warnings;
use PPI;
use Data::Dumper;
my $file = shift or ( die("Need a file name!\n") );
my $document =
See also Text::Balanced and its extract_quotelike:
http://search.cpan.org/~shay/Text-Balanced-2.03/lib/Text/Balanced.pm#extract_quotelike
David
On Tue, Jun 13, 2017 at 7:23 AM, Paul Johnson wrote:
> On Tue, Jun 13, 2017 at 02:03:10PM +0300, Lars Noodén wrote:
> > There are a lot of ways to wri
On Tue, Jun 13, 2017 at 02:03:10PM +0300, Lars Noodén wrote:
> There are a lot of ways to write patterns.
> Is there a module or method that can identify and extract them from a
> larger bit of code regardless of style?
That's not an easy problem. Fortunately, there is a module which will
probab