Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^4: regex gotcha moving from 5.8.8 to 5.30.0?

by tybalt89 (Monsignor)
on Feb 12, 2021 at 02:56 UTC ( [id://11128286]=note: print w/replies, xml ) Need Help??


in reply to Re^3: regex gotcha moving from 5.8.8 to 5.30.0?
in thread regex gotcha moving from 5.8.8 to 5.30.0?

Tried a whole bunch of things, not all worked, but currently at about 20X faster on 231MB fake file (perl v5.32.0).

#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11128141 use warnings; use Time::HiRes qw( time ); my $string = do { local(@ARGV, $/) = '50k.foo'; <> }; my $start = time; parse_v( $string ); printf "seconds %.3f for length %d file\n", time - $start, length $str +ing; sub parse_v { local $_ = shift; my $name; while( 1 ) { if(/\G (?: (?!endmodule\b|module\b) \S+ \s [^;]* ; | (?<!\N) endmodule \b) \s* /gcx) { } elsif(/\G (?<!\N) module \s+ (\S+?) \s* \( [^)]* \) \s* ; \s* /gcx +) { $name = $1 } else { /\G \z/gcx ? last : die "ERROR: unknown syntax at @{[pos($_ +)]}\n" } } print "LAST MODULE (Perl $]): $name\n"; }

For double negative fans, (?<!\N) means "not preceded by not a newline".

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11128286]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2024-04-25 20:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found