When I push the timing files to separate files and run each of them against your script using the debugger I notice that it runs twice for the first file but only once for the second:
main::(working.pl:11): while (<$fh>) { DB<1> main::(working.pl:12): /[(](\w+)[^(]+[(](\w+)[^:]+:\s+(\w+).*?s +lack[^-]+(-\d+)/s; DB<1> main::(working.pl:13): $PG{$3}{"$1-$2"} = $4; DB<1> main::(working.pl:12): /[(](\w+)[^(]+[(](\w+)[^:]+:\s+(\w+).*?s +lack[^-]+(-\d+)/s;
Simple analysis of what is in $_ immediately after Line 11 reveals that it contains everything up to the second record. With the second timing file the same thing shows you the entire file. Therefore, your record separator is not matching correctly. If you change your code to the following it should work:
my $report_file = $ARGV[0]||'timing_report.rpt'; my %PG; local $/ = "Startpoint"; open my $fh, '<', $report_file; while (<$fh>) { if(/[(](\w+)[^(]+[(](\w+)[^:]+:\s+(\w+).*?slack[^-]+(-\d+)/s) { $PG{$3}{"$1-$2"} = $4; } } use Data::Dump; dd \%PG;
You'll notice that I made two changes to your code. 1) I changed the record separator from "\nStartpoint" to just "Startpoint" and 2) I wrapped your regular expression in an if statement.
My recommendations for you going further are as follows:
Celebrate Intellectual Diversity
In reply to Re: regexp with Hash dout
by InfiniteSilence
in thread regexp with Hash dout
by mak.jordan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |